Skip to main content
GameDev.net gamedev.net
🔒 Locked

Haskell Newbie Question

Started by laeuchli Mar 5, 2009 at 6:12 PM 0 replies 950+ views
Original Post
laeuchli
laeuchli
Dear All, I've been reading a few online texts on haskell recently, and theres one aspect of the synatx I'm a little confused on, the arrow syntax. I was hoping the knowledgeable here could help me out. Look at the page here(http://www.haskell.org/arrows/index.html). The first example is: (b -> c) -> a b c As far as I understand it, this means that the function arr takes a type b, then produces a type c, then from this type c produces a tuple with type a b c. Is this correct? Onward to the next example, they have (>>>) :: a b c -> a c d -> a b d Now as I understand it, this function >>> takes three variables of type a b c, and after two computations ends up with a tuple of type a b d. However in Haskell dont all functions take only one parameter? Does this mean what happens is as below: (a-> (b->c) ) -> (a -> (c -> d)) - > a b d If not, whats the correct way in which the types are transformed? Finally they have first :: a b c -> a (b,d) (c,d) I'm quite confused by this one. Is it: (a -> ( b - > c) ) -> a (a -> (b -> d) ) (a -> ( b -> c) -> d) ? Thanks for the help. Jesse
Daerax
Daerax
At first I thought you would be talking about curried functions. But on viewing the link those arrows are... Arrows - a kind of generalizations of monads. Arrows are not part of Haskell syntax, they are external and part of a library, kinda like List<> in C#.

If you are beginning Haskell then that tutorial is overkill (for example you are mixing type constructor polymorphism with tuples). Start with learning the difference between tupled functions and curried functions and the notion of Partial Application.

Check out 'Yet Another Haskell Tutorial' on google.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.