Download presentation
Presentation is loading. Please wait.
1
Typed AG Alexey Rodriquez Y Faridah Liduan Type Systems Project 26 Jun 2003
2
Introduction
3
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
4
Why Typed AG? Well typed AG => well typed haskell program Typed errors are given in terms of the AG source
5
AG Type Errors in Terms of Haskell Source
6
How to Merge AG and UHC
7
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
8
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
9
Our Choice Implement Typed AG
10
Typing Semantic Functions
11
AG Data and Semantic Function Definition
12
AG Generated Semantic Function
13
How to Type Check Semantic Functions
14
How to Type Check Semantic Functions (cont~)
15
Simple Subset (no local attributes)
16
Implementation of Typed AG
17
AG Example
18
AG Data Flow Diagram
19
Implementation Choice
20
Other implementation choice?
21
Type Inference of Local Attributes
22
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
23
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.
24
Implementation Issues
25
AG + UHC UHC copied to the AG repository. Slight modification of existing Makefiles.
26
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.
27
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.
28
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.
29
Q & A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.