@@ -185,16 +185,18 @@ newtype DeBrujinContext = DeBrujinContext (Sum Int)
185185instance Act DeBrujinContext DeBrujin where
186186 act (DeBrujinContext (Sum n)) (DeBrujin i j) = DeBrujin (i + n) j
187187
188+type TDeBrujinMap = ShiftedMap DeBrujinContext TypeVariable DeBrujin
189+
188190close :: Range TypeVariable -> NType -> NType
189191close range =
190192 run
191− . evalState @(ShiftedMap DeBrujinContext TypeVariable DeBrujin) mempty
193+ . evalState @TDeBrujinMap mempty
192194 . runReader @Int 0
193195 . evalState @Int 0
194196 . close'
195197 where
196198 -- State is the sequential number, Reader is the binding context number
197− close' :: NType -> Eff '[State Int, Reader Int, State (ShiftedMap DeBrujinContext TypeVariable DeBrujin)] NType
199+ close' :: NType -> Eff '[State Int, Reader Int, State TDeBrujinMap] NType
198200 close' x@(NAtomic _) = return x
199201 close' x@(NBrujin _) = return x
200202 close' (NTypeVariable tv) | tv `R.member` range = NBrujin <$> newbrujin tv
@@ -203,18 +205,18 @@ close range =
203205 close' (NAttrSet x) = bndCtx $ NAttrSet <$> traverse close' x
204206
205207 bndCtx m = do
206− modify @(ShiftedMap DeBrujinContext TypeVariable DeBrujin) (SM.shift 1)
208+ modify @TDeBrujinMap (SM.shift 1)
207209 x <- local @Int (+ 1) m
208− modify @(ShiftedMap DeBrujinContext TypeVariable DeBrujin) (SM.shift (-1))
210+ modify @TDeBrujinMap (SM.shift (-1))
209211 return x
210212 newbrujin t = do
211− get @(ShiftedMap DeBrujinContext TypeVariable DeBrujin) <&> SM.lookup t >>= \case
213+ get @TDeBrujinMap <&> SM.lookup t >>= \case
212214 Nothing -> do
213215 i <- ask
214216 j <- get
215217 modify @Int (+ 1)
216218 let x = DeBrujin i j
217− modify @(ShiftedMap DeBrujinContext TypeVariable DeBrujin) (SM.insert t x)
219+ modify @TDeBrujinMap (SM.insert t x)
218220 return x
219221 Just x -> return x
220222