Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Created March 12, 2019 06:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save puffnfresh/fb08b02915a6018a10335ed884e8819f to your computer and use it in GitHub Desktop.
Save puffnfresh/fb08b02915a6018a10335ed884e8819f to your computer and use it in GitHub Desktop.
type LoadedData<A> =
<B>(f: (a: A) => B, g: (e: Error) => B, b: B) => B;
function loaded<A>(a: A): LoadedData<A> {
return <B>(f: (a: A) => B, error: (e: Error) => B, empty: B) => f(a);
}
function error<A>(e: Error): LoadedData<A> {
return <B>(success: (a: A) => B, f: (e: Error) => B, empty: B) => f(e);
}
function loading<A>(): LoadedData<A> {
return <B>(success: (a: A) => B, error: (e: Error) => B, e:B ) => e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment