Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>decoder.unwrap

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function decoder.unwrap
import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { unwrap } = decoder;

A combinator over Decoded that maps a DecodeError into a printable tree.

Examples

Example 1

import * as D from "./decoder.ts";
import { pipe } from "./fn.ts";

const result1 = pipe(
  D.failure(1, "string"),
  D.unwrap,
); // Left("cannot decode 1, should be string")
const result2 = pipe(
  D.success(1),
  D.unwrap
); // Right(1)

Returns

Either<string, A>