3 ms·
I love Haskell, but the existence of a bottom type throws all run time guarantees out the window. import Control.Monad ex1 = Just 1 :: Maybe Int ex
by greydius 11y ago
I love Haskell, but the existence of a bottom type throws all run time guarantees out the window.
import Control.Monad
ex1 = Just 1 :: Maybe Int
ex2 = undefined :: Maybe Int
inc = liftM (+1)
main = do
putStrLn . show $ inc ex1
putStrLn . show $ inc ex2
Yes, you should never use `undefined`. Now replace `undefined` with `null` and it becomes apparent that Maybe and Optional have exactly the same amount of power.
- cauterize 11y ago-Wall and hlint both don't warn about the use of undefined!! Am I off base thinking they should be screaming at the user?
- codygman 11y ago> Yes, you should never use `undefined`. Now replace `undefined` with `null` and it becomes apparent that Maybe and Optional have exactly the same amount of power. Null is encouraged and pervasive in Java, undefined is sometimes used as a placeholder and could be forgotten. You can't say that Maybe and Optional have the same amount of power because of this.