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

Daniel Fischer daniel.is.fischer at googlemail.com
Thu Apr 14 00:29:41 CEST 2011

On Thursday 14 April 2011 00:14:19, blackcat at pro-ns.net wrote:
>  I've got some values in GHCi that look like
>  Just (Left (Blah [stuff]))
>  and I'd like to pull out the (Blah [stuff]) to operate on it.  Is there
>  a way to do this directly in GHCi without writing a helper function?

I'm not quite sure what you want, you can bind the Blah [stuff] to a name 
using a pattern-match, perhaps that's what you want.

After the fact:

ghci> let Just (Left blah) = it
ghci> doSomethingWith blah


ghci> case it of Just (Left blah) -> doSomethingWith blah

Before: replace 'it' with the expression generating Just (Left (Blah 

More information about the Beginners mailing list