[Haskell-begin] Exercises for beginners and Natural Tansformations

Federico Brubacher fbrubacher at gmail.com
Sat Jul 19 09:00:12 EDT 2008


Hi all,
I think i will love this list :)

Yesterday I was looking at this Haskell Exercises for beginners [1] and got
somewhat stuck at Ex nbr 2 , here's why:
The idea of this exercises is that you don't use built in Haskell Lists, so
no pattern matching, instead you have to use the data type list provided in
the source of the exercise.

My friend who is more advanced in Haskell said this approach is good because
you get to learn natural Transformations. So I googled that and I came up
with this [2]. I can read al little bit of category theory but I would love
to know how to apply [2] in the sum exercise.

Anyway as we all know summing all the elements in a list using Haskell lists
is trivial :

sum :: [Int] -> Int
sum (xs) = foldr(+)0xs

But how to do it with Natural transformations ???

Thanks a lot

Federico

[1] http://blog.tmorris.net/haskell-exercises-for-beginners/

-- 
Federico Brubacher
www.fbrubacher.com

Colonial Duty Free Shop
www.colonial.com.uy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080719/668e9e08/attachment.htm


More information about the Beginners mailing list