You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Monads were introduced into fp because Haskell is lazy
Mainstream languages are based on strict evaluation.
the expressions are evaluated when they are bound to a name
the function args are evaluated before they're applied to a function
fun second(a: Int, b: Int, c: Int):Int=
{ println("Ignore everything and return second"); b }
let c = { println("Evaluating C"); 3 }
let result = second(
{ println("Evaluating A"); 1 },
{ println("Evaluating B"); 2 },
c
)
println(result)
the side-effects are executed during the evaluation of the expression where they are defined.
second a b c =putStrLn"Ignore everything and return second">>=\\_ ->return b
main::IO()
main =putStrLn"Evaluating C">>=\\_ ->return3>>=\\c ->putStrLn"Evaluating A">>=\\_ ->return1>>=\\a ->putStrLn"Evaluating B">>=\\_ ->return2>>=\\b ->
second a b c >>=\\result ->putStrLn (show result)
Why are we using monads / monad-like things outside of Haskell ?
monads are great not just for modeling native effects but also for any custom or user-defined effect
THE ACTUAL SUPERPOWER OF MONADS IS THE EMBEDDING OF CONTROL FLOW
In traditional programming languages, the set of control flow patterns is fixed. Such as, try/catch, while, for, async/await, ...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Death of Monads? Direct Style Algebraic Effects
MONADS ARE INFAMOUS
Monads were introduced into fp because
Haskell is lazy
Mainstream languages are based on strict evaluation.
THE ACTUAL SUPERPOWER OF MONADS IS THE EMBEDDING OF CONTROL FLOW
In traditional programming languages, the set of control flow patterns is
fixed
. Such as,try/catch
,while
,for
,async/await
, ...Beta Was this translation helpful? Give feedback.
All reactions