LAM-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

LAM.Pure

Description

Pure versions of abstract machine states.

These hold the entire state, instead of needing an IO context to fetch data from the heap.

Synopsis

Documentation

class IsNamedEnv t => ToPureState a (t :: Type -> Type) where #

A class for printing abstract machine states.

Methods

toPureState :: a -> IO (PState t) #

Instances

Instances details
ToPureState (State NamedList) NamedList # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State NamedList) Trie # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State Seq) NamedList # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State Seq) Trie # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State Vector) NamedList # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State Vector) Trie # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State []) NamedList # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

ToPureState (State []) Trie # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

Methods

toPureState :: State [] -> IO (PState Trie) #

ToPureState (State NamedList) NamedList # 
Instance details

Defined in LAM.Exec.DBTrimPure

ToPureState (State NamedList) Trie # 
Instance details

Defined in LAM.Exec.DBTrimPure

ToPureState (State []) Trie # 
Instance details

Defined in LAM.Exec.DBTrimPure

Methods

toPureState :: State [] -> IO (PState Trie) #

IsNamedEnv t => ToPureState (PState t) t # 
Instance details

Defined in LAM.Pure

Methods

toPureState :: PState t -> IO (PState t) #

(IsNamedEnv t1, IsNamedEnv t2) => ToPureState (PState t1) t2 # 
Instance details

Defined in LAM.Pure

Methods

toPureState :: PState t1 -> IO (PState t2) #

(Traversable t1, CanTrim Term t1, IsNamedEnv t1, IsNamedEnv t2) => ToPureState (RState IORef Term t1) t2 # 
Instance details

Defined in LAM.Pure

Methods

toPureState :: RState IORef Term t1 -> IO (PState t2) #

type PState (t :: Type -> Type) = (RHeap Term t, PState' t) #

Pure state, i.e. a state that includes the heap.

type PState' (t :: Type -> Type) = RState Ref Term t #

Pure state, but without heap

class IsNamedEnv (t :: Type -> Type) where #

An environment

Minimal complete definition

eToList, eFromList

Methods

eToList :: t a -> [(Name, a)] #

eFromList :: [(Name, a)] -> t a #

eLookup :: Name -> t a -> Maybe a #

addToEnv :: Name -> a -> t a -> t a #

Instances

Instances details
IsNamedEnv NamedList # 
Instance details

Defined in LAM.Base

Methods

eToList :: NamedList a -> [(Name, a)] #

eFromList :: [(Name, a)] -> NamedList a #

eLookup :: Name -> NamedList a -> Maybe a #

addToEnv :: Name -> a -> NamedList a -> NamedList a #

IsNamedEnv Trie # 
Instance details

Defined in LAM.Base

Methods

eToList :: Trie a -> [(Name, a)] #

eFromList :: [(Name, a)] -> Trie a #

eLookup :: Name -> Trie a -> Maybe a #

addToEnv :: Name -> a -> Trie a -> Trie a #

IsNamedEnv Seq # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

Methods

eToList :: Seq a -> [(Name, a)] #

eFromList :: [(Name, a)] -> Seq a #

eLookup :: Name -> Seq a -> Maybe a #

addToEnv :: Name -> a -> Seq a -> Seq a #

IsNamedEnv Vector # 
Instance details

Defined in LAM.Exec.DBNoTrimPure

Methods

eToList :: Vector a -> [(Name, a)] #

eFromList :: [(Name, a)] -> Vector a #

eLookup :: Name -> Vector a -> Maybe a #

addToEnv :: Name -> a -> Vector a -> Vector a #

IsNamedEnv [] # 
Instance details

Defined in LAM.Base

Methods

eToList :: [a] -> [(Name, a)] #

eFromList :: [(Name, a)] -> [a] #

eLookup :: Name -> [a] -> Maybe a #

addToEnv :: Name -> a -> [a] -> [a] #

type RHeap term (t :: Type -> Type) = [(RHeapPointer Ref term t, Maybe (RClosure Ref term t))] #

A list representing the heap. We extract this from an abstract machine to get a pure value we can manipulate freely.

data Ref a #

The address pointing to a value of type a. We want to convert an IORef to this.

Instances

Instances details
Foldable Ref # 
Instance details

Defined in LAM.Pure

Methods

fold :: Monoid m => Ref m -> m #

foldMap :: Monoid m => (a -> m) -> Ref a -> m #

foldMap' :: Monoid m => (a -> m) -> Ref a -> m #

foldr :: (a -> b -> b) -> b -> Ref a -> b #

foldr' :: (a -> b -> b) -> b -> Ref a -> b #

foldl :: (b -> a -> b) -> b -> Ref a -> b #

foldl' :: (b -> a -> b) -> b -> Ref a -> b #

foldr1 :: (a -> a -> a) -> Ref a -> a #

foldl1 :: (a -> a -> a) -> Ref a -> a #

toList :: Ref a -> [a] #

null :: Ref a -> Bool #

length :: Ref a -> Int #

elem :: Eq a => a -> Ref a -> Bool #

maximum :: Ord a => Ref a -> a #

minimum :: Ord a => Ref a -> a #

sum :: Num a => Ref a -> a #

product :: Num a => Ref a -> a #

Traversable Ref # 
Instance details

Defined in LAM.Pure

Methods

traverse :: Applicative f => (a -> f b) -> Ref a -> f (Ref b) #

sequenceA :: Applicative f => Ref (f a) -> f (Ref a) #

mapM :: Monad m => (a -> m b) -> Ref a -> m (Ref b) #

sequence :: Monad m => Ref (m a) -> m (Ref a) #

Functor Ref # 
Instance details

Defined in LAM.Pure

Methods

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

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

Show (Ref a) # 
Instance details

Defined in LAM.Pure

Methods

showsPrec :: Int -> Ref a -> ShowS #

show :: Ref a -> String #

showList :: [Ref a] -> ShowS #

Eq (Ref a) # 
Instance details

Defined in LAM.Pure

Methods

(==) :: Ref a -> Ref a -> Bool #

(/=) :: Ref a -> Ref a -> Bool #

IsNamedEnv t => ToPureState (PState t) t # 
Instance details

Defined in LAM.Pure

Methods

toPureState :: PState t -> IO (PState t) #

(IsNamedEnv t1, IsNamedEnv t2) => ToPureState (PState t1) t2 # 
Instance details

Defined in LAM.Pure

Methods

toPureState :: PState t1 -> IO (PState t2) #

simpHeapAddrs :: forall (t :: Type -> Type). IsNamedEnv t => PState t -> PState t #

Replace actual heap addresses by small integers to make it easier to read the output.

heuristicCompState :: (ToPureState s1 Trie, ToPureState s2 Trie) => s1 -> s2 -> IO Bool #

Heuristic equality for ToPureStates. This doesn't properly follow pointers, but it should be very difficult to create two states that this test equates but aren't actually equal.

heuristicCompState s1 s2 = false => s1 /= s2

heuristicCompPState :: forall (t :: Type -> Type). IsNamedEnv t => PState t -> PState t -> Bool #

Heuristic equality for 'PState. This doesn't properly follow pointers, but it should be very difficult to create two states that this test equates but aren't actually equal.

heuristicCompPState s1 s2 = false => s1 /= s2

trimState :: forall (t :: Type -> Type). IsNamedEnv t => PState t -> PState t #

Removed unused references from 'PState

toPureStateGen :: forall t (t1 :: Type -> Type) (t2 :: Type -> Type). (CanTrim t t1, Traversable t1, IsNamedEnv t1, IsNamedEnv t2) => (t -> DBTerm) -> RState IORef t t1 -> IO (PState t2) #

Generic function to write ToPureState classes.

stateToTerm :: forall (t :: Type -> Type). IsNamedEnv t => PState t -> Term #

Orphan instances

Show (IORef a) # 
Instance details

Methods

showsPrec :: Int -> IORef a -> ShowS #

show :: IORef a -> String #

showList :: [IORef a] -> ShowS #

Show (Closure DBTerm t) # 
Instance details

Show (Closure Term Trie) # 
Instance details