2 /* --------------------------------------------------------------------------
3 * Definitions for substitution data structure and operations.
5 * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
6 * Yale Haskell Group, and the Oregon Graduate Institute of Science and
7 * Technology, 1994-1999, All rights reserved. It is distributed as
8 * free software under the license in the file "License", which is
9 * included in the distribution.
11 * $RCSfile: subst.h,v $
13 * $Date: 1999/11/17 16:57:50 $
14 * ------------------------------------------------------------------------*/
16 typedef struct { /* Each type variable contains: */
17 Type bound; /* A type skeleton (unbound==NIL) */
18 Int offs; /* Offset for skeleton */
19 Kind kind; /* kind annotation */
22 #if FIXED_SUBST /* storage for type variables */
23 extern Tyvar tyvars[];
25 extern Tyvar *tyvars; /* storage for type variables */
27 extern Int typeOff; /* offset of result type */
28 extern Type typeIs; /* skeleton of result type */
29 extern Int typeFree; /* freedom in instantiated type */
30 extern List predsAre; /* list of predicates in type */
31 extern List genericVars; /* list of generic vars */
32 extern List btyvars; /* explicitly scoped type vars */
34 #define tyvar(n) (tyvars+(n)) /* nth type variable */
35 #define tyvNum(t) ((t)-tyvars) /* and the corresp. inverse funct. */
36 #define isBound(t) (((t)->bound) && ((t)->bound!=SKOLEM))
37 #define aVar mkOffset(0) /* Simple skeletons for type vars */
38 #define bVar mkOffset(1)
39 #define enterBtyvs() btyvars = cons(NIL,btyvars)
40 #define leaveBtyvs() btyvars = tl(btyvars)
42 #define deRef(tyv,t,o) while ((tyv=getTypeVar(t,o)) && isBound(tyv)) { \
47 /* offs values when isNull(bound): */
48 #define FIXED_TYVAR 0 /* fixed in current assumption */
49 #define UNUSED_GENERIC 1 /* not fixed, not yet encountered */
50 #define GENERIC 2 /* GENERIC+n==nth generic var found*/
52 extern char *unifyFails; /* Unification error message */
54 extern Void emptySubstitution Args((Void));
55 extern Int newTyvars Args((Int));
56 #define newKindvars(n) newTyvars(n)
57 extern Int newKindedVars Args((Kind));
58 extern Void instantiate Args((Type));
60 extern Pair findBtyvs Args((Text));
61 extern Void markBtyvs Args((Void));
62 extern Type localizeBtyvs Args((Type));
64 extern Tyvar *getTypeVar Args((Type,Int));
65 extern Void tyvarType Args((Int));
66 extern Void bindTv Args((Int,Type,Int));
67 extern Cell getDerefHead Args((Type,Int));
68 extern Void expandSyn Args((Tycon, Int, Type *, Int *));
70 extern Void clearMarks Args((Void));
71 extern Void markAllVars Args((Void));
72 extern Void resetGenerics Args((Void));
73 extern Void markTyvar Args((Int));
74 extern Void markType Args((Type,Int));
75 extern Void markPred Args((Cell));
77 extern Type copyTyvar Args((Int));
78 extern Type copyType Args((Type,Int));
79 extern Cell copyPred Args((Cell,Int));
80 extern Type dropRank2 Args((Type,Int,Int));
81 extern Type dropRank1 Args((Type,Int,Int));
82 extern Void liftRank2Args Args((List,Int,Int));
83 extern Type liftRank2 Args((Type,Int,Int));
84 extern Type liftRank1 Args((Type,Int,Int));
86 extern Type debugTyvar Args((Int));
87 extern Type debugType Args((Type,Int));
89 extern Kind copyKindvar Args((Int));
90 extern Kind copyKind Args((Kind,Int));
92 extern Bool eqKind Args((Kind,Kind));
93 extern Kind getKind Args((Cell,Int));
95 extern List genvarTyvar Args((Int,List));
96 extern List genvarType Args((Type,Int,List));
98 extern Bool doesntOccurIn Args((Tyvar*,Type,Int));
99 extern Bool unify Args((Type,Int,Type,Int));
100 extern Bool kunify Args((Kind,Int,Kind,Int));
102 extern Void typeTuple Args((Cell));
103 extern Kind simpleKind Args((Int));
104 extern Void varKind Args((Int));
106 extern Bool samePred Args((Cell,Int,Cell,Int));
107 extern Bool matchPred Args((Cell,Int,Cell,Int));
108 extern Bool unifyPred Args((Cell,Int,Cell,Int));
109 extern Inst findInstFor Args((Cell,Int));
111 extern Void improve Args((Int,List,List));
112 extern Void improve1 Args((Int,List,Cell,Int));
114 extern Bool sameSchemes Args((Type,Type));
115 extern Bool sameType Args((Type,Int,Type,Int));
116 extern Bool matchType Args((Type,Int,Type,Int));
118 /*-------------------------------------------------------------------------*/