Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


That'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)


Right! 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.


Well, that just pushes the goalposts of the complaint: now Haskell has Int, and those other languages do not.


I 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.


No, you can't think of C's int that way - it doesn't have a null.


You are completely right, not sure where my head was :P




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: