Now that is a *really* amazing example. I had no
idea that polymorphic recursion would do this.
I withdraw my claim that a type signature can't change the answer.
But I'm worried.
Simon
| -----Original Message-----
| From: Lennart Augustsson [mailto:[EMAIL PROTECTED]]
| Sent: 03 May 2001 15:24
| To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
| Cc: [EMAIL PROTECTED]
| Subject: Re: Implict parameters and monomorphism
|
|
| OK, so since noone liked my original example here's another
| one. It involves no defaulting and no classes in the funny
| function definition.
|
| -- Here's the type signature that makes a difference.
| --fun :: a -> Char
| fun x = const (fun x) (fun True)
|
| fix f = let x = f x in x
|
| class C a where
| m :: a -> String
|
| instance C Char where
| m _ = "has signature"
|
| instance C Bool where
| m _ = "no signature"
|
| main = putStrLn (m (fix fun))
|
|
| It is not at all surprising that you can write this.
| Originally type signatures only allowed you to put a
| signature that was
| more specific.
| Polymorhic recursion on the other hand allows you to make the
| type more general by putting a type signature on a
| definition. Combining these you can make the signature be
| incomparable to the deduced type. Using the class system you
| can then dispatch on the type and get different behaviour.
|
| -- Lennart
|
| _______________________________________________
| Haskell mailing list
| [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
|
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell