Re: [Haskell-cafe] Adding type annotations to an AST?
Hi Stephen, On Mon, Mar 5, 2012 at 08:52, Stephen Tetley wrote: How do I add type annotations to interior locations in an abstract syntax tree? I use an annotated expression tree in my work. The nodes of the AST are annotated with the type, assumption set, and constraint set as described in constraint-based type inference [1]. We have a paper describing our type-and-transform system [2] and a link in the paper points to the code. Let me know if you have any questions. Regards, Sean [1] http://www.staff.science.uu.nl/~heere112/phdthesis/index.html [2] http://www.cs.uu.nl/research/techreps/UU-CS-2012-004.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding type annotations to an AST?
Hi Sean Many thanks - the note on flow-issues might be particularly helpful for me (last para section 4 introduction). My current code has a bug which maybe this identifies. I'm currently using a modified algorithm M which I believe is top down, I'll switch to algorithm W. Thanks again Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding type annotations to an AST?
Hi Oleg - many thanks On 6 March 2012 07:15, o...@okmij.org wrote: How do I add type annotations to interior locations in an abstract syntax tree? {Snip} Here is the solution http://okmij.org/ftp/Computation/FLOLAC/TEvalNR.hs There is a bit of the explanation here: http://okmij.org/ftp/Computation/FLOLAC/lecture.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding type annotations to an AST?
Partially answering my own question - it seems like I want type directed translation as per section 8 of Practical Type Inference for Arbitrary Ranked Types. Does anyone know of a presentation with a simpler type language? Thanks again Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding type annotations to an AST?
How do I add type annotations to interior locations in an abstract syntax tree? i.e. the type it [algorithm] infers is the type of the whole program, I would also like the types of any internal let-rec definitions so I can label my AST. I had exactly the same problem: type reconstruction and the annotation of all sub-terms with their inferred types. Even if the overall type inference fails, the user can still see what the type checker was able to infer before the error. Here is the solution http://okmij.org/ftp/Computation/FLOLAC/TEvalNR.hs There is a bit of the explanation here: http://okmij.org/ftp/Computation/FLOLAC/lecture.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Adding type annotations to an AST?
Hello All How do I add type annotations to interior locations in an abstract syntax tree? I have a small ML language where programs are a single expression, but the expression type has let-rec so it supports recursive function definitions. Source programs have no type annotations. I want to annotate the lec-rec with type annotations, but my type inference is a simple implementation of Algorithm J so it seems monolithic to me - i.e. the type it infers is the type of the whole program, I would also like the types of any internal let-rec definitions so I can label my AST. What is the idiom for accomplishing this? I'm using Eijiro Sumii's MinCaml as reference - this embeds mutable references for types in the AST. So this appears a non-starter. My other thought is to uniquely label all type locations during parsing then collect them in a map (location - type) whilst computing the outermost type - I presume I can identify inner types as they are resolved during Algorithm J's run... Any solutions? Many thanks Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe