| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
LAM.Base
Description
This module contains all sorts of general definitions for working with terms
Synopsis
- module LAM.Types.BV
- module LAM.Types.Generic
- module LAM.Types.Pure
- freeIxs :: DBTerm -> [Int]
- appT :: Term -> Term -> Term
- substName :: Term -> Name -> Name -> Term
- isClosed :: Term -> Bool
- isFree :: Term -> Name -> Bool
- freshName :: String -> Term -> Name
- class IsNamedEnv (t :: Type -> Type) where
- newtype NamedList a = NamedList [(Name, a)]
- data RClosure (r :: Type -> Type) term (t :: Type -> Type) = Closure {
- t :: term
- env :: t (RHeapPointer r term t)
- data Tag a
- type RState (r :: Type -> Type) term (t :: Type -> Type) = (RClosure r term t, RStack r term t)
- type State = RState IORef Term Trie
- type RStack (r :: Type -> Type) term (t :: Type -> Type) = [Tag (RHeapPointer r term t)]
- type REnvironment (r :: Type -> Type) term (t :: Type -> Type) = t (RHeapPointer r term t)
- type RHeapPointer (r :: Type -> Type) term (t :: Type -> Type) = r (Maybe (RClosure r term t))
- type HeapRefs term (t :: Type -> Type) = [IORef (Maybe (RClosure IORef term t))]
- type Closure term (t :: Type -> Type) = RClosure IORef term t
- freeVars :: Term -> [Name]
- convStateRef :: forall m (t :: Type -> Type) r' r term. (Monad m, Traversable t, Traversable r') => (r (Maybe (RClosure r term t)) -> m (r' (Maybe (RClosure r term t)))) -> RState r term t -> m (RState r' term t)
- convClosureRef :: forall m (t :: Type -> Type) r' r term. (Monad m, Traversable t, Traversable r') => (r (Maybe (RClosure r term t)) -> m (r' (Maybe (RClosure r term t)))) -> RClosure r term t -> m (RClosure r' term t)
- withFix :: Term -> Term
- toTerm :: Term -> Term
- unsafeLookupNs :: [Name] -> Trie a -> [(Name, a)]
- mapFree :: (Int -> Int) -> DBTerm -> DBTerm
- collectHeap :: forall (t :: Type -> Type) term. Traversable t => RState IORef term t -> IO (HeapRefs term t)
Documentation
module LAM.Types.BV
module LAM.Types.Generic
module LAM.Types.Pure
DeBruijn version of freeVars.
length (freeIxs (toDBTerm id t)) = length (freeVars t)
length ctx = maximum (freeIxs t) + 1 => freeVars (fromDBTermCtx id ctx t) = ctx
substName :: Term -> Name -> Name -> Term #
substName t n n' is t[n/n'], i.e. replace every free
occurence of n' by n.
class IsNamedEnv (t :: Type -> Type) where #
An environment
Methods
eToList :: t a -> [(Name, a)] #
eFromList :: [(Name, a)] -> t a #
Instances
A basic environment for DeBruijn terms, including names for converting to a named representation.
Instances
data RClosure (r :: Type -> Type) term (t :: Type -> Type) #
Closure with a pointer type r.
Constructors
| Closure | |
Fields
| |
Instances
Tags for storing things on the stack.
Instances
type RState (r :: Type -> Type) term (t :: Type -> Type) = (RClosure r term t, RStack r term t) #
The state is a pair of a closure and a stack.
type RStack (r :: Type -> Type) term (t :: Type -> Type) = [Tag (RHeapPointer r term t)] #
Since we only ever interact with the stack via the top element, this can just be a list.
type REnvironment (r :: Type -> Type) term (t :: Type -> Type) = t (RHeapPointer r term t) #
An environment is a container of heap pointers. Does not specify how to index into the environment, so this works for named or DeBruijn.
type RHeapPointer (r :: Type -> Type) term (t :: Type -> Type) = r (Maybe (RClosure r term t)) #
Pointer to a closure or black hole
type HeapRefs term (t :: Type -> Type) = [IORef (Maybe (RClosure IORef term t))] #
A type for collecting heap pointers.
type Closure term (t :: Type -> Type) = RClosure IORef term t #
The most common pointer type is IORef.
convStateRef :: forall m (t :: Type -> Type) r' r term. (Monad m, Traversable t, Traversable r') => (r (Maybe (RClosure r term t)) -> m (r' (Maybe (RClosure r term t)))) -> RState r term t -> m (RState r' term t) #
Convert the pointer type in a state.
convClosureRef :: forall m (t :: Type -> Type) r' r term. (Monad m, Traversable t, Traversable r') => (r (Maybe (RClosure r term t)) -> m (r' (Maybe (RClosure r term t)))) -> RClosure r term t -> m (RClosure r' term t) #
Convert the pointer type in a closure.
Convert a general lambda term to a representation for our abstract machines.
unsafeLookupNs :: [Name] -> Trie a -> [(Name, a)] #
Lookup a subset of a trie.