stgi-1.0.1: Educational implementation of the STG (Spineless Tagless G-machine)

Safe HaskellNone
LanguageHaskell2010

Stg.Marshal.FromStg

Description

Extract Haskell values from running STG programs.

Synopsis

Documentation

class FromStg value where Source

Look up the value of a global variable.

Instances of this class should have a corresponding ToStg instance to inject a value into the program, with the two being inverse to each other (up to forcing the generated thunks).

Minimal complete definition

fromStgAddr

Methods

fromStg Source

Arguments

:: StgState 
-> Var

Name of the global, e.g. main

-> Either FromStgError value 

Retrieve the value of a global variable.

fromStgAddr :: StgState -> MemAddr -> Either FromStgError value Source

Retrieve the value of a heap address.

fromStgPrim :: Integer -> Either FromStgError value Source

Used only for looking up primitive integers.

Instances

FromStg Bool Source 
FromStg Integer Source

Boxed (Int# 1#) or unboxed (1#)

FromStg () Source 
FromStg a => FromStg [a] Source 
FromStg a => FromStg (Maybe a) Source 
(FromStg a, FromStg b) => FromStg (Either a b) Source 
(FromStg a, FromStg b) => FromStg (a, b) Source 
(FromStg a, FromStg b, FromStg c) => FromStg (a, b, c) Source 
(FromStg a, FromStg b, FromStg c, FromStg d) => FromStg (a, b, c, d) Source 
(FromStg a, FromStg b, FromStg c, FromStg d, FromStg e) => FromStg (a, b, c, d, e) Source 

data FromStgError Source

Constructors

TypeMismatch

e.g. asking for an Int# at an address that contains a Cons

IsWrongLambdaType LambdaType

Tried retrieving a non-constructor

IsBlackhole

Tried retrieving a black hole

BadArity

e.g. Cons x y z

NotFound NotInScope

An unsuccessful variable lookup

AddrNotOnHeap 
NoConstructorMatch

None of the given alternatives matched the given constructor, e.g. when trying to receive a Left as a Just