morte-1.6.14: A bare-bones calculus of constructions

Safe HaskellNone
LanguageHaskell98

Morte.Context

Contents

Description

All Context-related operations

Synopsis

Context

data Context a Source #

Bound variable names and their types

Variable names may appear more than once in the Context. The Var x@n refers to the nth occurrence of x in the Context (using 0-based numbering).

Instances

Functor Context Source # 

Methods

fmap :: (a -> b) -> Context a -> Context b #

(<$) :: a -> Context b -> Context a #

NFData a => NFData (Context a) Source # 

Methods

rnf :: Context a -> () #

empty :: Context a Source #

An empty context with no key-value pairs

toList empty = []

insert :: Text -> a -> Context a -> Context a Source #

Add a key-value pair to the Context

lookup :: Text -> Int -> Context a -> Maybe a Source #

Lookup a key by name and index

lookup k 0 (insert k v0              ctx ) = Just v0
lookup k 1 (insert k v0 (insert k v1 ctx)) = Just v1

toList :: Context a -> [(Text, a)] Source #

Return all key-value associations as a list