5 ms·
Haskell have the Maybe monad, which is defined as Just a | Nothing. One may argue then that languages with nullable integers implicitly define this type as Mayb
by pera 8y ago
Haskell have the Maybe monad, which is defined as Just a | Nothing. One may argue then that languages with nullable integers implicitly define this type as Maybe Int.
- Retra 8y agoWell, that just pushes the goalposts of the complaint: now Haskell has Int, and those other languages do not.
- pera 8y agoI meant that in some way one could think of, for instance, C's int as a sum type of just integer and null :) in practice the obvious difference is that a language like Haskell enforce considering both options with its type checker.
- AnimalMuppet 8y agoNo, you can't think of C's int that way - it doesn't have a null.
- pera 8y agoYou are completely right, not sure where my head was :P
- Peaker 8y agoThat's the Maybe type. The Maybe monad is this: instance Monad Maybe where return = Just Nothing >>= _ = Nothing Just x >>= f = f x (And is not really related to the discussion)
- pera 8y agoRight! that definition was the type, thanks for the correction :) still, the Maybe monad is used for computations that may fail, which is often the purpose of the null pointer.