Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Recalc.Repl
Description
Provides a few utilities to experiment with the core language to examine outcomes of parsing, type checking and inference, evaluation and sheet recomputation.
Only the recalculation family of operations implements cell
references (only single sheeted - assumes that the current
URI
is "file://repl.rc"
, and the current SheetName
is
"Test"
).
For an example usage of this module, refer to Recalc.EngineSpec.
Synopsis
- type Result e = Either (FetchError e)
- parseFormula :: Recalc t => String -> Result (ErrorOf t) t
- parseValue :: Recalc t => String -> Result (ErrorOf t) t
- infer :: forall t. Recalc t => EnvOf t -> t -> Result (ErrorOf t) (TypeOf t)
- eval :: forall t. Recalc t => EnvOf t -> ElaborationOf t -> Result (ErrorOf t) (ValueOf t)
- newEngineState :: EnvOf t -> EngineStateOf t
- recalc :: (Recalc t, Show (ErrorOf t)) => [(CellAddr, Maybe String)] -> EngineStateOf t -> (ResultsOf t, EngineStateOf t)
- evalRecalc :: (Recalc t, Show (ErrorOf t)) => [(CellAddr, Maybe String)] -> EngineStateOf t -> ResultsOf t
- execRecalc :: (Recalc t, Show (ErrorOf t)) => [(CellAddr, Maybe String)] -> EngineStateOf t -> EngineStateOf t
- pretty :: Pretty a => a -> Doc ann
Documentation
type Result e = Either (FetchError e) Source #
Parsing
parseFormula :: Recalc t => String -> Result (ErrorOf t) t Source #
parse a formula using the specified parser
parseValue :: Recalc t => String -> Result (ErrorOf t) t Source #
parse a value using the specified parser
Type Inference & Evaluation
Arguments
:: forall t. Recalc t | |
=> EnvOf t | custom context as specified |
-> t | term to infer type from |
-> Result (ErrorOf t) (TypeOf t) | either a type error or the inferred type |
infer the type of a term under a certain context (cell references not
supported, use recalc
instead)
Arguments
:: forall t. Recalc t | |
=> EnvOf t | custom context as specified |
-> ElaborationOf t | term to evaluate |
-> Result (ErrorOf t) (ValueOf t) |
evaluate a term (cell references not supported, use recalc
instead)
Spreadshheet Recalculation
newEngineState :: EnvOf t -> EngineStateOf t Source #
create a new engine state, initialising the custom context
Arguments
:: (Recalc t, Show (ErrorOf t)) | |
=> [(CellAddr, Maybe String)] | a list of inputs ( |
-> EngineStateOf t | the current engine state |
-> (ResultsOf t, EngineStateOf t) | all changed cells and their values, and the new engine state |
recalculate a spreadsheet from new inputs and a engine state (see
newEngineState
to create a new one)
evalRecalc :: (Recalc t, Show (ErrorOf t)) => [(CellAddr, Maybe String)] -> EngineStateOf t -> ResultsOf t Source #
same as recalc
but only returns the results
execRecalc :: (Recalc t, Show (ErrorOf t)) => [(CellAddr, Maybe String)] -> EngineStateOf t -> EngineStateOf t Source #
same as recalc
but only returns the new engine state