Safe Haskell | None |
---|---|
Language | Haskell2010 |
Convert Haskell values to STG values and back.
This module is what users should be using - it reexports only the safe classes.
- class ToStg value where
- class FromStg value where
- fromStg :: StgState -> Var -> Either FromStgError value
- data FromStgError
Documentation
class ToStg value where Source
Convert a Haskell value to an STG binding.
Instances of this class should have a corresponding FromStg
instance to
retrieve a value fom the program, with the two being inverse to each other
(up to forcing the generated thunks).
This class contains a helper function, toStgWithGlobals
, this is hidden
from the outside. If you want to write your own instance, have a look at the
source for documentation.
ToStg Bool Source |
|
ToStg Int Source | Same as the |
ToStg Integer Source |
|
ToStg () Source |
|
ToStg a => ToStg [a] Source |
|
ToStg a => ToStg (Maybe a) Source |
|
(ToStg a, ToStg b) => ToStg (Either a b) Source |
|
(ToStg a, ToStg b) => ToStg (a, b) Source |
|
(ToStg a, ToStg b, ToStg c) => ToStg (a, b, c) Source |
|
(ToStg a, ToStg b, ToStg c, ToStg d) => ToStg (a, b, c, d) Source |
|
(ToStg a, ToStg b, ToStg c, ToStg d, ToStg e) => ToStg (a, b, c, d, e) Source |
|
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).
:: StgState | |
-> Var | Name of the global, e.g. |
-> Either FromStgError value |
Retrieve the value of a global variable.
FromStg Bool Source | |
FromStg Integer Source | Boxed ( |
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
TypeMismatch | e.g. asking for an |
IsWrongLambdaType LambdaType | Tried retrieving a non-constructor |
IsBlackhole | Tried retrieving a black hole |
BadArity | e.g. |
NotFound NotInScope | An unsuccessful variable lookup |
AddrNotOnHeap | |
NoConstructorMatch | None of the given alternatives matched the given
constructor, e.g. when trying to receive a |