Copyright | Satoshi Egi |
---|---|
License | MIT |
Safe Haskell | None |
Language | Haskell98 |
This module contains type definitions of Egison Data.
- data EgisonTopExpr
- data EgisonExpr
- = CharExpr Char
- | StringExpr Text
- | BoolExpr Bool
- | IntegerExpr Integer
- | FloatExpr Double Double
- | VarExpr String
- | FreshVarExpr
- | IndexedExpr Bool EgisonExpr [Index EgisonExpr]
- | SubrefsExpr EgisonExpr EgisonExpr
- | SuprefsExpr EgisonExpr EgisonExpr
- | UserIndexedExpr EgisonExpr [UserIndex EgisonExpr]
- | PowerExpr EgisonExpr EgisonExpr
- | InductiveDataExpr String [EgisonExpr]
- | TupleExpr [EgisonExpr]
- | CollectionExpr [InnerExpr]
- | ArrayExpr [EgisonExpr]
- | HashExpr [(EgisonExpr, EgisonExpr)]
- | VectorExpr [EgisonExpr]
- | LambdaExpr [Arg] EgisonExpr
- | MemoizedLambdaExpr [String] EgisonExpr
- | MemoizeExpr [(EgisonExpr, EgisonExpr, EgisonExpr)] EgisonExpr
- | CambdaExpr String EgisonExpr
- | ProcedureExpr [String] EgisonExpr
- | MacroExpr [String] EgisonExpr
- | PatternFunctionExpr [String] EgisonPattern
- | IfExpr EgisonExpr EgisonExpr EgisonExpr
- | LetRecExpr [BindingExpr] EgisonExpr
- | LetExpr [BindingExpr] EgisonExpr
- | LetStarExpr [BindingExpr] EgisonExpr
- | WithSymbolsExpr [String] EgisonExpr
- | MatchExpr EgisonExpr EgisonExpr [MatchClause]
- | MatchAllExpr EgisonExpr EgisonExpr MatchClause
- | MatchLambdaExpr EgisonExpr [MatchClause]
- | MatchAllLambdaExpr EgisonExpr MatchClause
- | NextMatchExpr EgisonExpr EgisonExpr [MatchClause]
- | NextMatchAllExpr EgisonExpr EgisonExpr MatchClause
- | NextMatchLambdaExpr EgisonExpr [MatchClause]
- | NextMatchAllLambdaExpr EgisonExpr MatchClause
- | MatcherBFSExpr MatcherInfo
- | MatcherDFSExpr MatcherInfo
- | AlgebraicDataMatcherExpr [(String, [EgisonExpr])]
- | QuoteExpr EgisonExpr
- | QuoteFunctionExpr EgisonExpr
- | WedgeExpr EgisonExpr
- | WedgeApplyExpr EgisonExpr EgisonExpr
- | DoExpr [BindingExpr] EgisonExpr
- | IoExpr EgisonExpr
- | SeqExpr EgisonExpr EgisonExpr
- | ApplyExpr EgisonExpr EgisonExpr
- | CApplyExpr EgisonExpr EgisonExpr
- | PartialExpr Integer EgisonExpr
- | PartialVarExpr Integer
- | RecVarExpr
- | GenerateArrayExpr EgisonExpr (EgisonExpr, EgisonExpr)
- | ArrayBoundsExpr EgisonExpr
- | ArrayRefExpr EgisonExpr EgisonExpr
- | ParExpr EgisonExpr EgisonExpr
- | PseqExpr EgisonExpr EgisonExpr
- | PmapExpr EgisonExpr EgisonExpr
- | GenerateTensorExpr EgisonExpr EgisonExpr
- | TensorExpr EgisonExpr EgisonExpr EgisonExpr EgisonExpr
- | TensorContractExpr EgisonExpr EgisonExpr
- | TensorMapExpr EgisonExpr EgisonExpr
- | TensorMap2Expr EgisonExpr EgisonExpr EgisonExpr
- | TransposeExpr EgisonExpr EgisonExpr
- | FlipIndicesExpr EgisonExpr
- | SomethingExpr
- | UndefinedExpr
- data EgisonPattern
- = WildCard
- | PatVar String
- | ValuePat EgisonExpr
- | PredPat EgisonExpr
- | IndexedPat EgisonPattern [EgisonExpr]
- | LetPat [BindingExpr] EgisonPattern
- | NotPat EgisonPattern
- | AndPat [EgisonPattern]
- | OrPat [EgisonPattern]
- | OrderedOrPat [EgisonPattern]
- | TuplePat [EgisonPattern]
- | InductivePat String [EgisonPattern]
- | LoopPat String LoopRange EgisonPattern EgisonPattern
- | ContPat
- | PApplyPat EgisonExpr [EgisonPattern]
- | VarPat String
- | DApplyPat EgisonPattern [EgisonPattern]
- | DivPat EgisonPattern EgisonPattern
- | PlusPat [EgisonPattern]
- | MultPat [EgisonPattern]
- | PowerPat EgisonPattern EgisonPattern
- data Arg
- data Index a
- = Subscript a
- | Superscript a
- | SupSubscript a
- | DFscript Integer Integer
- data UserIndex a = Userscript a
- data InnerExpr
- type BindingExpr = ([String], EgisonExpr)
- type MatchClause = (EgisonPattern, EgisonExpr)
- type MatcherInfo = [(PrimitivePatPattern, EgisonExpr, [(PrimitiveDataPattern, EgisonExpr)])]
- data LoopRange = LoopRange EgisonExpr EgisonExpr EgisonPattern
- data PrimitivePatPattern
- data PrimitiveDataPattern
- type Matcher = EgisonValue
- type PrimitiveFunc = WHNFData -> EgisonM WHNFData
- class EgisonData a where
- showTSV :: EgisonValue -> String
- data EgisonValue
- = World
- | Char Char
- | String Text
- | Bool Bool
- | ScalarData ScalarData
- | TensorData (Tensor EgisonValue)
- | UserIndexedData EgisonValue [UserIndex EgisonValue]
- | Float Double Double
- | InductiveData String [EgisonValue]
- | Tuple [EgisonValue]
- | Collection (Seq EgisonValue)
- | Array (Array Integer EgisonValue)
- | IntHash (HashMap Integer EgisonValue)
- | CharHash (HashMap Char EgisonValue)
- | StrHash (HashMap Text EgisonValue)
- | UserMatcher Env PMMode MatcherInfo
- | Func (Maybe String) Env [String] EgisonExpr
- | PartialFunc Env Integer EgisonExpr
- | CFunc (Maybe String) Env String EgisonExpr
- | MemoizedFunc (Maybe String) ObjectRef (IORef (HashMap [Integer] ObjectRef)) Env [String] EgisonExpr
- | Proc (Maybe String) Env [String] EgisonExpr
- | Macro [String] EgisonExpr
- | PatternFunc Env [String] EgisonPattern
- | PrimitiveFunc String PrimitiveFunc
- | IOFunc (EgisonM WHNFData)
- | QuotedFunc EgisonValue
- | Port Handle
- | Something
- | Undefined
- | EOF
- data ScalarData = Div PolyExpr PolyExpr
- data PolyExpr = Plus [TermExpr]
- data TermExpr = Term Integer [(SymbolExpr, Integer)]
- data SymbolExpr
- data Tensor a
- class HasTensor a where
- initTensor :: [Integer] -> [a] -> [EgisonValue] -> [EgisonValue] -> Tensor a
- tSize :: Tensor a -> [Integer]
- tToList :: Tensor a -> [a]
- tIndex :: Tensor a -> [Index EgisonValue]
- tref :: HasTensor a => [Index EgisonValue] -> Tensor a -> EgisonM a
- enumTensorIndices :: [Integer] -> [[Integer]]
- tTranspose :: HasTensor a => [Index EgisonValue] -> Tensor a -> EgisonM (Tensor a)
- tTranspose' :: HasTensor a => [EgisonValue] -> Tensor a -> EgisonM (Tensor a)
- tFlipIndices :: HasTensor a => Tensor a -> EgisonM (Tensor a)
- appendDFscripts :: Integer -> WHNFData -> EgisonM WHNFData
- removeDFscripts :: WHNFData -> EgisonM WHNFData
- tMap :: HasTensor a => (a -> EgisonM a) -> Tensor a -> EgisonM (Tensor a)
- tMap2 :: HasTensor a => (a -> a -> EgisonM a) -> Tensor a -> Tensor a -> EgisonM (Tensor a)
- tMapN :: HasTensor a => ([a] -> EgisonM a) -> [Tensor a] -> EgisonM (Tensor a)
- tSum :: HasTensor a => (a -> a -> EgisonM a) -> Tensor a -> Tensor a -> EgisonM (Tensor a)
- tProduct :: HasTensor a => (a -> a -> EgisonM a) -> Tensor a -> Tensor a -> EgisonM (Tensor a)
- tContract :: HasTensor a => Tensor a -> EgisonM [Tensor a]
- tContract' :: HasTensor a => Tensor a -> EgisonM (Tensor a)
- tConcat :: HasTensor a => Index EgisonValue -> [Tensor a] -> EgisonM (Tensor a)
- tConcat' :: HasTensor a => [Tensor a] -> EgisonM (Tensor a)
- symbolScalarData :: String -> String -> EgisonValue
- mathExprToEgison :: ScalarData -> EgisonValue
- egisonToScalarData :: EgisonValue -> EgisonM ScalarData
- mathNormalize' :: ScalarData -> ScalarData
- mathFold :: ScalarData -> ScalarData
- mathSymbolFold :: ScalarData -> ScalarData
- mathTermFold :: ScalarData -> ScalarData
- mathRemoveZero :: ScalarData -> ScalarData
- mathDivide :: ScalarData -> ScalarData
- mathPlus :: ScalarData -> ScalarData -> ScalarData
- mathMult :: ScalarData -> ScalarData -> ScalarData
- mathNegate :: ScalarData -> ScalarData
- mathNumerator :: ScalarData -> ScalarData
- mathDenominator :: ScalarData -> ScalarData
- extractScalar :: EgisonValue -> EgisonM ScalarData
- extractScalar' :: WHNFData -> EgisonM ScalarData
- data Object
- type ObjectRef = IORef Object
- data WHNFData
- data Intermediate
- data Inner
- class EgisonData a => EgisonWHNF a where
- data Env = Env [HashMap String ObjectRef]
- data Var = Var String [Index ()]
- data VarWithIndices = VarWithIndices String [Index String]
- type Binding = (String, ObjectRef)
- nullEnv :: Env
- extendEnv :: Env -> [Binding] -> Env
- refVar :: Env -> String -> Maybe ObjectRef
- type Match = [Binding]
- data PMMode
- pmMode :: Matcher -> PMMode
- data MatchingState = MState Env [LoopPatContext] [Binding] [MatchingTree]
- data MatchingTree
- type PatternBinding = (String, EgisonPattern)
- data LoopPatContext = LoopPatContext Binding ObjectRef EgisonPattern EgisonPattern EgisonPattern
- data EgisonError
- = UnboundVariable String
- | TypeMismatch String WHNFData
- | ArgumentsNumWithNames [String] Int Int
- | ArgumentsNumPrimitive Int Int
- | ArgumentsNum Int Int
- | InconsistentTensorSize
- | InconsistentTensorIndex
- | TensorIndexOutOfBounds Integer Integer
- | NotImplemented String
- | Assertion String
- | Match String
- | Parser String
- | Desugar String
- | EgisonBug String
- | Default String
- liftError :: MonadError e m => Either e a -> m a
- newtype EgisonM a = EgisonM {
- unEgisonM :: ExceptT EgisonError (FreshT IO) a
- parallelMapM :: (a -> EgisonM b) -> [a] -> EgisonM [b]
- runEgisonM :: EgisonM a -> FreshT IO (Either EgisonError a)
- liftEgisonM :: Fresh (Either EgisonError a) -> EgisonM a
- fromEgisonM :: EgisonM a -> IO (Either EgisonError a)
- newtype FreshT m a = FreshT {}
- type Fresh = FreshT Identity
- class (Applicative m, Monad m) => MonadFresh m where
- runFreshT :: Monad m => (Int, Int) -> FreshT m a -> m (a, (Int, Int))
- type MatchM = MaybeT EgisonM
- matchFail :: MatchM a
- data MList m a
- fromList :: Monad m => [a] -> MList m a
- fromSeq :: Monad m => Seq a -> MList m a
- fromMList :: Monad m => MList m a -> m [a]
- msingleton :: Monad m => a -> MList m a
- mfoldr :: Monad m => (a -> m b -> m b) -> m b -> MList m a -> m b
- mappend :: Monad m => MList m a -> m (MList m a) -> m (MList m a)
- mconcat :: Monad m => MList m (MList m a) -> m (MList m a)
- mmap :: Monad m => (a -> m b) -> MList m a -> m (MList m b)
- mfor :: Monad m => MList m a -> (a -> m b) -> m (MList m b)
- isBool :: EgisonValue -> Bool
- isInteger :: EgisonValue -> Bool
- isRational :: EgisonValue -> Bool
- isSymbol :: EgisonValue -> Bool
- isScalar :: EgisonValue -> Bool
- isTensor :: EgisonValue -> Bool
- isTensorWithIndex :: EgisonValue -> Bool
- isBool' :: PrimitiveFunc
- isInteger' :: PrimitiveFunc
- isRational' :: PrimitiveFunc
- isScalar' :: PrimitiveFunc
- isFloat' :: PrimitiveFunc
- isComplex' :: PrimitiveFunc
- isTensor' :: PrimitiveFunc
- isTensorWithIndex' :: PrimitiveFunc
- isChar' :: PrimitiveFunc
- isString' :: PrimitiveFunc
- isCollection' :: PrimitiveFunc
- isArray' :: PrimitiveFunc
- isHash' :: PrimitiveFunc
- readUTF8File :: FilePath -> IO String
Egison expressions
data EgisonTopExpr Source #
data EgisonExpr Source #
data EgisonPattern Source #
type BindingExpr = ([String], EgisonExpr) Source #
type MatchClause = (EgisonPattern, EgisonExpr) Source #
type MatcherInfo = [(PrimitivePatPattern, EgisonExpr, [(PrimitiveDataPattern, EgisonExpr)])] Source #
data PrimitivePatPattern Source #
data PrimitiveDataPattern Source #
type Matcher = EgisonValue Source #
class EgisonData a where Source #
toEgison :: a -> EgisonValue Source #
fromEgison :: EgisonValue -> EgisonM a Source #
EgisonData Bool Source # | |
EgisonData Char Source # | |
EgisonData Double Source # | |
EgisonData Integer Source # | |
EgisonData Rational Source # | |
EgisonData () Source # | |
EgisonData Handle Source # | |
EgisonData Text Source # | |
EgisonData a => EgisonData [a] Source # | |
(EgisonData a, EgisonData b) => EgisonData (a, b) Source # | |
(EgisonData a, EgisonData b, EgisonData c) => EgisonData (a, b, c) Source # | |
(EgisonData a, EgisonData b, EgisonData c, EgisonData d) => EgisonData (a, b, c, d) Source # | |
showTSV :: EgisonValue -> String Source #
Egison values
data EgisonValue Source #
data ScalarData Source #
Term Integer [(SymbolExpr, Integer)] |
data SymbolExpr Source #
class HasTensor a where Source #
tensorElems :: a -> Vector a Source #
tensorSize :: a -> [Integer] Source #
tensorIndices :: a -> [Index EgisonValue] Source #
fromTensor :: Tensor a -> EgisonM a Source #
Tensor
initTensor :: [Integer] -> [a] -> [EgisonValue] -> [EgisonValue] -> Tensor a Source #
enumTensorIndices :: [Integer] -> [[Integer]] Source #
tTranspose :: HasTensor a => [Index EgisonValue] -> Tensor a -> EgisonM (Tensor a) Source #
tTranspose' :: HasTensor a => [EgisonValue] -> Tensor a -> EgisonM (Tensor a) Source #
tMap2 :: HasTensor a => (a -> a -> EgisonM a) -> Tensor a -> Tensor a -> EgisonM (Tensor a) Source #
tProduct :: HasTensor a => (a -> a -> EgisonM a) -> Tensor a -> Tensor a -> EgisonM (Tensor a) Source #
Scalar
symbolScalarData :: String -> String -> EgisonValue Source #
mathFold :: ScalarData -> ScalarData Source #
mathTermFold :: ScalarData -> ScalarData Source #
mathDivide :: ScalarData -> ScalarData Source #
mathPlus :: ScalarData -> ScalarData -> ScalarData Source #
mathMult :: ScalarData -> ScalarData -> ScalarData Source #
mathNegate :: ScalarData -> ScalarData Source #
mathNumerator :: ScalarData -> ScalarData Source #
Internal data
data Intermediate Source #
class EgisonData a => EgisonWHNF a where Source #
Environment
data VarWithIndices Source #
Pattern matching
data MatchingState Source #
data MatchingTree Source #
type PatternBinding = (String, EgisonPattern) Source #
data LoopPatContext Source #
Errors
data EgisonError Source #
liftError :: MonadError e m => Either e a -> m a Source #
Monads
parallelMapM :: (a -> EgisonM b) -> [a] -> EgisonM [b] Source #
runEgisonM :: EgisonM a -> FreshT IO (Either EgisonError a) Source #
liftEgisonM :: Fresh (Either EgisonError a) -> EgisonM a Source #
fromEgisonM :: EgisonM a -> IO (Either EgisonError a) Source #
MonadTrans FreshT Source # | |
MonadState s m => MonadState s (FreshT m) Source # | |
MonadError e m => MonadError e (FreshT m) Source # | |
Monad m => Monad (FreshT m) Source # | |
Functor m => Functor (FreshT m) Source # | |
Monad m => Applicative (FreshT m) Source # | |
MonadIO (FreshT IO) Source # | |
(Applicative m, Monad m) => MonadFresh (FreshT m) Source # | |
Monad m => MonadState (Int, Int) (FreshT m) Source # | |
class (Applicative m, Monad m) => MonadFresh m where Source #
MonadFresh EgisonM Source # | |
MonadFresh DesugarM Source # | |
(Applicative m, Monad m) => MonadFresh (FreshT m) Source # | |
MonadFresh m => MonadFresh (ExceptT e m) Source # | |
MonadFresh m => MonadFresh (StateT s m) Source # | |
(MonadFresh m, Monoid e) => MonadFresh (WriterT e m) Source # | |
(MonadFresh m, Monoid e) => MonadFresh (ReaderT * e m) Source # | |
msingleton :: Monad m => a -> MList m a Source #
Typing
isBool :: EgisonValue -> Bool Source #
isInteger :: EgisonValue -> Bool Source #
isRational :: EgisonValue -> Bool Source #
isSymbol :: EgisonValue -> Bool Source #
isScalar :: EgisonValue -> Bool Source #
isTensor :: EgisonValue -> Bool Source #
isTensorWithIndex :: EgisonValue -> Bool Source #