Skip to content

Commit 8471976

Browse files
bo0tzzlpil
authored andcommitted
Document zero parameter for decode.failure
I think people are likely to encounter failure before new_primitive_decoder, so add this explanation there too. This is basically copied from new_primitive_decoder, if you prefer other wording please let me know.
1 parent bf6b6f2 commit 8471976

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/gleam/dynamic/decode.gleam

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,10 @@ fn run_decoders(
981981
/// Define a decoder that always fails. The parameter for this function is the
982982
/// name of the type that has failed to decode.
983983
///
984+
/// When this decoder is used as part of a larger decoder, the zero value is
985+
/// used as a placeholder so that the rest of the decoder can continue to run
986+
/// and collect all decoding errors.
987+
///
984988
pub fn failure(zero: a, expected: String) -> Decoder(a) {
985989
Decoder(function: fn(d) { #(zero, decode_error(expected, d)) })
986990
}
@@ -991,7 +995,7 @@ pub fn failure(zero: a, expected: String) -> Decoder(a) {
991995
/// define a decoder for Erlang's pid type.
992996
///
993997
/// A default "zero" value is also required to make a decoder. When this
994-
/// decoder is used as part of a larger decoder this zero value used as
998+
/// decoder is used as part of a larger decoder this zero value is used as
995999
/// a placeholder so that the rest of the decoder can continue to run and
9961000
/// collect all decoding errors.
9971001
///

0 commit comments

Comments
 (0)