import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { annotate } = decoder;
Annotate the DecodeError output of an existing Decoder if it fails while parsing. Internally, this uses the DecodeError Wrap constructor.
Examples
Example 1
Example 1
import * as D from "./decoder.ts";
import { pipe } from "./fn.ts";
const decoder = pipe(
D.literal("a", "b", "c", 1, 2, 3),
D.annotate("like the song"),
);
const result1 = decoder(1); // Right(1)
const result2 = D.unwrap(decoder("d"));
// Left(`like the song
// └─ cannot decode "d", should be "a", "b", "c", 1, 2, 3`)