How to use the monocle-ts.Prism.fromPredicate function in monocle-ts

To help you get started, we’ve selected a few monocle-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcanti / fp-ts-codegen / examples / These.ts View on Github external
export function _right(): Prism, These> { return Prism.fromPredicate(s => s.type === "Right"); }
github gcanti / fp-ts-codegen / examples / FooBar.ts View on Github external
export const bar: FooBar = { type: "Bar" };

export function fold(fa: FooBar, onFoo: R, onBar: R): R { switch (fa.type) {
    case "Foo": return onFoo;
    case "Bar": return onBar;
} }

export function foldL(fa: FooBar, onFoo: () => R, onBar: () => R): R { switch (fa.type) {
    case "Foo": return onFoo();
    case "Bar": return onBar();
} }

import { Prism } from "monocle-ts";

export const _Foo: Prism = Prism.fromPredicate(s => s.type === "Foo");

export const _Bar: Prism = Prism.fromPredicate(s => s.type === "Bar");
github gcanti / fp-ts-codegen / examples / Either.ts View on Github external
export function _right(): Prism, Either> { return Prism.fromPredicate(s => s.type === "Right"); }
github gcanti / fp-ts-codegen / examples / Maybe.ts View on Github external
export function _just<a>(): Prism, Maybe</a><a>&gt; { return Prism.fromPredicate(s =&gt; s.type === "Just"); }
</a>
github gcanti / fp-ts-codegen / examples / Constrained.ts View on Github external
export function _fetching<a>(): Prism, Constrained</a><a>&gt; { return Prism.fromPredicate(s =&gt; s.type === "Fetching"); }
</a>
github gcanti / io-ts-types / src / monocle-ts / createRangePrism.ts View on Github external
export const createRangePrism = (from: number, to: number): Prism =&gt; {
  return Prism.fromPredicate(n =&gt; n &gt;= from &amp;&amp; n &lt;= to)
}
github gcanti / fp-ts-codegen / examples / Maybe.ts View on Github external
export function _nothing<a>(): Prism, Maybe</a><a>&gt; { return Prism.fromPredicate(s =&gt; s.type === "Nothing"); }
</a>
github gcanti / fp-ts-codegen / examples / Either.ts View on Github external
export function _left(): Prism, Either&gt; { return Prism.fromPredicate(s =&gt; s.type === "Left"); }
github gcanti / fp-ts-codegen / examples / Tree.ts View on Github external
export function _leaf<a>(): Prism, Tree</a><a>&gt; { return Prism.fromPredicate(s =&gt; s.type === "Leaf"); }
</a>
github gcanti / fp-ts-codegen / examples / Option.ts View on Github external
export function _none<a>(): Prism, Option</a><a>&gt; { return Prism.fromPredicate(s =&gt; s.type === "None"); }
</a>