[Haskell-beginners] lazy IO in readFile

Chaddaï Fouché chaddai.fouche at gmail.com
Wed Jun 2 12:40:15 EDT 2010

On Thu, May 20, 2010 at 3:17 AM, Andrew Sackville-West
<andrew at swclan.homelinux.org> wrote:
> thanks for this. it helps a lot. hmmm... I wonder why it is I never
> have a problem returning functions in Scheme, but it never occurs to
> me as I learn Haskell?

Maybe you're already doing it without realizing it ? For instance for
the same kind of problem but without the IO part, the type of the
function could be :
> getIsNewItemPredicate :: stuff -> (String -> Bool)
but in normal Haskell, you wouldn't write this last pair of
parenthesis (since they're implicit) :
> getIsNewItemPredicate :: stuff -> String -> Bool
And so it is pretty likely that you would write this function just as
if it had two parameters :
> getIsNewItemPredicate stuff str = .... str `isMember` set
And later on use the fact that the function is curried to get a
predicate on String :
> let isNewItem = getIsNewItemPredicate someStuff

In this case, you're "returning" a function but it may not be as
obvious as in Scheme (where curryfication is not an idiom encouraged
by the language).


More information about the Beginners mailing list