[Haskell-beginners] How to extract from Maybe & Either in GHCi
Ertugrul Soeylemez
es at ertes.de
Thu Apr 14 13:12:15 CEST 2011
Christopher Done <chrisdone at googlemail.com> wrote:
> FWIW there is also Data.Either which has the either function.
Only few people seem to realize that 'maybe' and 'either' exist and how
useful they are. They are defined in the Prelude, so no imports are
necessary.
either this that . maybe defValue foo $ someMaybeEitherValue
They also help with monadic code:
getStuff :: IO (Maybe String)
getStuff >>= maybe (throwIO (MyError "Stuff not available")) putStrLn
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Beginners
mailing list