Re: Inferring from context declarations
Simon Peyton Jones' comments about dictionary passing are a red herring, since they assume a particular form of compiler. Various (MLj, MLton) ML compilers already inline out all polymorphism. ML is a language where you can do this. In Haskell it is not always possible to eliminate all polymorphism (due to polymorphic recursion).
-- Lennart
Lennart Augustsson writes:
Simon Peyton Jones' comments about dictionary passing are a red herring, since they assume a particular form of compiler. Various (MLj, MLton) ML compilers already inline out all polymorphism. ML is a language where you can do this. In Haskell it is not always possible to eliminate all polymorphism (due to polymorphic recursion).
I'd like to see an example of this! --Thomas
Thomas Johnsson wrote:
Lennart Augustsson writes:
Simon Peyton Jones' comments about dictionary passing are a red herring, since they assume a particular form of compiler. Various (MLj, MLton) ML compilers already inline out all polymorphism. ML is a language where you can do this. In Haskell it is not always possible to eliminate all polymorphism (due to polymorphic recursion).
I'd like to see an example of this!
Sure, here's one where you can't bound the number of dictionaries: main = interact $ show . f 'a' . read f :: (Eq a) => a -> Integer -> Bool f x 0 = x == x f x n = f [x] (n-1) If the input is 0 the comparison is of Char, if the input is 1 the comparison is of [Char], if the input is 2 the comparison is of [[Char]], etc. Incidentally, this has nothing to do with allowing polymorphic recursion on functions in Haskell. It could be done earlier too, but then it had to be encoded using a class and instance declaration. -- Lennart
Lennart Augustsson wrote:
Incidentally, this has nothing to do with allowing polymorphic recursion on functions in Haskell. It could be done earlier too, but then it had to be encoded using a class and instance declaration.
I would argue that methods are in fact polymorphically recursive functions. Wasn't this one motivation to allow general polymorphic recursion in Haskell - that it is in the language anyway? - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids. If Pac Man affected us as kids, we would all be running around in darkened rooms, munching pills, and listening to repetitive music."
participants (4)
-
Andreas Rossberg -
Lennart Augustsson -
Lennart Augustsson -
Thomas Johnsson