290 likes | 476 Views
Typed AG. Alexey Rodriquez Y Faridah Liduan Type Systems Project 26 Jun 2003. Introduction. Goals. Produce a well-typed AG file Detect type errors of semantic functions early in the AG stage Do type checking and type inferencing using: AG type annotations
E N D
Typed AG Alexey Rodriquez Y Faridah Liduan Type Systems Project 26 Jun 2003
Goals • Produce a well-typed AG file • Detect type errors of semantic functions early in the AG stage • Do type checking and type inferencing using: • AG type annotations • Types of haskell source fragment • Local attributes definitions
Why Typed AG? • Well typed AG => well typed haskell program • Typed errors are given in terms of the AG source
Embedding AG to UHC (Attribute Haskell) • Advantages: • Haskell is extended with attribute grammar • Make use features of haskell interpreter and haskell compiler • AG will have a module system if it is properly done • Disadvantages: • Utterly Complex • Proper language design vs gluing
Embedding UHC to AG (Typed AG) • Advantages: • Easier to implement • Disadvantages: • Still a two-step process • Improvements in the UHC do not apply to Typed AG
Our Choice • Implement Typed AG
Implementation Options • Simple Dependency Analysis Type inference over local variables in the order determined by the analysis • Constraint: no cycles (cycle = incorrect result) • Use bindgroup • Put all local attributes in a bindgroup and do type inferencing. • Disadvantages: no polymorphic local attributes
Implementation Options (cont~) • Use HC Constructors Use semantic functions to type check local, synthesized, and inherited attributes. • Disadvantages: Error messages are not given in terms of original AG source.
AG + UHC • UHC copied to the AG repository. • Slight modification of existing Makefiles.
Current State of Affairs • Our implementation can detect type errors in the embedded Haskell source fragments. • It can also detect type errors related to misuse of semantic functions. • Type errors are also detected in the RHS of the attribute rules.
Missing features from UHC and our implementation • Type synonyms are not supported. • Types are not parsed. • Omission of local attributes (& patterns). • Typing of attribute expressions as a whole.
Final Remarks • Typed AG guarantees well-typedness of generated Haskell source file. • A really useful implementation of Typed AG will need modules and full Haskell.