X-Git-Url: http://git.megacz.com/?p=coq-hetmet.git;a=blobdiff_plain;f=src%2FExtraction-prefix.hs;h=0775229ddcebba6900626f7480da5dfbdec05e3d;hp=fbe22cb074eb5d340efd28a5d282c999f991d858;hb=794719aadd55d760c0514f45c23b9cb450d92d9f;hpb=ddac2a6a7301788326cd9107965e59fc0804daad diff --git a/src/Extraction-prefix.hs b/src/Extraction-prefix.hs index fbe22cb..0775229 100644 --- a/src/Extraction-prefix.hs +++ b/src/Extraction-prefix.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module CoqPass ( coqPassCoreToString, coqPassCoreToCore ) where import qualified Unique @@ -28,11 +29,9 @@ import qualified Data.List import qualified Data.Ord import qualified Data.Typeable import Data.Bits ((.&.), shiftL, (.|.)) -import Prelude ( (++), (+), (==), Show, show, Char, (.), ($) ) +import Prelude ( (++), (+), (==), Show, show, (.), ($) ) import qualified Prelude -import qualified Debug.Trace import qualified GHC.Base -import qualified System.IO import qualified System.IO.Unsafe getTyConTyVars :: TyCon.TyCon -> [Var.TyVar] @@ -54,11 +53,14 @@ 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!" +errOrFail :: OrError t -> t errOrFail (OK x) = x errOrFail (Error s) = Prelude.error s @@ -87,8 +89,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 @@ -113,7 +116,7 @@ coreKindToKind k = else Prelude.error ((Prelude.++) "coreKindToKind got an unknown kind: " (Outputable.showSDoc (Outputable.ppr k))) outputableToString :: Outputable.Outputable a => a -> Prelude.String -outputableToString = (\x -> Outputable.showSDoc (Outputable.ppr x)) +outputableToString = (\x -> Outputable.showSDocDebug (Outputable.ppr x)) coreViewDeep :: Type.Type -> Type.Type coreViewDeep t = @@ -178,17 +181,19 @@ weakCoercionToCoreCoercion :: CoreCoercion -> Type.Type | WCoUnsafe t1 t2 => (t1,t2) -} +{-# NOINLINE trace #-} +trace :: Prelude.String -> a -> a +trace msg x = x --trace = Debug.Trace.trace --trace msg x = x -trace msg x = System.IO.Unsafe.unsafePerformIO $ Prelude.return x -{- -trace s x = x -trace msg x = System.IO.Unsafe.unsafePerformIO $ - (Prelude.>>=) (System.IO.hPutStrLn System.IO.stdout msg) (\_ -> Prelude.return x) -trace msg x = System.IO.Unsafe.unsafePerformIO $ - (Prelude.>>=) (System.IO.hPutStr System.IO.stdout " ") (\_ -> Prelude.return x) --} +--trace msg x = System.IO.Unsafe.unsafePerformIO $ Prelude.return x +--trace s x = x +--trace msg x = System.IO.Unsafe.unsafePerformIO $ +-- (Prelude.>>=) (System.IO.hPutStrLn System.IO.stdout msg) (\_ -> Prelude.return x) +--trace msg x = System.IO.Unsafe.unsafePerformIO $ +-- (Prelude.>>=) (System.IO.hPutStr System.IO.stdout " ") (\_ -> Prelude.return x) + {- -- used for extracting strings WITHOUT the patch for Coq bin2ascii =