[Haskell-cafe] case of (was: [Haskell] Mixing monadic and non-monadic functions)

Sven Moritz Hallberg pesco at gmx.de
Tue Sep 20 04:14:13 EDT 2005

Donn Cave schrieb:

> The ordinary lambda comes close - in ghc anyway, it supports
> pattern matching.  But I can't work out the syntax for multiple
> cases, which would obviously be needed to make it practically
> useful.
> e.g., this seems to be OK:
>     getArgs >>= \ (a:_) -> putStrLn (show a)
> but how do you write
>     getArgs >>= \	[] -> putStrLn "(no arguments)"
> 			(a:_) -> putStrLn (show a)
> (pardon me if I missed where you were going in "case of ...")

Sorry, I'm just jumping into this discussion, but why shouldn't the
above work? I.e. extend lambda to accept a group of patterns:

	\{Pat1 -> exp1; Pat2 -> exp2; Pat3 -> exp3}


Sven Moritz

More information about the Haskell-Cafe mailing list