[Haskell-cafe] Need feedback on my Haskell code
ck_kashyap at yahoo.com
Fri Jul 31 08:12:32 EDT 2009
I personally find
map maySwitch (unfoldr go (x1,y1,0)) and map maySwitch $ unfoldr go (x1,y1,0) more intuitive.
I can read it as map the maySwitch function over the list generated from the unfolding.
Is there any difference in the evaluation steps between the composition version and the non-composition version?
From: david48 <dav.vire+haskell at gmail.com>
To: Ryan Ingram <ryani.spam at gmail.com>
Cc: Johan Tibell <johan.tibell at gmail.com>; haskell-cafe at haskell.org; CK Kashyap <ck_kashyap at yahoo.com>
Sent: Friday, July 31, 2009 11:56:17 AM
Subject: Re: [Haskell-cafe] Need feedback on my Haskell code
On Fri, Jul 31, 2009 at 5:53 AM, Ryan Ingram<ryani.spam at gmail.com> wrote:
> Read ($) as a parenthesis that extends as far to the right as
> possible; so you can write, for example:
That doesn't always work, for example :
map (+2) . map (*1) $ [1,2,3]
Now replacing the $ by a parenthesis that extends as far to the right
as possible :
map (+2) . map (*1) ( [1,2,3] )
Couldn't match expected type `a -> [a1]'
against inferred type `[a2]'
In the second argument of `(.)', namely `map (* 2) ([1, 2, 3])'
In the expression: map (+ 2) . map (* 2) ([1, 2, 3])
In the definition of `it': it = map (+ 2) . map (* 2) ([1, 2, 3])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe