@@ -92,38 +92,38 @@ data Constraint = !Scheme :~ !Scheme
9292instance Pretty Constraint where
9393 pretty (x :~ y) = pretty x <+> "~" <+> pretty y
9494
95−newtype DeBrujinContext = DeBrujinContext (Sum Int)
95+newtype DeBruijnContext = DeBruijnContext (Sum Int)
9696 deriving newtype (Eq, Ord, Show, Semigroup, Monoid, Group, Num)
9797
98−instance Act DeBrujinContext DeBrujin where
99− act (DeBrujinContext (Sum n)) (DeBrujin i j) = DeBrujin (i + n) j
98+instance Act DeBruijnContext DeBruijn where
99+ act (DeBruijnContext (Sum n)) (DeBruijn i j) = DeBruijn (i + n) j
100100
101−type TDeBrujinMap = ShiftedMap DeBrujinContext TypeVariable DeBrujin
101+type TDeBruijnMap = ShiftedMap DeBruijnContext TypeVariable DeBruijn
102102
103103close :: Predicate TypeVariable -> Scheme -> Scheme
104104close (Predicate f) =
105105 run
106− . evalState @TDeBrujinMap mempty
106+ . evalState @TDeBruijnMap mempty
107107 . runReader @Int 0
108108 . evalState @Int 0
109109 . close'
110110 where
111111 -- State is the sequential number, Reader is the binding context number
112− close' :: Scheme -> Eff '[State Int, Reader Int, State TDeBrujinMap] Scheme
112+ close' :: Scheme -> Eff '[State Int, Reader Int, State TDeBruijnMap] Scheme
113113 close' x@(NAtomic _) = return x
114114 close' (preds :=> t) =
115115 (:=>) <$> (Preds <$> closePred `traverse` unPreds preds) <*> closeType t
116116
117− closeType :: NType -> Eff '[State Int, Reader Int, State TDeBrujinMap] NType
117+ closeType :: NType -> Eff '[State Int, Reader Int, State TDeBruijnMap] NType
118118 closeType = \case
119− x@(NBrujin _) -> return x
120− (NTypeVariable tv) | f tv -> NBrujin <$> newbrujin tv
119+ x@(NBruijn _) -> return x
120+ (NTypeVariable tv) | f tv -> NBruijn <$> newbruijn tv
121121 x@(NTypeVariable _) -> return x
122122 (x :-> y) -> bndCtx $ (:->) <$> close' x <*> close' y
123123 (List x) -> bndCtx $ List <$> close' x
124124 (NAttrSet x) -> bndCtx $ NAttrSet <$> traverse close' x
125125
126− closePred :: Pred -> Eff '[State Int, Reader Int, State TDeBrujinMap] Pred
126+ closePred :: Pred -> Eff '[State Int, Reader Int, State TDeBruijnMap] Pred
127127 closePred = \case
128128 (Update x y z) -> bndCtx $ Update <$> closeType x <*> closeType y <*> closeType z
129129 (HasField t (k, v)) -> bndCtx $ do
@@ -132,18 +132,18 @@ close (Predicate f) =
132132 return $ HasField t' (k, v')
133133
134134 bndCtx m = do
135− modify @TDeBrujinMap (SM.shift 1)
135+ modify @TDeBruijnMap (SM.shift 1)
136136 x <- local @Int (+ 1) m
137− modify @TDeBrujinMap (SM.shift (-1))
137+ modify @TDeBruijnMap (SM.shift (-1))
138138 return x
139− newbrujin t = do
140− get @TDeBrujinMap <&> SM.lookup t >>= \case
139+ newbruijn t = do
140+ get @TDeBruijnMap <&> SM.lookup t >>= \case
141141 Nothing -> do
142142 i <- ask
143143 j <- get
144144 modify @Int (+ 1)
145− let x = DeBrujin i j
146− modify @TDeBrujinMap (SM.insert t x)
145+ let x = DeBruijn i j
146+ modify @TDeBruijnMap (SM.insert t x)
147147 return x
148148 Just x -> return x
149149
@@ -156,10 +156,10 @@ instance Free NType where
156156 free (List x) = free x
157157 free (NAttrSet attrs) = foldMap free . M.elems $ attrs
158158 free (x :-> y) = free x <> free y
159− free (NBrujin _) = S.empty
159+ free (NBruijn _) = S.empty
160160
161161 sub s r = case r of
162− NBrujin _ -> r
162+ NBruijn _ -> r
163163 NTypeVariable x -> NTypeVariable x -- it should be substituted higher in Scheme
164164 List x -> List $ sub s x
165165 NAttrSet m -> NAttrSet $ sub s <$> m
@@ -382,24 +382,24 @@ instantiate ::
382382 Eff effs Scheme
383383instantiate = evalState M.empty . instantiateScheme
384384 where
385− instantiateScheme :: forall. Scheme -> Eff (State (Map DeBrujin TypeVariable) ': effs) Scheme
385+ instantiateScheme :: forall. Scheme -> Eff (State (Map DeBruijn TypeVariable) ': effs) Scheme
386386 instantiateScheme (ps :=> t) =
387387 (:=>) <$> (Preds <$> traverse instantiatePred (unPreds ps)) <*> instantiate' t
388388 instantiateScheme x@(NAtomic _) = return x
389389
390− instantiatePred :: forall. Pred -> Eff (State (Map DeBrujin TypeVariable) ': effs) Pred
390+ instantiatePred :: forall. Pred -> Eff (State (Map DeBruijn TypeVariable) ': effs) Pred
391391 instantiatePred = \case
392392 (Update x y z) -> Update <$> instantiate' x <*> instantiate' y <*> instantiate' z
393393 (x `HasField` (f, y)) -> HasField <$> instantiate' x <*> ((f,) <$> instantiate y)
394394
395− instantiate' :: forall. NType -> Eff (State (Map DeBrujin TypeVariable) ': effs) NType
395+ instantiate' :: forall. NType -> Eff (State (Map DeBruijn TypeVariable) ': effs) NType
396396 instantiate' x@(NTypeVariable _) = return x
397− instantiate' (NBrujin db) = NTypeVariable <$> freshInst db
397+ instantiate' (NBruijn db) = NTypeVariable <$> freshInst db
398398 instantiate' (x :-> y) = (:->) <$> instantiateScheme x <*> instantiateScheme y
399399 instantiate' (List x) = List <$> instantiateScheme x
400400 instantiate' (NAttrSet xs) = NAttrSet <$> traverse instantiateScheme xs
401401
402− freshInst :: DeBrujin -> Eff (State (Map DeBrujin TypeVariable) ': effs) TypeVariable
402+ freshInst :: DeBruijn -> Eff (State (Map DeBruijn TypeVariable) ': effs) TypeVariable
403403 freshInst db = do
404404 gets (M.lookup db) >>= \case
405405 Just t -> return t