[Haskell-cafe] Scary type inference for monadic function definitions

Henning Thielemann lemming at henning-thielemann.de
Thu Jun 4 06:56:02 EDT 2009


Ahn, Ki Yung wrote:
> Scary type inference for monadic function definitions
> (or, why you'd want to annotate types for monadic function definitions)
> 
> This is a real example that I've experienced.
> 
> I defined the following function.
> 
>> checkOneVerseByLineWith readLine v =
>>   do mg <- readLine
>>      case mg of
>>        Just g  -> return Just (v==g)
>>        Nothing -> return Nothing

How about
 liftM (fmap (v==)) readLine
?


-- 
Mit freundlichen Gruessen
Henning Thielemann

Viele Gruesse
Henning

Martin-Luther-Universitaet Halle-Wittenberg, Institut fuer Informatik

Tel. +49 - 345 - 55 24773
Fax  +49 - 345 - 55 27333


More information about the Haskell-Cafe mailing list