import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { right } = optic;
A preconstructed composed prism that focuses on the Right value of an Either.
Examples
Example 1
Example 1
import * as O from "./optic.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";
type Response = E.Either<Error, string>;
const value = pipe(O.id<Response>(), O.right);
const result1 = pipe(value, O.view(E.right("Good job!")));
// Some("Good job!")
const result2 = pipe(value, O.view(E.left(new Error("Something broke"))));
// None