Juan Carlos Arevalo Baeza wrote:
  Another case where I encounter this is with the "when" function:

myParser2 :: Bool -> Parser ()
myParser2 all =
       do  string "Hello"
           when all $
               do  string ", world"
           string "!"

I made a function (did I miss one in the base package?)

ignore :: Monad m => m a -> m ()
ignore m = m >> return()

and write "ignore $ string "..." if necessary.

"when b m" is "if b then m else return()".
I don't think that the then- or else- branch of any if- expression schould be automatically casted to some matching type "m ()" (and I don't know what implications this would have to typing in general).

However "when b m" could be generalized by "if b then ignore m else return ()". (The same applies to "unless")

Cheers Christian
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to