Description Value Usage Details Examples
These functions implement basic monads as seen in Haskell.
Usually a monad
Maybe(a) Just(a) Nothing()
unit(x) unit(x)
Bind operator m m
m m
Regular composition f(g(x)) f
Monad composition g(f(x)) f
Monad composition f(g(x)) f
Monads are types that carry context. Monad operators enable chaining monadic operations together.
1 2 3 4 5 6 7 8 9 10 11 12 | require(lambda.r)
safelog(x) %::% numeric : Maybe
safelog(x) %when% { x <= 0 } %as% Nothing()
safelog(x) %:=% Just(log(x))
safesqrt(x) %::% numeric : Maybe
safesqrt(x) %when% { x <= 0 } %as% Nothing()
safesqrt(x) %:=% Just(sqrt(x))
safelogsqrt <- safelog %<=<% safesqrt
safelogsqrt(-2)
safelogsqrt(2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.