[Fwd: Harper on parse-time type checking for ML]
dvanhorn <[email protected]>
| Newsgroups | gmane.org.ballistichelmet.lambda |
|---|---|
| Message-ID | <[email protected]> |
FWIW, PLT Scheme takes the Haskell approach with token directed fixity: (1 . < . 2) <=> (< 1 2) +1 Scheme -1 ML David -------- Original Message -------- Subject: Harper on parse-time type checking for ML Date: Thu, 4 Mar 2004 15:36:24 -0500 From: Christian Skalka <skalka-UYko1UTVIqz2fBVCVOL8/[email protected]> To: <cs303s04-UYko1UTVIqz2fBVCVOL8/[email protected]> Dear CS303 class members, As promised, here are Bob Harper's comments on why parse-time type inference/checking can't be done in Standard ML. Enjoy. -chris ----------------- > From: Christian Skalka [mailto:skalka-UYko1UTVIqz2fBVCVOL8/[email protected]] > Sent: Monday, February 10, 2003 2:49 PM > To: Robert Harper > Subject: Re: ML type implementation > > Quick question: in SML97, is type inference done at parse time, > or is it done as a separate pass, post-parsing, on the abstract syntax > trees (I am unaware of any features that would preclude the latter > approach)? After parsing. In fact you can't even finish parsing until you type check! This is because of the bizarre "infix" declaration, which has to be processed during elaboration (type checking), but affects parsing. Ugh. The solution is to do a rough parse, then type check, then re-parse. It's a mess. ... The idea of a "declaration" of fixity is broken, in any form. The reason is that it's not a declaration. It's a mutation of the state of the parser telling it how to treat certain tokens. It is not a declaration of a variable, nor does it have anything to do with the variable/function name itself, only to do with how certain tokens are parsed. The Haskell approach is best: `op` for a left-associative infix, 'op' for a right-associative infix. It's inherent in the token that it's infix and with what associativity. Bob -----Original Message----- From: Christian Skalka [mailto:skalka-UYko1UTVIqz2fBVCVOL8/[email protected]] Sent: Monday, February 10, 2003 2:21 PM To: [email protected] Subject: ML type implementation ========================= ========================== Christian Skalka Department of Computer Science University of Vermont http://www.cs.uvm.edu/~skalka ==========================