3 ms·
That's why I like ocaml and racket (or scheme). Functional, but you don't need to jump through hoops to do basic stuff like I/o.
by shawn_w 2y ago
That's why I like ocaml and racket (or scheme). Functional, but you don't need to jump through hoops to do basic stuff like I/o.
- develop7 2y agoBecause everything can do IO and launch missiles there :) And there's no way to limit it (except maybe algebraic effects introduced recently? I'm pretty sure nobody uses them anyway)
- hollerith 2y agoWhen you grok the IO type ("monads") it stops feeling like jumping through hoops, and then it isn't any harder to write imperative code in it than in any normal, imperative language. Or at least that was my experience.
- simonmic 2y agoHaskellers think I/O is an important effect and want to manage when it's allowed. It's allowed in the IO context, which happens to be the default: main = do putStrLn "hello world" more more = putStrLn "hello again, still in IO" If you want to, you can break the rule and do I/O from non-IO functions, by using trace: import Debug.Trace add :: Int -> Int -> Int add a b = trace ("adding " ++ show a ++ " and " ++ show b) (a + b) or unsafePerformIO: import System.IO.Unsafe add :: Int -> Int -> Int add a b = unsafePerformIO $ do appendFile "debug.log" ("adding " ++ show a ++ " and " ++ show b ++ "\n") return (a + b) Not exactly white-hot hoops of fire ? :)