[Haskell-beginners] lazy IO in readFile

Andrew Sackville-West andrew at swclan.homelinux.org
Sat Jun 5 17:12:26 EDT 2010

On Wed, Jun 02, 2010 at 06:40:15PM +0200, Chaddaï Fouché wrote:
> 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).

very insightful observation. I do indeed do it, but not conciously as
would be the case in a language with Scheme. 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20100607/c4f8149b/attachment.bin

More information about the Beginners mailing list