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!
-
Show this thread
-
Replying to @lexi_lambda
This would introduce a new class of bugs where effects are lost because IO t’s were let-bound instead of composed. Built-in constructs like IO rely on the fact that you can never capture an IO t and examine it.
1 reply 0 retweets 4 likes -
Replying to @TimSweeneyEpic @lexi_lambda
A mixed functional/imperative language with eager or lenient evaluation and effects-typing instead of monads extends more naturally to an untyped interpreter. There, the worst that can happen is running effects in a context intended to be pure.
2 replies 0 retweets 1 like -
Replying to @TimSweeneyEpic
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.
2 replies 0 retweets 1 like
Oh wow. You’re right. My mental model of IO t was broken.
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.