
On Wed, May 30, 2007 at 11:21:45PM +0200, Roberto Zunino wrote:
Tomasz Zielonka wrote:
In the Ord variant, the result value pretty much has to come from the input list or be bottom. It has to be bottom for the empty list. If f :: Ord a => [a] -> a and g preserves order (is monotonic) then f (map g l) == g (f l) This could be nice for testing Ord instances. Unfortunately, for bounded types the only order preserving function is id.
Interesting... are the following g allowed? (I am relatively new to parametericity results.)
And I am only using my intuition, not a deep knowledge of such results :-)
(\!x -> (x,4)) -- bounded types (?)
Ah, right! I unneccesarily restricted g's type to be (compatible with) t -> t.
($!) Data.List.repeat -- ;-) unbounded types
You got me - I'm not sure how to respond to that. Let's try: this function doesn't preserve computable equality. I probably should require that at the beginning. BTW, why so many exclamation marks in your code? Are they essential? Best regards Tomek