[Haskell-beginners] How to extract from Maybe & Either in GHCi

Christopher Done chrisdone at googlemail.com
Thu Apr 14 02:19:15 CEST 2011


On 14 April 2011 00:52, <blackcat at pro-ns.net> wrote:

>  Pattern matching works in ghci:
>>
>>  let x = Just (Left (Blah [stuff]))
>>> let (Just (Left (Blah y)) = x
>>>
>>
> Thanks! That's exactly what I'm looking for.


FWIW there is also Data.Either which has the either function.

λ> :t either
either :: (a -> c) -> (b -> c) -> Either a b -> c

Quite useful sometimes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110414/1d19f73b/attachment.htm>


More information about the Beginners mailing list