It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this?
There's no definition, it's a parameter to the constructor, so the function can be anything. Taking a much simpler example, you'll be familiar with, if you do: data Foo a = Foo a then the first argument to the Foo constructor also doesn't have a definition. But when you use it to construct a value, then you provide one: myFoo = Foo 3 Likewise, when you construct an Ord value, you supply a function as the value for the 'less' parameter: numOrd = Ord { less = (<) } or you could use a different function for a different purpose: listLengthOrd = Ord { less = \ a b => length a < length b } Hope that helps, Peter On 20 February 2013 21:18, Emanuel Koczwara <poczta@emanuelkoczwara.pl>wrote:
Hi,
I'm watching Philip Wadler "Faith, Evolution, and Programming Languages" (very cool by the way): http://www.youtube.com/watch?v=8frGknO8rIg
At 00:24:14 there is strange thing on the slide:
data Ord a = { less :: a -> a -> Bool }
It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this?
Emanuel
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners