Haskell confusion (81)

1 Name: #!usr/bin/anon 2005-11-05 03:09 ID:B+nCC/mJ

I'm trying to learn Haskell (for fun, of course). My only previous experience with the functional programming paradigm was playing around with Scheme a bit. I was nodding my head to "A Gentle Introduction to Haskell" until I got to this, from section 2.2, User-Defined Types:

"Note that the type of the binary data constructor Pt is a -> a -> Point a, ..."

This is from http://www.haskell.org/tutorial/goodies.html

Now, where the heck does this type come from, and what does it mean? Just a paragraph before, we learn that "-> is a type constructor: given two types t and u, t->u is the type of functions mapping elements of type t to elements of type u."

So Pt maps elements of "a -> a" to elements of "Point a"? Or does it map elements of "a" to elements of "a -> Point a"? How does either of these possibilities make any sense? Seems like it maps two elements of type "a" to a single element of type "Point a", no?

I tried the "just ignore and keep reading, hoping it will make sense later" technique, but the next section, 2.2.1, Recursive Types, defines the Branch type in a similarly baffling way. Hopefully, someone more knowledgeable here will be so kind as to clear this up for me.

57 Name: #!/usr/bin/anonymous : 2006-04-04 00:35 ID:jLQEuxPf

OK, so let's talk about this, >>54. You want a better method for partially evaluating functions. Maybe something like f:4=foo for a function that's like f, but it doesn't take the fourth argument of f, and uses foo for that instead. So basically, assuming f takes 5 arguments, it would be shorthand for (\a b c d -> f a b c foo d).

Is that the sort of thing you had in mind? If not, what would be a better way to do it? Are there any languages out there that implement a partial-evaluation method you find satisfactory? (Perl doesn't, to my knowledge, offer anything even as succinct as the lambda version, but my knowledge of Perl is limited.) Could you name some non-contrived situations in which the above sort of syntactic sugar offers significant advantage over currying and the use of combinators like flip?

58 Name: #!/usr/bin/anonymous : 2006-04-04 01:51 ID:/nIL5qky

>>57
maybe something like: f _ _ 42 _ === (\a b c -> f a b 42 c)

This thread has been closed. You cannot post in this thread any longer.