A realization I had tonight: the monadic IO construct Haskell uses to enforce purity does not require static types—it works perfectly fine in a dynamically-typed language, too. This seems obvious in retrospect but clearly isn’t, given that I hadn’t thought about it until now!
-
-
When I first saw your tweets, I agreed, but… you can still do let _ = putStrLn "hello" in putStrLn "goodbye" in Haskell. If you do something like let x = getLine in x ++ "!" then it’ll fail faster in Haskell, but it’d still be a runtime error in a dynamically typed lang.
-
I can’t construct a program in this hypothetical pure, dynamically typed language that Haskell catches statically but the dynamically typed language does not detect dynamically (assuming the relevant code is actually executed, of course).
- 2 more replies
New conversation -
-
-
the fiasco was well demonstrated with C# STM. the funny thing is that while monads need a purely functional language to work, monads are also the only thing that can give pure fp data structures causality (an evaluation order) between any values. so pure fp needs monads too.
-
otherwise you can't even estimate how long a list's first element will take to calculate, because the runtime could well decide to evaluate every element after the first one before that first one! with monads it physically can't, because the 2nd element requires the 1st to exist.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.