> Here is a laundry list of things I think Haskell still needs.  By
> Haskell here I mean Haskell plus extension that are found in both hugs
> and ghc.
...
> 4) Being able to write
>   do a <- getLine
>      b <- getLine
>      proc a b
> as
>   proc getLine getLine
> and the like.  I don't know the number of times that I get REALLY sick
> of having to explicitly bind everything to a variable.  Monads do a very
> good job of supporting imperative style.  Now lets make them less
> tedious to use.

You could define proc':

proc' act1 act2 = do
  v1 <- act1
  v2 <- act2
  proc v1 v2

so you can write:

 proc' getLine getLine

When proc returns a value rather than a computation, i.e., proc :: a -> b ->
c, and c is not monadic, then you can just write Monad.liftM2 proc getLine
getLine.

You could define a higher-order version of proc' above in the same vein:

liftM2' :: (a -> b -> m c) -> (m a -> m b -> m c)
liftM2' proc m1 m2 = do
  v1 <- m1
  v2 <- m2
  proc v1 v2

In simpler cases where proc takes only one argument, you can avoid thinking
up new names by currying:

  getLine >>= proc

I find that if you make liberal use of higher-order constructs and
modularize your code, then the need to do explicit binding is not so much of
a problem. Then again, I am the sort of person who uses "let" and "where"
whenever he can to name subexpressions as well...

--FC




Reply via email to