Re:Why functional programming matters (1990) [pdf]
by nbouscal on Thursday May 07, 2015 @08:20AM
(#9504502)
You're using a somewhat non-standard definition of "purity", which makes your claims more confusing than they need to be. Haskell is usually referred to as pure, and has had encapsulated effects from the start. Your claims are true using your definition of "purity", but false using the more common one.
Re:Why functional programming matters (1990) [pdf]
by dllthomas on Friday May 08, 2015 @10:28AM
(#9511882)
As a point of historical note, Haskell has not had encapsulated effects from the start. Monadic IO was introduced in version 1.3, roughly 6 years after version 1.0.
http://research.microsoft.com/en-us/um/people/simonpj/papers...
Re:Why functional programming matters (1990) [pdf]
by nbouscal on Sunday May 10, 2015 @03:59PM
(#9521114)
Thanks for the correction! I wondered about that when I was writing it but didn't have time to go double-check.
Re:Why functional programming matters (1990) [pdf]
by wz1000 on Thursday May 07, 2015 @06:25AM
(#9504074)
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].
Re:Why functional programming matters (1990) [pdf]
by denim_chicken on Thursday May 07, 2015 @10:14AM
(#9505162)
C is "pure" too.
The statement
puts ("hello");
is a "pure" value of type int.
Re:Why functional programming matters (1990) [pdf]
by dllthomas on Thursday May 07, 2015 @10:26AM
(#9505235)
No, 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.
Re:Why functional programming matters (1990) [pdf]
by wz1000 on Thursday May 07, 2015 @12:28PM
(#9506267)
Here is a comment I wrote about the same issue some time ago:
https://news.ycombinator.com/item?id=9085403
Haskell IO is severely misunderstood.
Re:Why functional programming matters (1990) [pdf]
by mbrock on Thursday May 07, 2015 @05:36AM
(#9503978)
Can you clarify the essential difference between Haskell's and Agda's versions of monadic I/O?
Or are you talking about divergent side-effects like bottom and exceptions?
Re:Why functional programming matters (1990) [pdf]
by mafribe on Thursday May 07, 2015 @09:30PM
(#9509523)
Thanks for your question. I should have been more careful. I meant Agda used as a prover,
not Agda used as a 'conventional' programming language (Indeed in years of usage, I've never executed an Agda program, I've only ever used the type checker). In other words, Agda, the proof calculus for Martin-Loef type theory.
That said, I was talking about effects in general, including non-termination, exceptions, concurrency ...
What Haskell contributes (in a concrete implementation, the ideas go back to Moggi's theory) is the monadic encapsulation of effects, which I treat as a separate point under (viii). Monadic encapsulation of effects is not absence of effects. It's a reflection of effects at the type level.