Re: Polymorphic recursive calls possible via type classes

1993-07-29 Thread kh
> 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

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread wadler
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

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread wadler
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

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread wadler
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

Polymorphic recursive calls possible via type classes

1993-07-28 Thread smk
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: % %

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread wadler
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

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread hudak-paul
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

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread Joe Fasel
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]] | | |

Re: Polymorphic recursive calls possible via type classes

1993-07-28 Thread Joe Fasel
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

Re: Polymorphic recursive calls possible via type classes

1993-07-27 Thread jones-mark
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.

Polymorphic recursive calls possible via type classes

1993-07-27 Thread Konstantin Laufer
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