[Haskell-beginners] Using Either and Maybe

Dan Serban dserban01 at gmail.com
Sun May 4 15:42:01 UTC 2014


Hi Alan,

Check out these two functions, they point you towards how to write
more idiomatic code. They are called smart destructors, google that
term for more information:

λ> :i maybe
maybe :: b -> (a -> b) -> Maybe a -> b 	-- Defined in `Data.Maybe'
λ> :i either
either :: (a -> c) -> (b -> c) -> Either a b -> c
  	-- Defined in `Data.Either'


More information about the Beginners mailing list