> Joe's example work as is. As I think it should. I havn't tried
> with ghc.
It compiles perfectly with ghc. Like Lennart, I don't see why it
shouldn't!
Kevin
Joe writes:
I forgot to mention that I did try it with hbc:
... transcript of working program omitted ...
That's surprising! I'd be interested to know if `maptry' works,
since in that case it makes sense to run the program, as well
as type it. Cheers, -- P
Joe writes:
| Phil Writes:
|
| | The closest one can come is
| |
| |class G a where
| |g :: a -> Bool
| |g x = g [x]
| |
| |instance G Int
| |instance G [Int]
| |instance G [[Int]]
| |...
| |
| |which requires an infini
Tobias Nipkow and Simon Finn were both kind enough to point
out that my Trie example was wrong, in that it is perfectly
typeable in ML (or Haskell).
Tries are like Mark's datatype X. The untypeable version is like
Mark's datatype Y.
data Try a = Atom a | List (Try [a])
mapt
Phil's (Robin Milner's ??) example typechecks in ML.
%Incidentally, there has been a lot of work done on Milner's type
%system extended to allow polymorphic recursion; this system is
%sometimes called ML+. One motivating example -- which I first
%heard from Milner -- is:
%
%
TRANSLATING MONOMORPHISM TO POLYMORPHISM, AND POLYMORPHIC RECURSION
(An addition to Konstantin and Mark's remarks.)
The great thing about Milner's polymorphism is that it came for free:
adding a function declaration does not make a function more efficient.
This is true for the usual implementati
I haven't tried it in Haskell,
but it should either be illegal or cause the type-checker to enter an
infinite loop. (Hmmm! Maybe someone should try it ...)
Yes, after all, everyone knows that a language is defined by its
implementation... (:-)
-Paul
Phil writes:
| Joe writes:
|
| | Phil Writes:
| |
| | | The closest one can come is
| | |
| | |class G a where
| | |g :: a -> Bool
| | |g x = g [x]
| | |
| | |instance G Int
| | |instance G [Int]
| | |instance G [[Int]]
| | |
Phil Writes:
|However, for the extended type system that allows polymorphism in
|recursion, this is no longer the case -- my thanks to Lennart
|Augustsson for pointing this out. The counter-example (similar
|to one of Mark's) is:
|
|g :: a -> Bool
|g x = g [x]
|
|This function
Konstantin Laufer <[EMAIL PROTECTED]> writes:
| Consider the following recursive function binding:
|
| > f [] = 0::Int
| > f (x:xs) = 1 + f([]::[Int]) + f([]::[Bool]) + f xs
|
| This binding is ill-typed since f is used in two different instances
| of its polymorphic-to-be type.
Consider the following recursive function binding:
> f [] = 0::Int
> f (x:xs) = 1 + f([]::[Int]) + f([]::[Bool]) + f xs
This binding is ill-typed since f is used in two different instances
of its polymorphic-to-be type. Indeed, the above declaration is
rejected by hbc, ghc, and g
11 matches
Mail list logo