Re:Brilliance of Haskell's Maybe type and the Value of Stati...
by Zak on Sunday July 25, 2010 @05:16PM
(#1546372)
I've always thought it bizarre that many languages with static typing allow arbitrary values to be null. It's par for the course with dynamic typing, of course. Damn you, C.A.R. Hoare!
[ Parent
| on HN ]
Re:Brilliance of Haskell's Maybe type and the Value of Stati...
by tome on Sunday July 25, 2010 @05:24PM
(#1546386)
He did apologise for it:
Re:Brilliance of Haskell's Maybe type and the Value of Stati...
by _delirium on Sunday July 25, 2010 @07:42PM
(#1546638)
It's a common design change in C dialects, but none seem to have really caught on. For example, Cyclone has both nullable and non-nullable pointers (http://cyclone.thelanguage.org/wiki/Cyclone%20for%20C%20Prog...).
Re:Brilliance of Haskell's Maybe type and the Value of Stati...
by eelco on Monday July 26, 2010 @01:55AM
(#1547271)
I like Objective-C's solution, where one can just send messages to nil. The practical result when writing code is pretty close to using the Maybe monad applicatively (i.e., write your code like the value is never nil, only check for nil when it's part of the (bigger) logical flow in your code.)
Re:Brilliance of Haskell's Maybe type and the Value of Stati...
by masklinn on Monday July 26, 2010 @02:46AM
(#1547336)
The problem is that, though operations flow better, it's a good way to hide bugs until you've completely lost its context, and then finding out its source is a pain unless you have a backtracking debugger.
An option type, especially one which allows you to lift operations into it (as Haskell's does) is a much better solution as it gives the programmer the choice of behavior: does he not care and just want to keep his option, or does he want to know and unwrap the value within the container?
Objective-C allows half of this, but it's generally the wrong half.
Most other statically typed languages allow neither solution and are therefore broken.