Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Created November 19, 2020 14:39
Show Gist options
  • Save kasperpeulen/580380e42a46ad94b67a7e5c91400f87 to your computer and use it in GitHub Desktop.
Save kasperpeulen/580380e42a46ad94b67a7e5c91400f87 to your computer and use it in GitHub Desktop.
type Monad<A> = Array<A>;
function of<A>(a: A): Monad<A> {
return [a];
}
function flatMap<A, B>(monad: Monad<A>, cb: (a: A) => Monad<B>): Monad<B> {
return monad.flatMap(cb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment