@@ -21,7 +21,7 @@ import LambdaBuffers.Compiler.KindCheck.Context (Context (Context), addContext,
2121import LambdaBuffers.Compiler.KindCheck.Derivation (Derivation (Abstraction , Application , Axiom ))
2222import LambdaBuffers.Compiler.KindCheck.Judgement (Judgement (Judgement ))
2323import LambdaBuffers.Compiler.KindCheck.Kind (Kind (KVar , Type , (:->:) ))
24- import LambdaBuffers.Compiler.KindCheck.Type (Type (Abs , App , Var ), tyProd , tySum , tyUnit , tyVoid )
24+ import LambdaBuffers.Compiler.KindCheck.Type (Type (Abs , App , Var ), tyOpaque , tyProd , tySum , tyUnit , tyVoid )
2525import LambdaBuffers.Compiler.KindCheck.Variable (Atom , Variable )
2626
2727import Control.Monad.Freer (Eff , Member , Members , run )
@@ -87,20 +87,23 @@ runDerive ctx t = run $ runError $ runWriter $ evalState (DC atoms) $ runReader
8787
8888infer :: Context -> Type -> Either InferErr Kind
8989infer ctx t = do
90- (d, c) <- runDerive (defTerms <> ctx) t
90+ (d, c) <- runDerive (defContext <> ctx) t
9191 s <- runUnify' c
9292 let res = foldl (flip substitute) d s
9393 pure $ res ^. topKind
94- where
95- defTerms =
96- mempty
97- & context
98- .~ M. fromList
99- [ (tySum, Type :->: Type :->: Type )
100- , (tyProd, Type :->: Type :->: Type )
101- , (tyUnit, Type )
102- , (tyVoid, Type )
103- ]
94+
95+ -- | Default KC Context.
96+ defContext :: Context
97+ defContext =
98+ mempty
99+ & context
100+ .~ M. fromList
101+ [ (tySum, Type :->: Type :->: Type )
102+ , (tyProd, Type :->: Type :->: Type )
103+ , (tyUnit, Type )
104+ , (tyVoid, Type )
105+ , (tyOpaque, Type )
106+ ]
104107
105108--------------------------------------------------------------------------------
106109-- Implementation
0 commit comments