
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
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?
getIsNewItemPredicate :: stuff -> (String -> Bool) but in normal Haskell, you wouldn't write this last pair of
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
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 : parenthesis (since they're implicit) : 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. A