5 ms·
Haskell allows this too, users can just code everything within IO until they feel comfortable with adding extra purity through refactoring: main :: IO ()
by ghostwriter 5y ago
Haskell allows this too, users can just code everything within IO until they feel comfortable with adding extra purity through refactoring:
main :: IO ()
main = do
myBusinessLogic
myBusinessLogic :: IO ()
myBusinessLogic = do
doThing1
doThing2
doThing1 :: IO ()
doThing1 = do
putStr "Hello "
doThing2 :: IO ()
doThing2 = do
putStrLn "World"
---
ghc -o main main.hs
[1 of 1] Compiling Main ( main.hs, main.o )
Linking main ...
./main
Hello World
- dboreham 5y agoTrue. Perhaps my issue is that I know how that's implemented and my brain can't see it the same as sequential statement execution ;)
- JoelMcCracken 5y agoThis is a function of familiarity though. Get familiar with it and you'll understand it just fine. If you want to talk more about it, feel free to email me.
- tome 5y agoI think dboreham's objection was exactly the opposite!
- JoelMcCracken 5y agoIdk i mean simply knowing what the code for >> looks like doesn't mean you're used to thinking in that way. There was a time years ago when someone was showing me the types of (>>) and (>>=) in Haskell and my question was "ok, but what does that have to do with IO?!?"