X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2FHaskWeakToCore.v;h=b6add9448794403c5c9de6c77baff31dfdd1447c;hb=b0303799b3deddd7a19b29be7852f6dafaf04325;hp=cb3d7a393298865041f7bb9ecfaa67f8d9524bf1;hpb=ee5aaad57d76400e9b8736d4a12d2804f99f329c;p=coq-hetmet.git diff --git a/src/HaskWeakToCore.v b/src/HaskWeakToCore.v index cb3d7a3..b6add94 100644 --- a/src/HaskWeakToCore.v +++ b/src/HaskWeakToCore.v @@ -21,21 +21,20 @@ Variable mkCoreLet : @CoreBind CoreVar -> @CoreExpr CoreVar -> @CoreExpr CoreVar Extract Inlined Constant mkCoreLet => "MkCore.mkCoreLet". Variable sortAlts : forall {a}{b}, list (@triple AltCon a b) -> list (@triple AltCon a b). - Extract Inlined Constant mkCoreLet => "sortAlts". + Extract Inlined Constant sortAlts => "sortAlts". Implicit Arguments sortAlts [[a][b]]. -Variable trustMeCoercion : CoreCoercion. - Extract Inlined Constant trustMeCoercion => "Coercion.unsafeCoerce". +Variable mkUnsafeCoercion : CoreType -> CoreType -> CoreCoercion. + Extract Inlined Constant mkUnsafeCoercion => "Coercion.mkUnsafeCoercion". (* Coercion and Type are actually the same thing in GHC, but we don't tell Coq about that. This lets us get around it. *) Variable coreCoercionsAreReallyTypes : CoreCoercion -> CoreType. Extract Inlined Constant coreCoercionsAreReallyTypes => "(\x -> x)". -Definition weakCoercionToCoreCoercion : WeakCoercion -> CoreCoercion := - fun _ => trustMeCoercion. +Definition weakCoercionToCoreCoercion (wc:WeakCoercion) : CoreCoercion := + mkUnsafeCoercion (weakTypeToCoreType (fst (weakCoercionTypes wc))) (weakTypeToCoreType (snd (weakCoercionTypes wc))). - - Fixpoint weakExprToCoreExpr (me:WeakExpr) : @CoreExpr CoreVar := +Fixpoint weakExprToCoreExpr (me:WeakExpr) : @CoreExpr CoreVar := match me with | WEVar (weakExprVar v _) => CoreEVar v | WELit lit => CoreELit lit @@ -88,6 +87,9 @@ Definition weakCoercionToCoreCoercion : WeakCoercion -> CoreCoercion := (weakExprToCoreExpr e) end. +Definition weakTypeOfWeakExpr (we:WeakExpr) : ???WeakType := + coreTypeToWeakType (coreTypeOfCoreExpr (weakExprToCoreExpr we)). - +Instance weakExprToString : ToString WeakExpr := + { toString := fun we => toString (weakExprToCoreExpr we) }.