[Haskell-cafe] Need feedback on my Haskell code

Chaddaï Fouché chaddai.fouche at gmail.com
Fri Jul 31 08:25:00 EDT 2009

On Fri, Jul 31, 2009 at 2:12 PM, CK Kashyap<ck_kashyap at yahoo.com> wrote:
> 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?

There may be small differences in the result after optimisation but
you shouldn't worry about that right now (if you really want to
optimise this function, the first thing to do is to change your data
structure for points : a strict pair of int (data Point = P !Int !Int)
could easily go more than 5 times faster, I tried).

I tend to always use this "map maySwitch . unfoldr go $ (x1,y1,0)"
style since I like to see things in terms of functions compositions
and it is easier to refactor this kind of code with copy and paste
(not really relevant here but for longer chains it's interesting).


More information about the Haskell-Cafe mailing list