1.0.3 • Published 5 years ago
monadic-bind v1.0.3
The bind (a.k.a. chain) operator, Haskell's >>=,
implemented for plain native JavaScript types, as a function.
Namely for:
Array, works like Haskell'sList Monadnumber, unusual, perhaps, you're free to ignore it. But in JavaScript,NaNis sort of an empty value within thenumbertype..., not treated as a "string[Char]", however, you can just.split()it to anArray<string>T | null | undefined, works like Haskell'sMaybe
FAQ
Show me an example!
import {bind} from "monadic-bind";
const u = getUserOrNull("Joe")
bind(u, printUser);Why not data-last?
TypeScript's type inference is left to right, putting the data argument first helps it infer the function argument's type.
Anyway, data-last only makes sense if the language has automatic currying, which JavaScript doesn't.