Skip to content
pannous edited this page Jul 4, 2022 · 7 revisions

Monads are basically wrappers with some algebraic properties

Examples of monads familiar to most programmers should be Promises, Lists, Optionals, Closures and IO.

In all cases, the 'pure' monad is boring:

1 => Promise(1)
1 => [1]
1 => Some(1)
1 => (x => 1)  // whatever you give me, I return 1
readFileMock := "haha, no real IO"

In all cases, asking for a value of non-pure monads directly makes little sense:

x := anyPromise(); x.value(); // async task may not have finished yet!
x := [1, 2, 3]; x.value(); // which one??
x := maybeAnswer(); x.value(); // might be null or error, check first!
x := y=>z(); x.value() // you need to apply x to something!
readFile.value; // first give me the file to read then wait for hard drive

https://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

With these insights in mind, the algebraic properties might suddenly become intuitive. Similar to Groups and Rings it is a beautiful lens through which to observe the universe, normal programmers might not find or define their own Monads. However for higher level researchers or developers they can be a powerful tool, which is why we aim to enable this abstraction as a first class citizen, at the very least through general operator overloading and block parameters.

Questions

How does our automatic broadcasting correspond to automatic lifting and (un)boxing?

Can the pipe operator be the universal monad operator '>>=' of haskell ?

See smart-pointers on how to implement optionals efficiently.

Home

Philosophy

data & code blocks

features

inventions

evaluation

keywords

iteration

tasks

examples

todo : bad ideas and open questions

⚠️ specification and progress are out of sync

Clone this wiki locally