Safe Haskell | Unsafe |
---|---|
Language | Haskell2010 |
de Bruijn levels for well-scoped terms.
Synopsis
- newtype Lvl ctx = UnsafeLvl Int
- lvlToIdx :: Size ctx -> Lvl ctx -> Idx ctx
- idxToLvl :: Size ctx -> Idx ctx -> Lvl ctx
- lvlZ :: Size ctx -> Lvl (S ctx)
- sinkLvl :: Lvl n -> Lvl (S n)
- class Sinkable t where
- sink :: Sinkable t => t ctx -> t (S ctx)
- mapSink :: (Functor f, Sinkable t) => f (t ctx) -> f (t (S ctx))
- sinkSize :: Sinkable t => Size ctx -> t EmptyCtx -> t ctx
- mapSinkSize :: (Functor f, Sinkable t) => Size ctx -> f (t EmptyCtx) -> f (t ctx)
- sinkAdd :: Sinkable t => Add n ctx ctx' -> t ctx -> t ctx'
- mapSinkAdd :: (Functor f, Sinkable t) => Add n ctx ctx' -> f (t ctx) -> f (t ctx')
Levels
de Bruijn levels.
lvlToIdx :: Size ctx -> Lvl ctx -> Idx ctx Source #
Convert level to index.
>>>
lvlToIdx S2 (lvlZ S1)
0
sinkLvl :: Lvl n -> Lvl (S n) Source #
Sink Lvl
into a larger context.
>>>
sinkLvl (lvlZ S3)
3
>>>
sink (lvlZ S3)
3
>>>
mapLvl (LS LZ) (lvlZ S3)
3
class Sinkable t where Source #
Sinkable terms can be weakened (sunk) cheaply.
sinkSize :: Sinkable t => Size ctx -> t EmptyCtx -> t ctx Source #
Sink term from empty context to a context of given size.