Skip to content

Commit e3df106

Browse files
committed
Merge remote-tracking branch 'origin/bladyjoker/proto-compat-rework' into bladyjoker/frontend
2 parents 1a8aaff + c1a3f33 commit e3df106

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

lambda-buffers-compiler/src/LambdaBuffers/Compiler/KindCheck.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import LambdaBuffers.Compiler.KindCheck.Inference (
3636
)
3737
import LambdaBuffers.Compiler.KindCheck.Inference qualified as I
3838
import LambdaBuffers.Compiler.KindCheck.Kind (kind2ProtoKind)
39-
import LambdaBuffers.Compiler.KindCheck.Type (Type (App), tyProd, tySum, tyUnit, tyVoid)
39+
import LambdaBuffers.Compiler.KindCheck.Type (Type (App), tyOpaque, tyProd, tySum, tyUnit, tyVoid)
4040
import LambdaBuffers.Compiler.KindCheck.Variable (Variable (ForeignRef, LocalRef))
4141
import LambdaBuffers.Compiler.ProtoCompat ()
4242
import LambdaBuffers.Compiler.ProtoCompat.Types qualified as PC
@@ -459,7 +459,7 @@ tyBody2Types ::
459459
PC.TyBody ->
460460
Eff eff [Type]
461461
tyBody2Types = \case
462-
PC.OpaqueI _ -> pure [Var $ LocalRef "Opaque"]
462+
PC.OpaqueI _ -> pure [Var tyOpaque]
463463
PC.SumI s -> sum2Types s
464464

465465
sum2Types ::

lambda-buffers-compiler/src/LambdaBuffers/Compiler/KindCheck/Inference.hs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import LambdaBuffers.Compiler.KindCheck.Context (Context (Context), addContext,
2121
import LambdaBuffers.Compiler.KindCheck.Derivation (Derivation (Abstraction, Application, Axiom))
2222
import LambdaBuffers.Compiler.KindCheck.Judgement (Judgement (Judgement))
2323
import 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)
2525
import LambdaBuffers.Compiler.KindCheck.Variable (Atom, Variable)
2626

2727
import Control.Monad.Freer (Eff, Member, Members, run)
@@ -87,20 +87,23 @@ runDerive ctx t = run $ runError $ runWriter $ evalState (DC atoms) $ runReader
8787

8888
infer :: Context -> Type -> Either InferErr Kind
8989
infer 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

Comments
 (0)