[Haskell-cafe] Lifting makes lazy

Mike Gunter m at ryangunter.com
Thu Sep 16 13:09:57 EDT 2004


This should *not* display anything.  Look at the types!  displayFile1
returns a value that is the "displaying action".  It does not "run"
it.

Replace "liftM" with "(=<<)" or use "join displayFile1" if you want to
run the displaying action.

	mike

>> displayFile1 :: IO (IO ())
>> displayFile1 =  liftM putStr contents -- Displays nothing
>>     where
>>       contents :: IO [Char]
>>       contents = readFile "DisplayFile.lhs"
>
> This should display the contents of a file, but nothing appears.


More information about the Haskell-Cafe mailing list