-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
data Kind = Star ExtClass | Kfun Kind Kind
Kfun f1 a1 == Kfun f2 a2 = f1 == f2 && a1 == a2
Kfun f1 a1 <= Kfun f2 a2 = if f1 <= f2 then
if f2 <= f1 then a1 <= a2
Star _ <= Kfun _ _ = True
Kfun _ _ <= Star _ = False
| Intersection (Set ClassId)
data Variance = CoVar | ContraVar | InVar
data ExtClass = ExtClass Class Variance
star = Star $ ExtClass Universe InVar
type ClassInst = ([Id], [Inst]) -- super classes and instances
-----------------------------------------------------------------------------
type ClassEnv = FiniteMap Id ClassInst
super :: ClassEnv -> Id -> [Id]
super ce i = case lookupFM ce i of Just (is, _) -> is
insts :: ClassEnv -> Id -> [Inst]
insts ce i = case lookupFM ce i of Just (_, its) -> its
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
data Tyvar = Tyvar { typeVarId :: TypeId, typeKind :: Kind } deriving (Eq, Ord)
data Tycon = Tycon TypeId Kind
data Type = TVar Tyvar | TCon Tycon | TAp Type Type | TGen Int
data Qual t = [Pred] :=> t
data Scheme = Scheme [Kind] (Qual Type)
type Assumps = FiniteMap Id [Scheme]
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
data SymbType = OpType Scheme
data Symbol = Symbol {symbId :: Id, sumbType :: SymbType}
-- the list of items which are part of a "sort-gen" (or free type)
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
data GenKind = Free | Generated | Loose deriving (Show,Eq)
data VarDecl = VarDecl { varId :: Id, varType :: Type }
data TypeBody = Alias Type -- non-recursive
| Datatype [Alternative] GenKind GenItems
| SubtypeDefn VarDecl Type Term -- a formula
-- type variables correspond to the kind
data TypeDefn = TypeDefn [Tyvar] TypeBody
-- full function type of constructor (result sort is the data type)
data Alternative = Construct Id Type [Component]
-- full function type of a selector (result sort is component sort)
data Component = Component (Maybe Id) Type
data ClassItem = ClassItem { classId :: Id
, subClasses :: [ClassId]
, superClasses :: [ClassId]
, classDefn :: Maybe Class
data TypeRel = TypeRel [Tyvar] Type Type
data TypeItem = TypeItem{ typeConstrId :: Id
, supertypes :: [TypeRel]
, typeDefn :: Maybe TypeDefn
data OpDefn = OpDef [VarDecl] Term
data BinOpAttr = Assoc | Comm | Idem deriving (Show)
data OpAttr = BinOpAttr BinOpAttr | UnitOpAttr Term
data OpItem = OpItem { opId :: Id
data TypeOp = OfType | AsType | InType deriving (Eq)
data Binder = LambdaTotal | LambdaPartial
data Term = BaseName Id Scheme [Type] -- instance
| Binding Binder [VarDecl] Term
data SigItem = AClassItem ClassItem