3 ms·
It is an absence of side effects because side effects are defined as effects that cannot be accounted for. As soon as you have a mechanism to document those eff
by wz1000 11y ago
It is an absence of side effects because side effects are defined as effects that cannot be accounted for. As soon as you have a mechanism to document those effects, they are not "side effects" any more.
hello :: IO ()
hello = putStrLn "Hello World"
`hello` is a "pure" value of type IO (). putStrLn a "pure" function of type -> IO ()
IO () is a value like any other "pure" value, like [Int].
- denim_chicken 11y agoC is "pure" too. The statement puts ("hello"); is a "pure" value of type int.
- dllthomas 11y agoNo, that statement evaluates to a pure value of type int. In the process, it does something else as well that effects the visible behavior of the program. The C equivalent of putStrLn "hello" is probably actually void putsHello(void) { puts("hello"); } Unfortunately, function definitions aren't something you can really manipulate at runtime in C.
- deleted 11y ago[deleted]
- wz1000 11y agoHere is a comment I wrote about the same issue some time ago: https://news.ycombinator.com/item?id=9085403 https://news.ycombinator.com/item?id=9085403 Haskell IO is severely misunderstood.