Copyright | Brent Yorgey |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Values and environments used for interpreting the Swarm language.
Synopsis
- data Value where
- VUnit :: Value
- VInt :: Integer -> Value
- VText :: Text -> Value
- VDir :: Direction -> Value
- VBool :: Bool -> Value
- VRobot :: Int -> Value
- VInj :: Bool -> Value -> Value
- VPair :: Value -> Value -> Value
- VClo :: Var -> Term -> Env -> Value
- VCApp :: Const -> [Value] -> Value
- VDef :: Bool -> Var -> Term -> Env -> Value
- VResult :: Value -> Env -> Value
- VBind :: Maybe Var -> Term -> Term -> Env -> Value
- VDelay :: Term -> Env -> Value
- VRef :: Int -> Value
- prettyValue :: Value -> Text
- valueToTerm :: Value -> Term
- type Env = Ctx Value
Values
A value is a term that cannot (or does not) take any more evaluation steps on its own.
VUnit :: Value | The unit value. |
VInt :: Integer -> Value | An integer. |
VText :: Text -> Value | Literal text. |
VDir :: Direction -> Value | A direction. |
VBool :: Bool -> Value | A boolean. |
VRobot :: Int -> Value | A reference to a robot. |
VInj :: Bool -> Value -> Value | An injection into a sum type. False = left, True = right. |
VPair :: Value -> Value -> Value | A pair. |
VClo :: Var -> Term -> Env -> Value | A closure, representing a lambda term along with an environment containing bindings for any free variables in the body of the lambda. |
VCApp :: Const -> [Value] -> Value | An application of a constant to some value arguments,
potentially waiting for more arguments. If a constant
application is fully saturated (as defined by its |
VDef :: Bool -> Var -> Term -> Env -> Value | A definition, which does not take effect until executed.
The |
VResult :: Value -> Env -> Value | The result of a command, consisting of the result of the
command as well as an environment of bindings from |
VBind :: Maybe Var -> Term -> Term -> Env -> Value | An unevaluated bind expression, waiting to be executed, of the
form i.e. |
VDelay :: Term -> Env -> Value | A (non-recursive) delayed term, along with its environment. If
a term would otherwise be evaluated but we don't want it to be
(e.g. as in the case of arguments to an 'if', or a recursive
binding), we can stick a |
VRef :: Int -> Value | A reference to a memory cell in the store. |
Instances
prettyValue :: Value -> Text Source #
Pretty-print a value.
valueToTerm :: Value -> Term Source #
Inject a value back into a term.