Cite.Answer (Cite v0.1.0)

Copy Markdown View Source

Reply maps to values.

Knows what an answer to each question type may be, and nothing else. Every answer that reaches noul/1 has passed check/2; a reply that fails it is an error for its whole request, never a value. Internal.

Summary

Functions

Checks a reply against the questions it answers, as they went on the wire: :ok when every question has one well-formed answer, otherwise {:error, {:missing_answers, keys}} or {:error, {:malformed_answers, keys}}, keys sorted, missing first. A reply that fails is an error for its whole request, never a "no".

The Noul probability of a well-formed Noul answer.

Functions

check(questions, answers)

@spec check(%{required(String.t()) => map()}, map()) ::
  :ok | {:error, {:missing_answers | :malformed_answers, [String.t()]}}

Checks a reply against the questions it answers, as they went on the wire: :ok when every question has one well-formed answer, otherwise {:error, {:missing_answers, keys}} or {:error, {:malformed_answers, keys}}, keys sorted, missing first. A reply that fails is an error for its whole request, never a "no".

noul(map)

@spec noul(map()) :: number()

The Noul probability of a well-formed Noul answer.