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

Typo

1993-07-28 Thread norman
In the Report 1.2 on page 98, in the definition of rationalToRealFloat, the line beginning "where y" has unbalanced parentheses. -Norman --- Messing about with signature files fills a much-needed gap in the working day.

Prefix negation

1993-07-28 Thread norman
I'm puzzled by a detail in the Report, which seems to contradict itself. On page 13 it says: The special form -e denotes prefix negation, [...] and is simply syntax for negate (e), where negate is as defined in the standard prelude. The standard prelude defines negate a

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: Prefix negation

1993-07-28 Thread Joe Fasel
| From: [EMAIL PROTECTED] | | I'm puzzled by a detail in the Report, which seems to contradict itself. | | On page 13 it says: | | The special form -e denotes prefix negation, [...] and is simply | syntax for negate (e), where negate is as defined in the standard | prelude

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