X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2FHaskWeakVars.v;h=44e267d0ab21bc49d2cfb98e735ef686a486f24b;hb=f49db0fc38c6c430585e4e48304510212c3f1a0f;hp=782c2a2c8cbf5708b8e82c9abd61552dc5264908;hpb=bcb16a7fa1ff772f12807c4587609fd756b7762e;p=coq-hetmet.git diff --git a/src/HaskWeakVars.v b/src/HaskWeakVars.v index 782c2a2..44e267d 100644 --- a/src/HaskWeakVars.v +++ b/src/HaskWeakVars.v @@ -13,12 +13,6 @@ Require Import HaskCoreVars. Require Import HaskCoreTypes. Require Import HaskWeakTypes. -(* TO DO: finish this *) -Inductive WeakCoercion : Type := weakCoercion : WeakType -> WeakType -> CoreCoercion -> WeakCoercion. - -(* a WeakCoerVar just wraps a CoreVar and tags it with the pair of types amongst which it coerces *) -Inductive WeakCoerVar := weakCoerVar : CoreVar -> WeakType -> WeakType -> WeakCoerVar. - (* a WeakExprVar just wraps a CoreVar and tags it with the type of its value *) Inductive WeakExprVar := weakExprVar : CoreVar -> WeakType -> WeakExprVar. @@ -37,9 +31,9 @@ Definition weakTypeVarToKind (tv:WeakTypeVar) : Kind := Definition weakVarToCoreVar (wv:WeakVar) : CoreVar := match wv with - | WExprVar (weakExprVar v _ ) => v - | WTypeVar (weakTypeVar v _ ) => v - | WCoerVar (weakCoerVar v _ _ ) => v + | WExprVar (weakExprVar v _ ) => v + | WTypeVar (weakTypeVar v _ ) => v + | WCoerVar (weakCoerVar v _ _ _) => v end. Coercion weakVarToCoreVar : WeakVar >-> CoreVar. @@ -47,6 +41,20 @@ Definition haskLiteralToWeakType lit : WeakType := WTyCon (haskLiteralToTyCon lit). Coercion haskLiteralToWeakType : HaskLiteral >-> WeakType. +Variable coreVarToWeakVar : CoreVar -> WeakVar. Extract Inlined Constant coreVarToWeakVar => "coreVarToWeakVar". +Variable getTyConTyVars_ : CoreTyCon -> list CoreVar. Extract Inlined Constant getTyConTyVars_ => "getTyConTyVars". +Definition tyConTyVars (tc:CoreTyCon) := + General.filter (map (fun x => match coreVarToWeakVar x with WTypeVar v => Some v | _ => None end) (getTyConTyVars_ tc)). + Opaque tyConTyVars. +Definition tyConKind (tc:TyCon) : list Kind := + map (fun (x:WeakTypeVar) => x:Kind) (tyConTyVars tc). + +Variable rawTyFunKind : CoreTyCon -> Kind. Extract Inlined Constant rawTyFunKind => "(coreKindToKind . TyCon.tyConKind)". + +Definition tyFunKind (tc:TyFun) : ((list Kind) * Kind) := + splitKind (rawTyFunKind tc). + +(* (* EqDecidable instances for all of the above *) Instance WeakCoerVarEqDecidable : EqDecidable WeakCoerVar. apply Build_EqDecidable. @@ -85,3 +93,7 @@ Instance WeakVarEqDecidable : EqDecidable WeakVar. left; auto. right; intro X; apply n; inversion X; auto. Defined. +*) + +Instance WeakVarToString : ToString WeakVar := + { toString := fun x => toString (weakVarToCoreVar x) }. \ No newline at end of file