1 Mar 2004 12:33
RE: Per-type function namespaces (was: Data.Set whishes)
Simon Peyton-Jones <simonpj <at> microsoft.com>
2004-03-01 11:33:07 GMT
2004-03-01 11:33:07 GMT
| > In Haskell today, you can at least tell what value is bound to each | > identifier in the program, *without* first doing type checking. | | I'm afraid I'm confused. In the following code | | > data Z | > data S a | > | > class Card c where c2int:: c -> Int | > | > instance Card Z where c2int _ = 0 | > instance (Card c) => Card (S c) where c2int _ = 1 + c2int (undefined::c) | > | > foo = c2int (undefined::(S (S (S (S Z))))) | | how can one tell the value of foo without first doing the | typechecking? What I meant was that you can always tell what executable code a value is bound to, without type checking. 'foo' is bound to the code for 'c2int (undefined::(S (S (S (S Z)))))'. 'c2int' is bound to code that extracts a method from it's first argument (which is a dictionary for Card). In any higher-order language, a function might invoke one of its arguments f x g = g x but I still say that it's clear what code is executed when f is called!(Continue reading)
RSS Feed