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

Donn Cave donn at drizzle.com
Tue Sep 20 12:31:46 EDT 2005


On Tue, 20 Sep 2005, Bernard Pope wrote:
> On Tue, 2005-09-20 at 10:14 +0200, Sven Moritz Hallberg wrote:
> > Donn Cave schrieb:
...
> > > but how do you write
> > >     getArgs >>= \	[] -> putStrLn "(no arguments)"
> > > 			(a:_) -> putStrLn (show a)

> What about good old let?
> 
> main
>    = getArgs >>=  let f []    = putStrLn "(no arguments)"
>                       f (a:_) = putStrLn (show a)
>                   in f

Indeed, I think I'm even on record somewhere arguing that lambda
is more or less extraneous.  Over-used, at any rate.  I was thinking
"where" instead of "let", but same difference.

But I wouldn't think the Haskell community would favor the Python
approach, where they have lambda but don't mind that it's sort of
crippled.  If lambda is staying, and it's feasible to make it
syntactically equivalent to a named function, that seems better than
a new "caseof" that appears to be essentially the same thing.

	Donn Cave, donn at drizzle.com



More information about the Haskell-Cafe mailing list