X-Git-Url: http://git.megacz.com/?p=coq-hetmet.git;a=blobdiff_plain;f=src%2FExtraction-prefix.hs;h=f11e63b20d773bf006a9a2273083bb486aa228dd;hp=7e68ba072341384d87442c4192b54f52809c4a3c;hb=6ae1b9b08da7c1d1f0de42afa1ccbf42acda3e62;hpb=2f503f719116c08f11178e46c3aecfa09d974a82 diff --git a/src/Extraction-prefix.hs b/src/Extraction-prefix.hs index 7e68ba0..f11e63b 100644 --- a/src/Extraction-prefix.hs +++ b/src/Extraction-prefix.hs @@ -53,8 +53,10 @@ sortAlts x = Data.List.sortBy (\a b -> if a `CoreSyn.ltAlt` b then Data.Ord.LT e coreVarToWeakVar :: Var.Var -> WeakVar coreVarToWeakVar v | Id.isId v = WExprVar (WeakExprVar v (errOrFail (coreTypeToWeakType (Var.varType v)))) coreVarToWeakVar v | Var.isTyVar v = WTypeVar (WeakTypeVar v (coreKindToKind (Var.varType v))) -coreVarToWeakVar v | Var.isCoVar v = WCoerVar (WeakCoerVar v (Prelude.error "FIXME") - (Prelude.error "FIXME") (Prelude.error "FIXME")) +coreVarToWeakVar v | Var.isCoVar v + = WCoerVar (WeakCoerVar v + (errOrFail (coreTypeToWeakType (Prelude.fst (Coercion.coercionKind (Var.varType v))))) + (errOrFail (coreTypeToWeakType (Prelude.snd (Coercion.coercionKind (Var.varType v)))))) coreVarToWeakVar _ = Prelude.error "Var.Var that is neither an expression variable, type variable, nor coercion variable!" @@ -62,13 +64,21 @@ errOrFail :: OrError t -> t errOrFail (OK x) = x errOrFail (Error s) = Prelude.error s +rawTyFunKind :: TyCon.TyCon -> ( [Kind] , Kind ) +rawTyFunKind tc = ((Prelude.map coreKindToKind (Prelude.take (TyCon.tyConArity tc) argk)) + , + coreKindToKind (Coercion.mkArrowKinds (Prelude.drop (TyCon.tyConArity tc) argk) retk)) + where (argk,retk) = Coercion.splitKindFunTys (TyCon.tyConKind tc) + tyConOrTyFun :: TyCon.TyCon -> Prelude.Either TyCon.TyCon TyCon.TyCon tyConOrTyFun n = if n == TysPrim.statePrimTyCon -- special-purpose hack treat State# as a type family since it has kind *->* but no tyvars then Prelude.Right n else if TyCon.isFamInstTyCon n then Prelude.Right n - else Prelude.Left n + else if TyCon.isSynTyCon n + then Prelude.Right n + else Prelude.Left n nat2int :: Nat -> Prelude.Int nat2int O = 0 @@ -87,8 +97,9 @@ sanitizeForLatex (c:x) = c:(sanitizeForLatex x) kindToCoreKind :: Kind -> TypeRep.Kind kindToCoreKind KindStar = TypeRep.liftedTypeKind kindToCoreKind (KindArrow k1 k2) = Coercion.mkArrowKind (kindToCoreKind k1) (kindToCoreKind k2) -kindToCoreKind _ = Prelude.error "kindToCoreKind does not know how to handle that" - +kindToCoreKind k = Prelude.error ((Prelude.++) + "kindToCoreKind does not know how to handle kind " + (kindToString k)) coreKindToKind :: TypeRep.Kind -> Kind coreKindToKind k = case Coercion.splitKindFunTy_maybe k of