[Haskell-cafe] Badly designed Parsec combinators?
Jan-Willem Maessen
jmaessen at alum.mit.edu
Fri Feb 17 11:51:31 EST 2006
On Feb 16, 2006, at 7:32 PM, John Meacham wrote:
> ...
>> Again that doesn't compile, because "when" requires a ()-returning
>> monad as its second parameter, but the "string" parser returns
>> "String".
>> Same thing with if-then-else, when used to switch IO actions and
>> such:
>> the IO actions must fully match in type, even if the returned
>> value will
>> be discarded, and again that can be trivially resolved by adding the
>> "return ()".
>
> This is a straight up bug in the definition of when I hope we fix. it
> should have type
>
> when :: Bool -> IO a -> IO ()
> when = ...
Arguably this could be made true of *every* function which presently
takes m () as an argument. That is, we could systematically go
through the libraries and convert every function of type:
f :: (Monad m) => .... -> m () -> ...
into
f :: (Monad m) => .... -> m otherwiseUnusedTypeVariable -> ...
This would basically eliminate the need for "ignore". I can see
taste arguments in either direction, but really the language ought to
pick an alternative and use it everywhere (including for >>).
-Jan-Willem Maessen
>
> John
>
>
> --
> John Meacham - ⑆repetae.net⑆john⑈
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list