egison-5.0.0: Programming language with non-linear pattern-matching against non-free data
LicenseMIT
Safe HaskellNone
LanguageGHC2021

Language.Egison.Data

Description

This module contains definitions for Egison internal data.

Synopsis

Egison values

data EgisonValue Source #

class EgisonData a where Source #

Instances

Instances details
EgisonData Handle Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Rational Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Text Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Integer Source # 
Instance details

Defined in Language.Egison.Data

EgisonData () Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Bool Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Char Source # 
Instance details

Defined in Language.Egison.Data

EgisonData Double Source # 
Instance details

Defined in Language.Egison.Data

EgisonData (IORef EgisonValue) Source # 
Instance details

Defined in Language.Egison.Data

EgisonData a => EgisonData [a] Source # 
Instance details

Defined in Language.Egison.Data

(EgisonData a, EgisonData b) => EgisonData (a, b) Source # 
Instance details

Defined in Language.Egison.Data

Methods

toEgison :: (a, b) -> EgisonValue Source #

fromEgison :: EgisonValue -> EvalM (a, b) Source #

(EgisonData a, EgisonData b, EgisonData c) => EgisonData (a, b, c) Source # 
Instance details

Defined in Language.Egison.Data

Methods

toEgison :: (a, b, c) -> EgisonValue Source #

fromEgison :: EgisonValue -> EvalM (a, b, c) Source #

(EgisonData a, EgisonData b, EgisonData c, EgisonData d) => EgisonData (a, b, c, d) Source # 
Instance details

Defined in Language.Egison.Data

Methods

toEgison :: (a, b, c, d) -> EgisonValue Source #

fromEgison :: EgisonValue -> EvalM (a, b, c, d) Source #

data Tensor a Source #

Constructors

Tensor Shape (Vector a) [Index EgisonValue] 
Scalar a 

Instances

Instances details
Show a => Show (Tensor a) Source # 
Instance details

Defined in Language.Egison.Data

Methods

showsPrec :: Int -> Tensor a -> ShowS #

show :: Tensor a -> String #

showList :: [Tensor a] -> ShowS #

ToMathExpr a => ToMathExpr (Tensor a) Source # 
Instance details

Defined in Language.Egison.PrettyMath.AST

Scalar

Internal data

data Object Source #

Constructors

Thunk (EvalM WHNFData) 
WHNF WHNFData 

Instances

Instances details
Show Object Source # 
Instance details

Defined in Language.Egison.Data

Show ObjectRef Source # 
Instance details

Defined in Language.Egison.Data

TensorComponent WHNFData ObjectRef Source # 
Instance details

Defined in Language.Egison.Tensor

type ObjectRef = IORef Object Source #

For memoization

Environment

data Env Source #

Environment: list of layers (for scoping) plus optional index context, plus a separate store for pattern functions.

type EnvLayer = Map String [VarEntry ObjectRef] Source #

Environment layer: maps base variable names to all bindings with that name VarEntry list is sorted by index length (shortest first) for efficient prefix matching

type PatFuncEnv = Map String ObjectRef Source #

Pattern function environment: maps pattern function names to their ObjectRefs. Kept separate from the regular value environment so that pattern typing is independent of which matcher is in scope (matcher polymorphism).

extendEnv :: Env -> [Binding] -> Env Source #

Extend environment with new bindings Groups bindings by base name and sorts by index length (shortest first)

extendPatFuncEnv :: Env -> [(String, ObjectRef)] -> Env Source #

Extend the pattern function environment with new name→ref bindings. The regular value layers and index context are preserved unchanged.

refVar :: Env -> Var -> Maybe ObjectRef Source #

Look up a variable in the environment Search algorithm: 1. Try exact match 2. Try prefix match (find longer indices and auto-complete with #) 3. Try suffix removal (find shorter indices, pick longest match) No recursion is used; all matching is done in a single pass to avoid infinite loops.

refPatFunc :: Env -> String -> Maybe ObjectRef Source #

Look up a pattern function by name in the pattern function environment.

envToBindingList :: Env -> [Binding] Source #

Convert environment to list of bindings Used for completion and debugging

Errors

Monads

type EvalM = EvalT RuntimeM Source #

fromEvalTWithState :: EvalState -> EvalM a -> RuntimeM (Either EgisonError (a, EvalState)) Source #

Run EvalM with a given EvalState (for REPL to preserve state between evaluations)