-
Notifications
You must be signed in to change notification settings - Fork 3
/
readme.txt
73 lines (52 loc) · 2.53 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
This is a small but complete implementation of the HMF type system
described in the paper "HMF: simple type inference for first-class polymorphism",
available at "http://research.microsoft.com/users/daan/pubs.html"
This implementation uses IO references to implement substitution instead of using
explicit substitutions. Also, it uses ranked unification type variables to implement
efficient generalization.
Just load the prototype in GHCi as:
> ghci Main.hs
and from the GHCi prompt, run the tests:
*Main> testAll
...
or check some expressions yourself:
*Main> check "\\x -> x"
expr: \x -> x
type: forall a. a -> a
*Main> check "auto"
expr: auto
type: forall a. (forall b. b -> b) -> a -> a
*Main> check "apply auto id"
expr: apply auto id
type: forall a. a -> a
*Main> check "map auto ids"
expr: map auto ids
type: forall a. [a -> a]
or get some more help:
*Main> help
...
See the test-cases in "Main.hs" for many more examples,
and "Gamma.hs" for the standard available functions.
There are three provided variants of HMF type inference that can be selected in Main.hs:
InferBasic : Basic HMF type inference
InferRigid : HMF extended with rigid type annotations
InferRigidOpt: Optimized HMF with rigid annotations with a minimal number generalizations.
InferNary : Optimized Rigid HMF with taking all arguments into account for N-ary applications
InferNaryProp: Optimized Rigid N-ary HMF with full type annotation propagation
Have fun,
-- Daan Leijen.
Modules:
--------------------------------------------------------------------------------------------
PPrint.hs Pretty printer library
Types.hs Basic definitions of terms and types
Parser.hs Basic parser for terms and types
Subst.hs Substitutions
Gamma.hs Type environment: also contains standard functions like "const", or "id"
Operations.hs Basic type operations: instantiate, skolemize etc.
Unify.hs Unification and matching algorithm
InferBasic.hs Basic HMF type inference <--- start with this to learn about HMF inference!!
InferRigid.hs HMF type inference extended with rigid type annotations
InferRigidOpt.hs Optimized version with rigid type annotations where generalizations are minimal
InferNary.hs Optimized Rigid HMF taking all arguments into account for N-ary applications
InferNaryProp.hs Optimized Rigid N-ary HMF with full type annotation propagation
Main.hs Main module