PDA

View Full Version : Newbie first steps with Haskell on steroids.



jorgedbucaran
01-26-2008, 03:16 PM
Hello,

I am newbie on functional programming (hear that often?) and I am loving it, no kidding I even started my own blog (http://jorgebucaran.wordpress.com) to trace my development. But of course I am not here to tell you that, actually is pretty useless at this point.

I am helping a friend to understand some Haskell code, so that's the story on how I started with Haskell. It's been over a week and so far I have barely grasp the basics. It is indeed a complex language, I am honored just to have the opportunity to talk to any of you who know what is going on.

Basically, I need to understand some code. The following is just a piece of it. The definition of mapReduce (yes as in Google's mapReduce, that is my friend's work and I went all the way positive on rescuing him without paying attention to difficulties, am I crazy?) Anyway, I am posting here the header with the module and import part, and the definition of the function. Note that this function call others wich I am not posting here just to make this post easy enough. After all I have to solve this out, hopefully you can help me get started by tipping me.

module MapReduce.Basic ( mapReduce ) where

import Data.Map (Map,empty,insertWith,mapWithKey,filterWithKey,toList)

mapReduce .: forall k1 k2 v1 v2 v3.
Ord k2
=> (k1 -> v1 -> [(k2,v2)])
-> (k2 -> [v2]) -> Maybe v3)
-> Map k1 v1
-> Map k2 v3

mapReduce mAP rEDUCE =
reducePerKey
. groupByKey
. mapPerKey

For example, I can't decipher the mapReduce:: ... (type,arguments,return parameters) It is just too complex, any help here?

Also how do I use the . operator, I mean how does it make sense in this context? And can you explain the header with module and import? What is the difference? what is it? And finally, what is the use of Where?

Thanks and sorry for the newbieness. :)

Fixed URL.