packages feed

SSTG 0.1.0.6 → 0.1.0.7

raw patch · 14 files changed

+322/−289 lines, 14 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- SSTG.Core.Execution.Models: ApplyFrame :: [Atom] -> Locals -> Frame
- SSTG.Core.Execution.Models: Blackhole :: HeapObj
- SSTG.Core.Execution.Models: CaseFrame :: Var -> [Alt] -> Locals -> Frame
- SSTG.Core.Execution.Models: ConObj :: DataCon -> [Value] -> HeapObj
- SSTG.Core.Execution.Models: Evaluate :: Expr -> Locals -> Code
- SSTG.Core.Execution.Models: FunObj :: [Var] -> Expr -> Locals -> HeapObj
- SSTG.Core.Execution.Models: Globals :: (Map Name Value) -> Globals
- SSTG.Core.Execution.Models: Heap :: (Map MemAddr HeapObj) -> MemAddr -> Heap
- SSTG.Core.Execution.Models: LitObj :: Lit -> HeapObj
- SSTG.Core.Execution.Models: LitVal :: Lit -> Value
- SSTG.Core.Execution.Models: Locals :: (Map Name Value) -> Locals
- SSTG.Core.Execution.Models: MemAddr :: Int -> MemAddr
- SSTG.Core.Execution.Models: MemVal :: MemAddr -> Value
- SSTG.Core.Execution.Models: PathCond :: (AltCon, [Var]) -> Expr -> Locals -> Bool -> PathCond
- SSTG.Core.Execution.Models: Return :: Value -> Code
- SSTG.Core.Execution.Models: Stack :: [Frame] -> Stack
- SSTG.Core.Execution.Models: State :: Status -> Stack -> Heap -> Globals -> Code -> [Name] -> PathCons -> SymLinks -> State
- SSTG.Core.Execution.Models: Status :: Int -> Status
- SSTG.Core.Execution.Models: SymLinks :: (Map Name Name) -> SymLinks
- SSTG.Core.Execution.Models: SymObj :: Symbol -> HeapObj
- SSTG.Core.Execution.Models: Symbol :: Var -> (Maybe (Expr, Locals)) -> Symbol
- SSTG.Core.Execution.Models: SymbolicT :: (s -> (s, a)) -> SymbolicT s a
- SSTG.Core.Execution.Models: UpdateFrame :: MemAddr -> Frame
- SSTG.Core.Execution.Models: [run] :: SymbolicT s a -> s -> (s, a)
- SSTG.Core.Execution.Models: [state_code] :: State -> Code
- SSTG.Core.Execution.Models: [state_globals] :: State -> Globals
- SSTG.Core.Execution.Models: [state_heap] :: State -> Heap
- SSTG.Core.Execution.Models: [state_links] :: State -> SymLinks
- SSTG.Core.Execution.Models: [state_names] :: State -> [Name]
- SSTG.Core.Execution.Models: [state_paths] :: State -> PathCons
- SSTG.Core.Execution.Models: [state_stack] :: State -> Stack
- SSTG.Core.Execution.Models: [state_status] :: State -> Status
- SSTG.Core.Execution.Models: [steps] :: Status -> Int
- SSTG.Core.Execution.Models: allocHeap :: HeapObj -> Heap -> (Heap, MemAddr)
- SSTG.Core.Execution.Models: allocHeapList :: [HeapObj] -> Heap -> (Heap, [MemAddr])
- SSTG.Core.Execution.Models: data Code
- SSTG.Core.Execution.Models: data Frame
- SSTG.Core.Execution.Models: data Heap
- SSTG.Core.Execution.Models: data HeapObj
- SSTG.Core.Execution.Models: data PathCond
- SSTG.Core.Execution.Models: data State
- SSTG.Core.Execution.Models: data Status
- SSTG.Core.Execution.Models: data Symbol
- SSTG.Core.Execution.Models: data Value
- SSTG.Core.Execution.Models: insertGlobals :: Var -> Value -> Globals -> Globals
- SSTG.Core.Execution.Models: insertGlobalsList :: [(Var, Value)] -> Globals -> Globals
- SSTG.Core.Execution.Models: insertHeap :: MemAddr -> HeapObj -> Heap -> Heap
- SSTG.Core.Execution.Models: insertHeapList :: [(MemAddr, HeapObj)] -> Heap -> Heap
- SSTG.Core.Execution.Models: insertLocals :: Var -> Value -> Locals -> Locals
- SSTG.Core.Execution.Models: insertLocalsList :: [(Var, Value)] -> Locals -> Locals
- SSTG.Core.Execution.Models: instance GHC.Base.Applicative (SSTG.Core.Execution.Models.SymbolicT s)
- SSTG.Core.Execution.Models: instance GHC.Base.Functor (SSTG.Core.Execution.Models.SymbolicT s)
- SSTG.Core.Execution.Models: instance GHC.Base.Monad (SSTG.Core.Execution.Models.SymbolicT s)
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Code
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Frame
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Globals
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Heap
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.HeapObj
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Locals
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.MemAddr
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.PathCond
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Stack
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.State
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Status
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.SymLinks
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Symbol
- SSTG.Core.Execution.Models: instance GHC.Classes.Eq SSTG.Core.Execution.Models.Value
- SSTG.Core.Execution.Models: instance GHC.Classes.Ord SSTG.Core.Execution.Models.MemAddr
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Code
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Frame
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Globals
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Heap
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.HeapObj
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Locals
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.MemAddr
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.PathCond
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Stack
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.State
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Status
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.SymLinks
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Symbol
- SSTG.Core.Execution.Models: instance GHC.Read.Read SSTG.Core.Execution.Models.Value
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Code
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Frame
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Globals
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Heap
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.HeapObj
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Locals
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.MemAddr
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.PathCond
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Stack
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.State
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Status
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.SymLinks
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Symbol
- SSTG.Core.Execution.Models: instance GHC.Show.Show SSTG.Core.Execution.Models.Value
- SSTG.Core.Execution.Models: lookupGlobals :: Var -> Globals -> Maybe Value
- SSTG.Core.Execution.Models: lookupHeap :: MemAddr -> Heap -> Maybe HeapObj
- SSTG.Core.Execution.Models: lookupLocals :: Var -> Locals -> Maybe Value
- SSTG.Core.Execution.Models: lookupValue :: Var -> Locals -> Globals -> Maybe Value
- SSTG.Core.Execution.Models: memAddrInt :: MemAddr -> Int
- SSTG.Core.Execution.Models: memAddrType :: MemAddr -> Heap -> Maybe Type
- SSTG.Core.Execution.Models: nameOccStr :: Name -> String
- SSTG.Core.Execution.Models: nameUnique :: Name -> Int
- SSTG.Core.Execution.Models: newtype Globals
- SSTG.Core.Execution.Models: newtype Locals
- SSTG.Core.Execution.Models: newtype MemAddr
- SSTG.Core.Execution.Models: newtype Stack
- SSTG.Core.Execution.Models: newtype SymLinks
- SSTG.Core.Execution.Models: newtype SymbolicT s a
- SSTG.Core.Execution.Models: type PathCons = [PathCond]
- SSTG.Core.Execution.Models: varName :: Var -> Name
- SSTG.Core.Execution.Models: vlookupHeap :: Var -> Locals -> Globals -> Heap -> Maybe (MemAddr, HeapObj)
- SSTG.Core.Syntax.Typecheck: altType :: Alt -> Type
- SSTG.Core.Syntax.Typecheck: atomType :: Atom -> Type
- SSTG.Core.Syntax.Typecheck: dataConType :: DataCon -> Type
- SSTG.Core.Syntax.Typecheck: exprType :: Expr -> Type
- SSTG.Core.Syntax.Typecheck: litType :: Lit -> Type
- SSTG.Core.Syntax.Typecheck: primFunType :: PrimFun -> Type
- SSTG.Core.Syntax.Typecheck: varType :: Var -> Type
+ SSTG.Core.Execution.Support: ApplyFrame :: [Atom] -> Locals -> Frame
+ SSTG.Core.Execution.Support: Blackhole :: HeapObj
+ SSTG.Core.Execution.Support: CaseFrame :: Var -> [Alt] -> Locals -> Frame
+ SSTG.Core.Execution.Support: ConObj :: DataCon -> [Value] -> HeapObj
+ SSTG.Core.Execution.Support: Evaluate :: Expr -> Locals -> Code
+ SSTG.Core.Execution.Support: FunObj :: [Var] -> Expr -> Locals -> HeapObj
+ SSTG.Core.Execution.Support: Globals :: (Map Name Value) -> Globals
+ SSTG.Core.Execution.Support: Heap :: (Map MemAddr HeapObj) -> MemAddr -> Heap
+ SSTG.Core.Execution.Support: LitObj :: Lit -> HeapObj
+ SSTG.Core.Execution.Support: LitVal :: Lit -> Value
+ SSTG.Core.Execution.Support: Locals :: (Map Name Value) -> Locals
+ SSTG.Core.Execution.Support: MemAddr :: Int -> MemAddr
+ SSTG.Core.Execution.Support: MemVal :: MemAddr -> Value
+ SSTG.Core.Execution.Support: PathCond :: (AltCon, [Var]) -> Expr -> Locals -> Bool -> PathCond
+ SSTG.Core.Execution.Support: Return :: Value -> Code
+ SSTG.Core.Execution.Support: Stack :: [Frame] -> Stack
+ SSTG.Core.Execution.Support: State :: Status -> Stack -> Heap -> Globals -> Code -> [Name] -> PathCons -> SymLinks -> State
+ SSTG.Core.Execution.Support: Status :: Int -> Status
+ SSTG.Core.Execution.Support: SymLinks :: (Map Name Name) -> SymLinks
+ SSTG.Core.Execution.Support: SymObj :: Symbol -> HeapObj
+ SSTG.Core.Execution.Support: Symbol :: Var -> (Maybe (Expr, Locals)) -> Symbol
+ SSTG.Core.Execution.Support: SymbolicT :: (s -> (s, a)) -> SymbolicT s a
+ SSTG.Core.Execution.Support: UpdateFrame :: MemAddr -> Frame
+ SSTG.Core.Execution.Support: [run] :: SymbolicT s a -> s -> (s, a)
+ SSTG.Core.Execution.Support: [state_code] :: State -> Code
+ SSTG.Core.Execution.Support: [state_globals] :: State -> Globals
+ SSTG.Core.Execution.Support: [state_heap] :: State -> Heap
+ SSTG.Core.Execution.Support: [state_links] :: State -> SymLinks
+ SSTG.Core.Execution.Support: [state_names] :: State -> [Name]
+ SSTG.Core.Execution.Support: [state_paths] :: State -> PathCons
+ SSTG.Core.Execution.Support: [state_stack] :: State -> Stack
+ SSTG.Core.Execution.Support: [state_status] :: State -> Status
+ SSTG.Core.Execution.Support: [steps] :: Status -> Int
+ SSTG.Core.Execution.Support: allocHeap :: HeapObj -> Heap -> (Heap, MemAddr)
+ SSTG.Core.Execution.Support: allocHeapList :: [HeapObj] -> Heap -> (Heap, [MemAddr])
+ SSTG.Core.Execution.Support: data Code
+ SSTG.Core.Execution.Support: data Frame
+ SSTG.Core.Execution.Support: data Heap
+ SSTG.Core.Execution.Support: data HeapObj
+ SSTG.Core.Execution.Support: data PathCond
+ SSTG.Core.Execution.Support: data State
+ SSTG.Core.Execution.Support: data Status
+ SSTG.Core.Execution.Support: data Symbol
+ SSTG.Core.Execution.Support: data Value
+ SSTG.Core.Execution.Support: insertGlobals :: Var -> Value -> Globals -> Globals
+ SSTG.Core.Execution.Support: insertGlobalsList :: [(Var, Value)] -> Globals -> Globals
+ SSTG.Core.Execution.Support: insertHeap :: MemAddr -> HeapObj -> Heap -> Heap
+ SSTG.Core.Execution.Support: insertHeapList :: [(MemAddr, HeapObj)] -> Heap -> Heap
+ SSTG.Core.Execution.Support: insertLocals :: Var -> Value -> Locals -> Locals
+ SSTG.Core.Execution.Support: insertLocalsList :: [(Var, Value)] -> Locals -> Locals
+ SSTG.Core.Execution.Support: instance GHC.Base.Applicative (SSTG.Core.Execution.Support.SymbolicT s)
+ SSTG.Core.Execution.Support: instance GHC.Base.Functor (SSTG.Core.Execution.Support.SymbolicT s)
+ SSTG.Core.Execution.Support: instance GHC.Base.Monad (SSTG.Core.Execution.Support.SymbolicT s)
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Code
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Frame
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Globals
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Heap
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.HeapObj
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Locals
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.MemAddr
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.PathCond
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Stack
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.State
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Status
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.SymLinks
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Symbol
+ SSTG.Core.Execution.Support: instance GHC.Classes.Eq SSTG.Core.Execution.Support.Value
+ SSTG.Core.Execution.Support: instance GHC.Classes.Ord SSTG.Core.Execution.Support.MemAddr
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Code
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Frame
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Globals
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Heap
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.HeapObj
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Locals
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.MemAddr
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.PathCond
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Stack
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.State
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Status
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.SymLinks
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Symbol
+ SSTG.Core.Execution.Support: instance GHC.Read.Read SSTG.Core.Execution.Support.Value
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Code
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Frame
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Globals
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Heap
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.HeapObj
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Locals
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.MemAddr
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.PathCond
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Stack
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.State
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Status
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.SymLinks
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Symbol
+ SSTG.Core.Execution.Support: instance GHC.Show.Show SSTG.Core.Execution.Support.Value
+ SSTG.Core.Execution.Support: lookupGlobals :: Var -> Globals -> Maybe Value
+ SSTG.Core.Execution.Support: lookupHeap :: MemAddr -> Heap -> Maybe HeapObj
+ SSTG.Core.Execution.Support: lookupLocals :: Var -> Locals -> Maybe Value
+ SSTG.Core.Execution.Support: lookupValue :: Var -> Locals -> Globals -> Maybe Value
+ SSTG.Core.Execution.Support: memAddrInt :: MemAddr -> Int
+ SSTG.Core.Execution.Support: memAddrType :: MemAddr -> Heap -> Maybe Type
+ SSTG.Core.Execution.Support: nameOccStr :: Name -> String
+ SSTG.Core.Execution.Support: nameUnique :: Name -> Int
+ SSTG.Core.Execution.Support: newtype Globals
+ SSTG.Core.Execution.Support: newtype Locals
+ SSTG.Core.Execution.Support: newtype MemAddr
+ SSTG.Core.Execution.Support: newtype Stack
+ SSTG.Core.Execution.Support: newtype SymLinks
+ SSTG.Core.Execution.Support: newtype SymbolicT s a
+ SSTG.Core.Execution.Support: type PathCons = [PathCond]
+ SSTG.Core.Execution.Support: varName :: Var -> Name
+ SSTG.Core.Execution.Support: vlookupHeap :: Var -> Locals -> Globals -> Heap -> Maybe (MemAddr, HeapObj)
+ SSTG.Core.Syntax.Typing: altType :: Alt -> Type
+ SSTG.Core.Syntax.Typing: atomType :: Atom -> Type
+ SSTG.Core.Syntax.Typing: dataConType :: DataCon -> Type
+ SSTG.Core.Syntax.Typing: exprType :: Expr -> Type
+ SSTG.Core.Syntax.Typing: litType :: Lit -> Type
+ SSTG.Core.Syntax.Typing: primFunType :: PrimFun -> Type
+ SSTG.Core.Syntax.Typing: varType :: Var -> Type

Files

README.md view
@@ -10,7 +10,7 @@ ## Dependencies * `ghc >= 8.0.1` -## Install+## Installation with Cabal `cabal install SSTG`  ## As an API@@ -27,7 +27,7 @@ This can be extracted from Haskell source by performing a call to the function:  ```-mkTargetBindings :: FilePath -> FilePath -> IO [SSTG.Binding]+mkTargetBindings :: FilePath -> FilePath -> IO [Binding] mkTargetBinding proj src = ... ``` @@ -45,15 +45,48 @@ proj = path/to/stuff src  = path/to/stuff/folder-one/source.hs ```-The extracted `[SSTG.Binding]`, like almost everything in SSTG, is endowed with `Show, Equal, Read`. However, it is advised to use the pretty-print functions defined in `SSTG.Utils.Printing`. For instance:+The extracted `[Binding]`, like almost everything in SSTG, is endowed with `Show, Equal, Read`. However, it is advised to use the pretty-print functions defined in `SSTG.Utils.Printing`. For instance: ```-pprBindingStr :: SSTG.Binding -> String+pprBindingStr :: Binding -> String ``` -#### Defunctionalizatoin+#### Defunctionalization+HEY KIDS YA EVER WANNA REASON ABOUT HIGHER-ORDER FUNCTIONS BUT YOUR SMT SOLVER AIN'T SMAHT ENOUGH??? CHECK OUT THIS [COOL WIKIPEDIA ARTICLE RIGHT HERE!!!][defunctionalization] +[defunctionalization]: https://en.wikipedia.org/wiki/Defunctionalization+ #### Symbolic Execution+Symbolic execution is done by performin a series of graph reductions on a `State` until we reach some value form, or our `step_count` tick runs out, creating a form of bounded execution exploration. +To load a `State`, two functions can be used:+```+data LoadResult = LoadOkay State | LoadGuess State [Binding] | LoadError String++newtype Program = Program [Binding]++loadState :: Program -> LoadResult++loadStateEntry :: String -> Program -> LoadResult+```+Next we have to fill out the flags for execution:+```+data StepType = BFS | BFSLogged | DFS | DFSLogged++data RunFlags = RunFlags { step_count :: Int+                         , step_type  :: StepType+                         , dump_dir   :: Maybe FilePath }+```+Here `step_count` is the number of steps we may take, the `step_type` is currently only implemented for `BFS` and `BFSLogged`, the latter of which keeps track of every step taken, while `BFS` only returns the very last state. Note that `BFSLogged` is currently unoptimized because it is easy to implement that way :)++Finally, to perform execution, the `execute` function is used:+```+execute :: RunFlags -> State -> [([LiveState], [DeadState])]+```+This yields a list of execution snapshots. The list is a singleton list if `BFS` or `DFS` is used, while multiple snapshots if the `BFSLogged` or `DFSLogged` is done. These can be then printed by using `pprLivesDeadsStr`:+```+pprLivesDeadsStr :: ([LiveState], [DeadState]) -> String+```+ #### Constraint Solving To come. @@ -61,6 +94,6 @@ * Defunctionalization pre-processing * SMT integration -## Shortcommings+## Shortcomings * Uninterpreted function evaluations are abstracted as symbolic computations. This includes all functions defined in `Prelude` and those not defined in the scope of the target programs. * There might be bugs, who knows? :)
SSTG.cabal view
@@ -1,5 +1,5 @@ name:                SSTG-version:             0.1.0.6+version:             0.1.0.7 synopsis:            STG Symbolic Execution description:         Prototype of STG-based Symbolic Execution for Haskell. homepage:            https://github.com/AntonXue/SSTG#readme@@ -21,13 +21,13 @@                      , SSTG.Core.Translation.Haskell                      , SSTG.Core.Syntax                      , SSTG.Core.Syntax.Language-                     , SSTG.Core.Syntax.Typecheck+                     , SSTG.Core.Syntax.Typing                      , SSTG.Core.Execution                      , SSTG.Core.Execution.Engine-                     , SSTG.Core.Execution.Models                      , SSTG.Core.Execution.Naming                      , SSTG.Core.Execution.Rules                      , SSTG.Core.Execution.Stepping+                     , SSTG.Core.Execution.Support                      , SSTG.Utils                      , SSTG.Utils.Printing                      , SSTG.Utils.FileIO
src/SSTG/Core/Execution.hs view
@@ -1,15 +1,15 @@ -- | Export Module for SSTG.Core.Execution module SSTG.Core.Execution     ( module SSTG.Core.Execution.Engine-    , module SSTG.Core.Execution.Models     , module SSTG.Core.Execution.Naming     , module SSTG.Core.Execution.Rules     , module SSTG.Core.Execution.Stepping+    , module SSTG.Core.Execution.Support     ) where  import SSTG.Core.Execution.Engine-import SSTG.Core.Execution.Models import SSTG.Core.Execution.Naming import SSTG.Core.Execution.Rules import SSTG.Core.Execution.Stepping+import SSTG.Core.Execution.Support 
src/SSTG/Core/Execution/Engine.hs view
@@ -10,9 +10,9 @@     ) where  import SSTG.Core.Syntax-import SSTG.Core.Execution.Models import SSTG.Core.Execution.Naming import SSTG.Core.Execution.Stepping+import SSTG.Core.Execution.Support  import qualified Data.Map as M 
− src/SSTG/Core/Execution/Models.hs
@@ -1,213 +0,0 @@--- | Symbolic STG Execution Models-module SSTG.Core.Execution.Models-    ( module SSTG.Core.Execution.Models-    ) where--import SSTG.Core.Syntax--import qualified Data.Map as M---- | Symbolic Transformation represents transformations applied to some--- State`(s). This is useful in allowing us to transfer from different actions--- within the engine.-newtype SymbolicT s a = SymbolicT { run :: s -> (s, a) }---- | Functor instance of Symbolic Transformation.-instance Functor (SymbolicT s) where-    fmap f st = SymbolicT (\s0 -> let (s1, a1) = (run st) s0 in (s1, f a1))---- | Applicative instance of Symbolic Transformation.-instance Applicative (SymbolicT s) where-    pure a    = SymbolicT (\s -> (s, a))-    sf <*> st = SymbolicT (\s0 -> let (s1, a1) = (run st) s0-                                      (s2, f2) = (run sf) s1 in (s2, f2 a1))---- | Monad instance of Symbolic Transformation.-instance Monad (SymbolicT s) where-    return a  = pure a-    st >>= fs = SymbolicT (\s0 -> let (s1, a1) = (run st) s0-                                      (s2, a2) = (run (fs a1)) s1 in (s2, a2))---- | `State` contains the information necessary to perform symbolic execution.--- Eval/Apply graph reduction semantics are used.-data State = State { state_status  :: Status-                   , state_stack   :: Stack-                   , state_heap    :: Heap-                   , state_globals :: Globals-                   , state_code    :: Code-                   , state_names   :: [Name]-                   , state_paths   :: PathCons-                   , state_links   :: SymLinks-                   } deriving (Show, Eq, Read)---- | Symbolic variables. The @Maybe (Expr, Locals)@ can be used to trace the--- source from which the symbolic variable was generated. For instance, this is--- useful during symbolic function application.-data Symbol = Symbol Var (Maybe (Expr, Locals)) deriving (Show, Eq, Read)---- | State status.-data Status = Status { steps :: Int-                     } deriving (Show, Eq, Read)---- | Execution stack used in graph reduction semnatics.-newtype Stack = Stack [Frame] deriving (Show, Eq, Read)---- | Frames of a stack.-data Frame = CaseFrame   Var [Alt] Locals-           | ApplyFrame  [Atom]    Locals-           | UpdateFrame MemAddr-           deriving (Show, Eq, Read)---- | Memory address for things on the `Heap`.-newtype MemAddr = MemAddr Int deriving (Show, Eq, Read, Ord)---- | A `Value` is something that we aim to reduce our current expression down--- into. `MemAddr` is a pointer to an object on the heap, such as `FunObj` or--- `ConObj`, which are "returned" from expression evaluation in this form.-data Value = LitVal Lit-           | MemVal MemAddr-           deriving (Show, Eq, Read)---- | Locals binds a `Var`'s `Name` to its some `Value`.-newtype Locals = Locals (M.Map Name Value) deriving (Show, Eq, Read)---- | Heaps map `MemAddr` to `HeapObj`, while keeping track of the last address--- that was allocated. This allows us to consistently allocate fresh addresses--- on the `Heap`.-data Heap = Heap (M.Map MemAddr HeapObj) MemAddr deriving (Show, Eq, Read)---- | Heap objects.-data HeapObj = LitObj Lit-             | SymObj Symbol-             | ConObj DataCon [Value]-             | FunObj [Var] Expr Locals-             | Blackhole-             deriving (Show, Eq, Read)---- | Globals are statically loaded at the time when a `State` is loaded.--- However, because uninterpreted / out-of-scope variables are made symbolic--- at runtime, it can be modified during execution.-newtype Globals = Globals (M.Map Name Value) deriving (Show, Eq, Read)---- | Evaluation of the current expression. We are either evaluating, or ready--- to return with some `Value`.-data Code = Evaluate Expr Locals-          | Return   Value-          deriving (Show, Eq, Read)---- | Path constraints.-type PathCons = [PathCond]---- | Path conditions denote logical paths taken in program execution thus far.-data PathCond = PathCond (AltCon, [Var]) Expr Locals Bool-              deriving (Show, Eq, Read)---- | Symbolic link tables helps keep track of what names went to what, what?-newtype SymLinks = SymLinks (M.Map Name Name) deriving (Show, Eq, Read)----   Simple functions that require only the immediate data structure.---- | A `Name`'s occurrence string.-nameOccStr :: Name -> String-nameOccStr (Name occ _ _ _) = occ---- | Name's unique `Int` key.-nameUnique :: Name -> Int-nameUnique (Name _ _ _ unq) = unq---- | Variable name.-varName :: Var -> Name-varName (Var name _) = name---- | `MemAddr`'s `Int` value.-memAddrInt :: MemAddr -> Int-memAddrInt (MemAddr int) = int---- | `Locals` lookup.-lookupLocals :: Var -> Locals -> Maybe Value-lookupLocals var (Locals lmap) = M.lookup (varName var) lmap---- | `Locals` insertion.-insertLocals :: Var -> Value -> Locals -> Locals-insertLocals var val (Locals lmap) = Locals lmap'-  where lmap' = M.insert (varName var) val lmap---- | List insertion into `Locals`.-insertLocalsList :: [(Var, Value)] -> Locals -> Locals-insertLocalsList []               locals = locals-insertLocalsList ((var, val):vvs) locals = insertLocalsList vvs locals'-  where locals' = insertLocals var val locals---- | `Heap` lookup.-lookupHeap :: MemAddr -> Heap -> Maybe HeapObj-lookupHeap addr (Heap hmap _) = M.lookup addr hmap---- | `Heap` allocation. Updates the last `MemAddr` kept in the `Heap`.-allocHeap :: HeapObj -> Heap -> (Heap, MemAddr)-allocHeap hobj (Heap hmap prev) = (Heap hmap' addr, addr)-  where addr  = MemAddr ((memAddrInt prev) + 1)-        hmap' = M.insert addr hobj hmap---- | Allocate a list of `HeapObj` in a `Heap`, returning in the same order the--- `MemAddr` at which they have been allocated at.-allocHeapList :: [HeapObj] -> Heap -> (Heap, [MemAddr])-allocHeapList []           heap = (heap, [])-allocHeapList (hobj:hobjs) heap = (heapf, addr : as)-  where (heap', addr) = allocHeap hobj heap-        (heapf, as)   = allocHeapList hobjs heap'---- | `Heap` direct insertion at a specific `MemAddr`.-insertHeap :: MemAddr -> HeapObj -> Heap -> Heap-insertHeap addr hobj (Heap hmap prev) = Heap hmap' prev-  where hmap' = M.insert addr hobj hmap---- | Insert a list of `HeapObj` at specified `MemAddr` locations.-insertHeapList :: [(MemAddr, HeapObj)] -> Heap -> Heap-insertHeapList []                 heap = heap-insertHeapList ((addr, hobj):ahs) heap = insertHeapList ahs heap'-  where heap' = insertHeap addr hobj heap---- | `Globals` lookup.-lookupGlobals :: Var -> Globals -> Maybe Value-lookupGlobals var (Globals gmap) = M.lookup (varName var) gmap---- | `Globals` insertion.-insertGlobals :: Var -> Value -> Globals -> Globals-insertGlobals var val (Globals gmap) = Globals gmap'-  where gmap' = M.insert (varName var) val gmap---- | Insert a list of `Var` and `Value` pairs into `Globals`. This would--- typically occur for new symbolic variables created from uninterpreted /--- out-of-scope variables during runtime.-insertGlobalsList :: [(Var, Value)] -> Globals -> Globals-insertGlobalsList []               globals = globals-insertGlobalsList ((var, val):vvs) globals = insertGlobalsList vvs globals'-  where globals' = insertGlobals var val globals----   Complex functions that involve multiple data structures.---- | `Value` lookup from the `Locals` first, then `Globals`.-lookupValue :: Var -> Locals -> Globals -> Maybe Value-lookupValue var locals globals = case lookupLocals var locals of-    Nothing -> lookupGlobals var globals-    mb_val  -> mb_val---- | `Heap` lookup. Returns the corresponding `MemAddr` and `HeapObj` if found.-vlookupHeap :: Var -> Locals -> Globals -> Heap -> Maybe (MemAddr, HeapObj)-vlookupHeap var locals globals heap = do-    val <- lookupValue var locals globals-    case val of-        LitVal _    -> Nothing-        MemVal addr -> lookupHeap addr heap >>= \hobj -> Just (addr, hobj)---- | Type of `HeapObj` held at `MemAddr`, if found.-memAddrType :: MemAddr -> Heap -> Maybe Type-memAddrType addr heap = do-    hobj <- lookupHeap addr heap-    Just $ case hobj of-        Blackhole           -> Bottom-        LitObj lit          -> litType lit-        SymObj (Symbol s _) -> varType s-        ConObj dcon _       -> dataConType dcon-        FunObj prms expr _  -> foldr FunTy (exprType expr) (map varType prms)-
src/SSTG/Core/Execution/Naming.hs view
@@ -9,7 +9,7 @@     ) where  import SSTG.Core.Syntax-import SSTG.Core.Execution.Models+import SSTG.Core.Execution.Support  import qualified Data.List as L import qualified Data.Map  as M@@ -49,8 +49,8 @@  -- | `Name`s in the `Heap`. heapNames :: Heap -> [Name]-heapNames (Heap heap _) = concatMap (heapObjNames . snd) kvs-  where kvs = M.toList heap+heapNames (Heap heap _) = concatMap (heapObjNames . snd) hlist+  where hlist = M.toList heap  -- | `Name`s in a `HeapObj`. heapObjNames :: HeapObj -> [Name]@@ -169,8 +169,8 @@  -- | `Name`s in a `SymLinks`. linksNames :: SymLinks -> [Name]-linksNames (SymLinks links) = concatMap (\(a, b) -> [a, b]) kvs-  where kvs = M.toList links+linksNames (SymLinks links) = concatMap (\(a, b) -> [a, b]) slist+  where slist = M.toList links  -- | Create a fresh seed given any `Int`, a `String` seed, and a `Set` of -- `String`s that we do not want our new `String` to conflict with. The sole
src/SSTG/Core/Execution/Rules.hs view
@@ -6,8 +6,8 @@     ) where  import SSTG.Core.Syntax-import SSTG.Core.Execution.Models import SSTG.Core.Execution.Naming+import SSTG.Core.Execution.Support  -- | `Rule`s that are applied during STG reduction. data Rule = RuleAtomLit | RuleAtomLitPtr | RuleAtomValPtr | RuleAtomUnInt
src/SSTG/Core/Execution/Stepping.hs view
@@ -8,8 +8,8 @@     , runBoundedDFSLogged     ) where -import SSTG.Core.Execution.Models import SSTG.Core.Execution.Rules+import SSTG.Core.Execution.Support  -- | A `State` that is not in value form yet, capable of being evaluated. A -- list of `Rule`s is kept to denote reduction history.
+ src/SSTG/Core/Execution/Support.hs view
@@ -0,0 +1,213 @@+-- | Symbolic STG Execution Support Architecture+module SSTG.Core.Execution.Support+    ( module SSTG.Core.Execution.Support+    ) where++import SSTG.Core.Syntax++import qualified Data.Map as M++-- | Symbolic Transformation represents transformations applied to some+-- State`(s). This is useful in allowing us to transfer from different actions+-- within the engine.+newtype SymbolicT s a = SymbolicT { run :: s -> (s, a) }++-- | Functor instance of Symbolic Transformation.+instance Functor (SymbolicT s) where+    fmap f st = SymbolicT (\s0 -> let (s1, a1) = (run st) s0 in (s1, f a1))++-- | Applicative instance of Symbolic Transformation.+instance Applicative (SymbolicT s) where+    pure a    = SymbolicT (\s -> (s, a))+    sf <*> st = SymbolicT (\s0 -> let (s1, a1) = (run st) s0+                                      (s2, f2) = (run sf) s1 in (s2, f2 a1))++-- | Monad instance of Symbolic Transformation.+instance Monad (SymbolicT s) where+    return a  = pure a+    st >>= fs = SymbolicT (\s0 -> let (s1, a1) = (run st) s0+                                      (s2, a2) = (run (fs a1)) s1 in (s2, a2))++-- | `State` contains the information necessary to perform symbolic execution.+-- Eval/Apply graph reduction semantics are used.+data State = State { state_status  :: Status+                   , state_stack   :: Stack+                   , state_heap    :: Heap+                   , state_globals :: Globals+                   , state_code    :: Code+                   , state_names   :: [Name]+                   , state_paths   :: PathCons+                   , state_links   :: SymLinks+                   } deriving (Show, Eq, Read)++-- | Symbolic variables. The @Maybe (Expr, Locals)@ can be used to trace the+-- source from which the symbolic variable was generated. For instance, this is+-- useful during symbolic function application.+data Symbol = Symbol Var (Maybe (Expr, Locals)) deriving (Show, Eq, Read)++-- | State status.+data Status = Status { steps :: Int+                     } deriving (Show, Eq, Read)++-- | Execution stack used in graph reduction semnatics.+newtype Stack = Stack [Frame] deriving (Show, Eq, Read)++-- | Frames of a stack.+data Frame = CaseFrame   Var [Alt] Locals+           | ApplyFrame  [Atom]    Locals+           | UpdateFrame MemAddr+           deriving (Show, Eq, Read)++-- | Memory address for things on the `Heap`.+newtype MemAddr = MemAddr Int deriving (Show, Eq, Read, Ord)++-- | A `Value` is something that we aim to reduce our current expression down+-- into. `MemAddr` is a pointer to an object on the heap, such as `FunObj` or+-- `ConObj`, which are "returned" from expression evaluation in this form.+data Value = LitVal Lit+           | MemVal MemAddr+           deriving (Show, Eq, Read)++-- | Locals binds a `Var`'s `Name` to its some `Value`.+newtype Locals = Locals (M.Map Name Value) deriving (Show, Eq, Read)++-- | Heaps map `MemAddr` to `HeapObj`, while keeping track of the last address+-- that was allocated. This allows us to consistently allocate fresh addresses+-- on the `Heap`.+data Heap = Heap (M.Map MemAddr HeapObj) MemAddr deriving (Show, Eq, Read)++-- | Heap objects.+data HeapObj = LitObj Lit+             | SymObj Symbol+             | ConObj DataCon [Value]+             | FunObj [Var] Expr Locals+             | Blackhole+             deriving (Show, Eq, Read)++-- | Globals are statically loaded at the time when a `State` is loaded.+-- However, because uninterpreted / out-of-scope variables are made symbolic+-- at runtime, it can be modified during execution.+newtype Globals = Globals (M.Map Name Value) deriving (Show, Eq, Read)++-- | Evaluation of the current expression. We are either evaluating, or ready+-- to return with some `Value`.+data Code = Evaluate Expr Locals+          | Return   Value+          deriving (Show, Eq, Read)++-- | Path constraints.+type PathCons = [PathCond]++-- | Path conditions denote logical paths taken in program execution thus far.+data PathCond = PathCond (AltCon, [Var]) Expr Locals Bool+              deriving (Show, Eq, Read)++-- | Symbolic link tables helps keep track of what names went to what, what?+newtype SymLinks = SymLinks (M.Map Name Name) deriving (Show, Eq, Read)++--   Simple functions that require only the immediate data structure.++-- | A `Name`'s occurrence string.+nameOccStr :: Name -> String+nameOccStr (Name occ _ _ _) = occ++-- | Name's unique `Int` key.+nameUnique :: Name -> Int+nameUnique (Name _ _ _ unq) = unq++-- | Variable name.+varName :: Var -> Name+varName (Var name _) = name++-- | `MemAddr`'s `Int` value.+memAddrInt :: MemAddr -> Int+memAddrInt (MemAddr int) = int++-- | `Locals` lookup.+lookupLocals :: Var -> Locals -> Maybe Value+lookupLocals var (Locals lmap) = M.lookup (varName var) lmap++-- | `Locals` insertion.+insertLocals :: Var -> Value -> Locals -> Locals+insertLocals var val (Locals lmap) = Locals lmap'+  where lmap' = M.insert (varName var) val lmap++-- | List insertion into `Locals`.+insertLocalsList :: [(Var, Value)] -> Locals -> Locals+insertLocalsList []               locals = locals+insertLocalsList ((var, val):vvs) locals = insertLocalsList vvs locals'+  where locals' = insertLocals var val locals++-- | `Heap` lookup.+lookupHeap :: MemAddr -> Heap -> Maybe HeapObj+lookupHeap addr (Heap hmap _) = M.lookup addr hmap++-- | `Heap` allocation. Updates the last `MemAddr` kept in the `Heap`.+allocHeap :: HeapObj -> Heap -> (Heap, MemAddr)+allocHeap hobj (Heap hmap prev) = (Heap hmap' addr, addr)+  where addr  = MemAddr ((memAddrInt prev) + 1)+        hmap' = M.insert addr hobj hmap++-- | Allocate a list of `HeapObj` in a `Heap`, returning in the same order the+-- `MemAddr` at which they have been allocated at.+allocHeapList :: [HeapObj] -> Heap -> (Heap, [MemAddr])+allocHeapList []           heap = (heap, [])+allocHeapList (hobj:hobjs) heap = (heapf, addr : as)+  where (heap', addr) = allocHeap hobj heap+        (heapf, as)   = allocHeapList hobjs heap'++-- | `Heap` direct insertion at a specific `MemAddr`.+insertHeap :: MemAddr -> HeapObj -> Heap -> Heap+insertHeap addr hobj (Heap hmap prev) = Heap hmap' prev+  where hmap' = M.insert addr hobj hmap++-- | Insert a list of `HeapObj` at specified `MemAddr` locations.+insertHeapList :: [(MemAddr, HeapObj)] -> Heap -> Heap+insertHeapList []                 heap = heap+insertHeapList ((addr, hobj):ahs) heap = insertHeapList ahs heap'+  where heap' = insertHeap addr hobj heap++-- | `Globals` lookup.+lookupGlobals :: Var -> Globals -> Maybe Value+lookupGlobals var (Globals gmap) = M.lookup (varName var) gmap++-- | `Globals` insertion.+insertGlobals :: Var -> Value -> Globals -> Globals+insertGlobals var val (Globals gmap) = Globals gmap'+  where gmap' = M.insert (varName var) val gmap++-- | Insert a list of `Var` and `Value` pairs into `Globals`. This would+-- typically occur for new symbolic variables created from uninterpreted /+-- out-of-scope variables during runtime.+insertGlobalsList :: [(Var, Value)] -> Globals -> Globals+insertGlobalsList []               globals = globals+insertGlobalsList ((var, val):vvs) globals = insertGlobalsList vvs globals'+  where globals' = insertGlobals var val globals++--   Complex functions that involve multiple data structures.++-- | `Value` lookup from the `Locals` first, then `Globals`.+lookupValue :: Var -> Locals -> Globals -> Maybe Value+lookupValue var locals globals = case lookupLocals var locals of+    Nothing -> lookupGlobals var globals+    mb_val  -> mb_val++-- | `Heap` lookup. Returns the corresponding `MemAddr` and `HeapObj` if found.+vlookupHeap :: Var -> Locals -> Globals -> Heap -> Maybe (MemAddr, HeapObj)+vlookupHeap var locals globals heap = do+    val <- lookupValue var locals globals+    case val of+        LitVal _    -> Nothing+        MemVal addr -> lookupHeap addr heap >>= \hobj -> Just (addr, hobj)++-- | Type of `HeapObj` held at `MemAddr`, if found.+memAddrType :: MemAddr -> Heap -> Maybe Type+memAddrType addr heap = do+    hobj <- lookupHeap addr heap+    Just $ case hobj of+        Blackhole           -> Bottom+        LitObj lit          -> litType lit+        SymObj (Symbol s _) -> varType s+        ConObj dcon _       -> dataConType dcon+        FunObj prms expr _  -> foldr FunTy (exprType expr) (map varType prms)+
src/SSTG/Core/Syntax.hs view
@@ -1,9 +1,9 @@ -- | Export Module for SSTG.Syntax module SSTG.Core.Syntax     ( module SSTG.Core.Syntax.Language-    , module SSTG.Core.Syntax.Typecheck+    , module SSTG.Core.Syntax.Typing     ) where  import SSTG.Core.Syntax.Language-import SSTG.Core.Syntax.Typecheck+import SSTG.Core.Syntax.Typing 
src/SSTG/Core/Syntax/Language.hs view
@@ -22,7 +22,7 @@ type TyCon    = GenTyCon    Name type AlgTyRhs = GenAlgTyRhs Name --- | A Program is defined as a list of bindings. The @bnd@ is an identifier+-- | A `Program` is defined as a list of bindings. The @bnd@ is an identifier -- that determines a unique binder to the @var@. In practice, these are defined -- to be `Name` and `Var` respectively. newtype GenProgram bnd var = Program [GenBinding bnd var]
− src/SSTG/Core/Syntax/Typecheck.hs
@@ -1,53 +0,0 @@--- | Typing Module-module SSTG.Core.Syntax.Typecheck-    ( module SSTG.Core.Syntax.Typecheck-    ) where--import SSTG.Core.Syntax.Language---- | Variable type.-varType :: Var -> Type-varType (Var _ ty) = ty---- | Literal type.-litType :: Lit -> Type-litType (MachChar _ ty)      = ty-litType (MachStr _ ty)       = ty-litType (MachInt _ ty)       = ty-litType (MachWord _ ty)      = ty-litType (MachFloat _ ty)     = ty-litType (MachDouble _ ty)    = ty-litType (MachNullAddr ty)    = ty-litType (MachLabel _ _ ty)   = ty-litType (BlankAddr)          = Bottom-litType (AddrLit _)          = Bottom-litType (SymLit var)         = varType var-litType (SymLitEval pf args) = foldl AppTy (primFunType pf) (map litType args)---- | Atom type.-atomType :: Atom -> Type-atomType (VarAtom var) = varType var-atomType (LitAtom lit) = litType lit---- | Primitive function type.-primFunType :: PrimFun -> Type-primFunType (PrimFun _ ty) = ty---- | Data constructor type denoted as a function.-dataConType :: DataCon -> Type-dataConType (DataCon _ ty tys) = foldr FunTy ty tys---- | Alt type-altType :: Alt -> Type-altType (Alt _ _ expr) = exprType expr---- | I wonder what this could possibly be?-exprType :: Expr -> Type-exprType (Atom atom)       = atomType atom-exprType (PrimApp pf args) = foldl AppTy (primFunType pf) (map atomType args)-exprType (ConApp dc args)  = foldl AppTy (dataConType dc) (map atomType args)-exprType (FunApp fun args) = foldl AppTy (varType fun)    (map atomType args)-exprType (Let _ expr)      = exprType expr-exprType (Case _ _ (a:_))  = altType a-exprType _                 = Bottom-
+ src/SSTG/Core/Syntax/Typing.hs view
@@ -0,0 +1,53 @@+-- | Typing Module+module SSTG.Core.Syntax.Typing+    ( module SSTG.Core.Syntax.Typing+    ) where++import SSTG.Core.Syntax.Language++-- | Variable type.+varType :: Var -> Type+varType (Var _ ty) = ty++-- | Literal type.+litType :: Lit -> Type+litType (MachChar _ ty)      = ty+litType (MachStr _ ty)       = ty+litType (MachInt _ ty)       = ty+litType (MachWord _ ty)      = ty+litType (MachFloat _ ty)     = ty+litType (MachDouble _ ty)    = ty+litType (MachNullAddr ty)    = ty+litType (MachLabel _ _ ty)   = ty+litType (BlankAddr)          = Bottom+litType (AddrLit _)          = Bottom+litType (SymLit var)         = varType var+litType (SymLitEval pf args) = foldl AppTy (primFunType pf) (map litType args)++-- | Atom type.+atomType :: Atom -> Type+atomType (VarAtom var) = varType var+atomType (LitAtom lit) = litType lit++-- | Primitive function type.+primFunType :: PrimFun -> Type+primFunType (PrimFun _ ty) = ty++-- | Data constructor type denoted as a function.+dataConType :: DataCon -> Type+dataConType (DataCon _ ty tys) = foldr FunTy ty tys++-- | Alt type+altType :: Alt -> Type+altType (Alt _ _ expr) = exprType expr++-- | I wonder what this could possibly be?+exprType :: Expr -> Type+exprType (Atom atom)       = atomType atom+exprType (PrimApp pf args) = foldl AppTy (primFunType pf) (map atomType args)+exprType (ConApp dc args)  = foldl AppTy (dataConType dc) (map atomType args)+exprType (FunApp fun args) = foldl AppTy (varType fun)    (map atomType args)+exprType (Let _ expr)      = exprType expr+exprType (Case _ _ (a:_))  = altType a+exprType _                 = Bottom+
src/SSTG/Utils/FileIO.hs view
@@ -5,8 +5,8 @@     , writePrettyState     ) where -import SSTG.Core.Execution.Models import SSTG.Core.Execution.Stepping+import SSTG.Core.Execution.Support import SSTG.Utils.Printing  import Text.Read