evaluate package:code-conjure

O(n). Just the value of an expression when possible (correct type), Nothing otherwise. This does not catch errors from undefined Dynamic values.
> let one = val (1 :: Int)
> let bee = val 'b'
> let negateE = value "negate" (negate :: Int -> Int)
> evaluate one :: Maybe Int
Just 1
> evaluate one :: Maybe Char
Nothing
> evaluate bee :: Maybe Int
Nothing
> evaluate bee :: Maybe Char
Just 'b'
> evaluate $ negateE :$ one :: Maybe Int
Just (-1)
> evaluate $ negateE :$ bee :: Maybe Int
Nothing
Evaluates a Defn into a regular Haskell value returning Nothing when there's a type mismatch. The integer argument indicates the limit of recursive evaluations.
Evaluates an Expr expression into Just a regular Haskell value using a Defn definition when it is found. If there's a type-mismatch, this function returns Nothing. This function requires a Expr-deep-reencoding function and a limit to the number of recursive evaluations. (cf. toDynamicWithDefn, deval, devl)
Checks if the given functional expression may refrain from evaluating its next argument.
> mayNotEvaluateArgument (plus :$ xx)
False
> mayNotEvaluateArgument (andE :$ pp)
True
This returns false for non-funcional value even if it involves an application which may not evaluate its argument.
> mayNotEvaluateArgument (andE :$ pp :$ qq)
False
This currently works by checking if the function is an if, && or ||.
Evaluates an Expr to a regular Haskell value using the given recursive definition and maximum number of recursive calls. If there's a type mismatch, this function returns Nothing. (cf. evaluate, devaluate)