Copyright | Satoshi Egi |
---|---|
License | MIT |
Safe Haskell | None |
Language | Haskell98 |
This module contains type definitions of Egison Data.
Synopsis
- data EgisonValue
- = World
- | Char Char
- | String Text
- | Bool Bool
- | ScalarData ScalarData
- | TensorData (Tensor EgisonValue)
- | Float 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 [PatternDef]
- | Func (Maybe Var) Env [String] EgisonExpr
- | PartialFunc Env Integer EgisonExpr
- | CFunc (Maybe Var) Env String EgisonExpr
- | MemoizedFunc (Maybe Var) ObjectRef (IORef (HashMap [Integer] ObjectRef)) Env [String] EgisonExpr
- | Proc (Maybe String) Env [String] EgisonExpr
- | PatternFunc Env [String] EgisonPattern
- | PrimitiveFunc String PrimitiveFunc
- | IOFunc (EgisonM WHNFData)
- | Port Handle
- | Something
- | Undefined
- | EOF
- type Matcher = EgisonValue
- type PrimitiveFunc = WHNFData -> EgisonM WHNFData
- data EgisonHashKey
- class EgisonData a where
- toEgison :: a -> EgisonValue
- fromEgison :: EgisonValue -> EgisonM a
- data Tensor a
- class HasTensor a where
- tensorElems :: a -> Vector a
- tensorSize :: a -> [Integer]
- tensorIndices :: a -> [Index EgisonValue]
- fromTensor :: Tensor a -> EgisonM a
- toTensor :: a -> EgisonM (Tensor a)
- undef :: a
- symbolScalarData :: String -> String -> EgisonValue
- symbolScalarData' :: String -> String -> ScalarData
- getSymId :: EgisonValue -> String
- getSymName :: EgisonValue -> String
- mathExprToEgison :: ScalarData -> EgisonValue
- egisonToScalarData :: EgisonValue -> EgisonM 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 Var ObjectRef] (Maybe VarWithIndices)
- type Binding = (Var, ObjectRef)
- nullEnv :: Env
- extendEnv :: Env -> [Binding] -> Env
- refVar :: Env -> Var -> Maybe ObjectRef
- type Match = [Binding]
- data MatchingTree
- data MatchingState = MState {
- mStateEnv :: Env
- loopPatCtx :: [LoopPatContext]
- seqPatCtx :: [SeqPatContext]
- mStateBindings :: [Binding]
- mTrees :: [MatchingTree]
- type PatternBinding = (String, EgisonPattern)
- data LoopPatContext = LoopPatContext Binding ObjectRef EgisonPattern EgisonPattern EgisonPattern
- data SeqPatContext = SeqPatContext [MatchingTree] EgisonPattern [Matcher] [WHNFData]
- data EgisonError
- = UnboundVariable String CallStack
- | TypeMismatch String WHNFData CallStack
- | ArgumentsNumWithNames [String] Int Int CallStack
- | ArgumentsNumPrimitive Int Int CallStack
- | TupleLength Int Int CallStack
- | InconsistentTensorSize CallStack
- | InconsistentTensorIndex CallStack
- | TensorIndexOutOfBounds Integer Integer CallStack
- | NotImplemented String CallStack
- | Assertion String CallStack
- | Parser String
- | EgisonBug String CallStack
- | MatchFailure String CallStack
- | Default String
- liftError :: MonadError e m => Either e a -> m a
- newtype EgisonM a = EgisonM {
- unEgisonM :: ExceptT EgisonError (FreshT IO) a
- 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
- fresh :: m String
- freshV :: m Var
- pushFuncName :: String -> m ()
- topFuncName :: m String
- popFuncName :: m ()
- getFuncNameStack :: m [String]
- runFreshT :: Monad m => RuntimeState -> FreshT m a -> m (a, RuntimeState)
- 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
Egison values
data EgisonValue Source #
Instances
Eq EgisonValue Source # | |
Defined in Language.Egison.Types (==) :: EgisonValue -> EgisonValue -> Bool # (/=) :: EgisonValue -> EgisonValue -> Bool # | |
Show EgisonValue Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> EgisonValue -> ShowS # show :: EgisonValue -> String # showList :: [EgisonValue] -> ShowS # | |
HasTensor EgisonValue Source # | |
Defined in Language.Egison.Types tensorElems :: EgisonValue -> Vector EgisonValue Source # tensorSize :: EgisonValue -> [Integer] Source # tensorIndices :: EgisonValue -> [Index EgisonValue] Source # fromTensor :: Tensor EgisonValue -> EgisonM EgisonValue Source # toTensor :: EgisonValue -> EgisonM (Tensor EgisonValue) Source # undef :: EgisonValue Source # | |
PrettyS EgisonValue Source # | |
Defined in Language.Egison.Pretty prettyS :: EgisonValue -> String Source # | |
Show (Index EgisonValue) Source # | |
Defined in Language.Egison.Types | |
PrettyS (Index EgisonValue) Source # | |
Defined in Language.Egison.Pretty |
type Matcher = EgisonValue Source #
class EgisonData a where Source #
toEgison :: a -> EgisonValue Source #
fromEgison :: EgisonValue -> EgisonM a Source #
Instances
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 #
Instances
HasTensor WHNFData Source # | |
Defined in Language.Egison.Types | |
HasTensor EgisonValue Source # | |
Defined in Language.Egison.Types tensorElems :: EgisonValue -> Vector EgisonValue Source # tensorSize :: EgisonValue -> [Integer] Source # tensorIndices :: EgisonValue -> [Index EgisonValue] Source # fromTensor :: Tensor EgisonValue -> EgisonM EgisonValue Source # toTensor :: EgisonValue -> EgisonM (Tensor EgisonValue) Source # undef :: EgisonValue Source # |
Scalar
symbolScalarData :: String -> String -> EgisonValue Source #
symbolScalarData' :: String -> String -> ScalarData Source #
getSymId :: EgisonValue -> String Source #
getSymName :: EgisonValue -> String Source #
Internal data
data Intermediate Source #
class EgisonData a => EgisonWHNF a where Source #
Environment
Pattern matching
data MatchingTree Source #
Instances
Show MatchingTree Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> MatchingTree -> ShowS # show :: MatchingTree -> String # showList :: [MatchingTree] -> ShowS # |
data MatchingState Source #
MState | |
|
Instances
Show MatchingState Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> MatchingState -> ShowS # show :: MatchingState -> String # showList :: [MatchingState] -> ShowS # |
type PatternBinding = (String, EgisonPattern) Source #
data LoopPatContext Source #
Instances
Show LoopPatContext Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> LoopPatContext -> ShowS # show :: LoopPatContext -> String # showList :: [LoopPatContext] -> ShowS # |
data SeqPatContext Source #
Instances
Show SeqPatContext Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> SeqPatContext -> ShowS # show :: SeqPatContext -> String # showList :: [SeqPatContext] -> ShowS # |
Errors
data EgisonError Source #
UnboundVariable String CallStack | |
TypeMismatch String WHNFData CallStack | |
ArgumentsNumWithNames [String] Int Int CallStack | |
ArgumentsNumPrimitive Int Int CallStack | |
TupleLength Int Int CallStack | |
InconsistentTensorSize CallStack | |
InconsistentTensorIndex CallStack | |
TensorIndexOutOfBounds Integer Integer CallStack | |
NotImplemented String CallStack | |
Assertion String CallStack | |
Parser String | |
EgisonBug String CallStack | |
MatchFailure String CallStack | |
Default String |
Instances
Show EgisonError Source # | |
Defined in Language.Egison.Types showsPrec :: Int -> EgisonError -> ShowS # show :: EgisonError -> String # showList :: [EgisonError] -> ShowS # | |
Exception EgisonError Source # | |
Defined in Language.Egison.Types | |
MonadError EgisonError EgisonM Source # | |
Defined in Language.Egison.Types throwError :: EgisonError -> EgisonM a # catchError :: EgisonM a -> (EgisonError -> EgisonM a) -> EgisonM a # |
liftError :: MonadError e m => Either e a -> m a Source #
Monads
Instances
Monad EgisonM Source # | |
Functor EgisonM Source # | |
MonadFail EgisonM Source # | |
Defined in Language.Egison.Types | |
Applicative EgisonM Source # | |
MonadIO EgisonM Source # | |
Defined in Language.Egison.Types | |
MonadFresh EgisonM Source # | |
MonadError EgisonError EgisonM Source # | |
Defined in Language.Egison.Types throwError :: EgisonError -> EgisonM a # catchError :: EgisonM a -> (EgisonError -> EgisonM a) -> EgisonM a # |
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 #
Instances
MonadTrans FreshT Source # | |
Defined in Language.Egison.Types | |
MonadState s m => MonadState s (FreshT m) Source # | |
MonadError e m => MonadError e (FreshT m) Source # | |
Defined in Language.Egison.Types throwError :: e -> FreshT m a # catchError :: FreshT m a -> (e -> FreshT m a) -> FreshT m a # | |
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 # | |
class (Applicative m, Monad m) => MonadFresh m where Source #
pushFuncName :: String -> m () Source #
topFuncName :: m String Source #
popFuncName :: m () Source #
getFuncNameStack :: m [String] Source #
Instances
MonadFresh EgisonM 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 #