| License | MIT |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Language.Egison.IExpr
Description
This module defines internal representation of Egison language.
Synopsis
- data ITopExpr
- data IExpr
- = IConstantExpr ConstantExpr
- | IVarExpr String
- | IIndexedExpr Bool IExpr [Index IExpr]
- | ISubrefsExpr Bool IExpr IExpr
- | ISuprefsExpr Bool IExpr IExpr
- | IUserrefsExpr Bool IExpr IExpr
- | IInductiveDataExpr String [IExpr]
- | ITupleExpr [IExpr]
- | ICollectionExpr [IExpr]
- | IConsExpr IExpr IExpr
- | IJoinExpr IExpr IExpr
- | IHashExpr [(IExpr, IExpr)]
- | IVectorExpr [IExpr]
- | ILambdaExpr (Maybe Var) [Var] IExpr
- | IMemoizedLambdaExpr [String] IExpr
- | ICambdaExpr String IExpr
- | IIfExpr IExpr IExpr IExpr
- | ILetRecExpr [IBindingExpr] IExpr
- | ILetExpr [IBindingExpr] IExpr
- | IWithSymbolsExpr [String] IExpr
- | IMatchExpr PMMode IExpr IExpr [IMatchClause]
- | IMatchAllExpr PMMode IExpr IExpr [IMatchClause]
- | IMatcherExpr [IPatternDef]
- | IQuoteExpr IExpr
- | IQuoteSymbolExpr IExpr
- | IWedgeApplyExpr IExpr [IExpr]
- | IDoExpr [IBindingExpr] IExpr
- | ISeqExpr IExpr IExpr
- | IApplyExpr IExpr [IExpr]
- | IGenerateTensorExpr IExpr IExpr
- | ITensorExpr IExpr IExpr
- | ITensorContractExpr IExpr
- | ITensorMapExpr IExpr IExpr
- | ITensorMap2Expr IExpr IExpr IExpr
- | ITensorMap2WedgeExpr IExpr IExpr IExpr
- | ITransposeExpr IExpr IExpr
- | IFlipIndicesExpr IExpr
- | IFunctionExpr [String]
- | IPatternFuncExpr [String] IPattern
- data IPattern
- = IWildCard
- | IPatVar String
- | IValuePat IExpr
- | IPredPat IExpr
- | IIndexedPat IPattern [IExpr]
- | ILetPat [IBindingExpr] IPattern
- | INotPat IPattern
- | IAndPat IPattern IPattern
- | IOrPat IPattern IPattern
- | IForallPat IPattern IPattern
- | ITuplePat [IPattern]
- | IInductivePat String [IPattern]
- | ILoopPat String ILoopRange IPattern IPattern
- | IContPat
- | IPApplyPat IExpr [IPattern]
- | IVarPat String
- | IInductiveOrPApplyPat String [IPattern]
- | ISeqNilPat
- | ISeqConsPat IPattern IPattern
- | ILaterPatVar
- | IDApplyPat IPattern [IPattern]
- data ILoopRange = ILoopRange IExpr IExpr IPattern
- type IBindingExpr = (IPrimitiveDataPattern, IExpr)
- type IMatchClause = (IPattern, IExpr)
- type IPatternDef = (PrimitivePatPattern, IExpr, [(IPrimitiveDataPattern, IExpr)])
- type IPrimitiveDataPattern = PDPatternBase Var
- data TITopExpr
- data TIExpr = TIExpr {}
- data TIExprNode
- = TIConstantExpr ConstantExpr
- | TIVarExpr String
- | TITupleExpr [TIExpr]
- | TICollectionExpr [TIExpr]
- | TIConsExpr TIExpr TIExpr
- | TIJoinExpr TIExpr TIExpr
- | TIHashExpr [(TIExpr, TIExpr)]
- | TIVectorExpr [TIExpr]
- | TILambdaExpr (Maybe Var) [Var] TIExpr
- | TIMemoizedLambdaExpr [String] TIExpr
- | TICambdaExpr String TIExpr
- | TIApplyExpr TIExpr [TIExpr]
- | TIIfExpr TIExpr TIExpr TIExpr
- | TILetExpr [TIBindingExpr] TIExpr
- | TILetRecExpr [TIBindingExpr] TIExpr
- | TIWithSymbolsExpr [String] TIExpr
- | TIMatchExpr PMMode TIExpr TIExpr [TIMatchClause]
- | TIMatchAllExpr PMMode TIExpr TIExpr [TIMatchClause]
- | TIMatcherExpr [TIPatternDef]
- | TIInductiveDataExpr String [TIExpr]
- | TIQuoteExpr TIExpr
- | TIQuoteSymbolExpr TIExpr
- | TIIndexedExpr Bool TIExpr [Index TIExpr]
- | TISubrefsExpr Bool TIExpr TIExpr
- | TISuprefsExpr Bool TIExpr TIExpr
- | TIUserrefsExpr Bool TIExpr TIExpr
- | TIWedgeApplyExpr TIExpr [TIExpr]
- | TIDoExpr [TIBindingExpr] TIExpr
- | TISeqExpr TIExpr TIExpr
- | TIGenerateTensorExpr TIExpr TIExpr
- | TITensorExpr TIExpr TIExpr
- | TITensorContractExpr TIExpr
- | TITensorMapExpr TIExpr TIExpr
- | TITensorMap2Expr TIExpr TIExpr TIExpr
- | TITensorMap2WedgeExpr TIExpr TIExpr TIExpr
- | TITransposeExpr TIExpr TIExpr
- | TIFlipIndicesExpr TIExpr
- | TIFunctionExpr [String]
- data TIPattern = TIPattern {}
- data TIPatternNode
- = TIWildCard
- | TIPatVar String
- | TIValuePat TIExpr
- | TIPredPat TIExpr
- | TIIndexedPat TIPattern [TIExpr]
- | TILetPat [TIBindingExpr] TIPattern
- | TINotPat TIPattern
- | TIAndPat TIPattern TIPattern
- | TIOrPat TIPattern TIPattern
- | TIForallPat TIPattern TIPattern
- | TITuplePat [TIPattern]
- | TIInductivePat String [TIPattern]
- | TILoopPat String TILoopRange TIPattern TIPattern
- | TIContPat
- | TIPApplyPat TIExpr [TIPattern]
- | TIVarPat String
- | TIInductiveOrPApplyPat String [TIPattern]
- | TISeqNilPat
- | TISeqConsPat TIPattern TIPattern
- | TILaterPatVar
- | TIDApplyPat TIPattern [TIPattern]
- data TILoopRange = TILoopRange TIExpr TIExpr TIPattern
- type TIBindingExpr = (IPrimitiveDataPattern, TIExpr)
- type TIMatchClause = (TIPattern, TIExpr)
- type TIPatternDef = (PrimitivePatPattern, TIExpr, [TIBindingExpr])
- tiExprType :: TIExpr -> Type
- tiExprScheme :: TIExpr -> TypeScheme
- tiExprTypeVars :: TIExpr -> [TyVar]
- tiExprConstraints :: TIExpr -> [Constraint]
- tipType :: TIPattern -> Type
- stripType :: TIExpr -> IExpr
- stripTypeTopExpr :: TITopExpr -> ITopExpr
- data Var = Var String [Index (Maybe Var)]
- stringToVar :: String -> Var
- extractNameFromVar :: Var -> String
- data Index a
- extractSupOrSubIndex :: Index a -> Maybe a
- extractIndex :: Index a -> a
- makeIApply :: String -> [IExpr] -> IExpr
- data ConstantExpr
- data PMMode
- data PrimitivePatPattern
- data PDPatternBase var
- = PDWildCard
- | PDPatVar var
- | PDInductivePat String [PDPatternBase var]
- | PDTuplePat [PDPatternBase var]
- | PDEmptyPat
- | PDConsPat (PDPatternBase var) (PDPatternBase var)
- | PDSnocPat (PDPatternBase var) (PDPatternBase var)
- | PDConstantPat ConstantExpr
- | PDDivPat (PDPatternBase var) (PDPatternBase var)
- | PDPlusPat (PDPatternBase var)
- | PDTermPat (PDPatternBase var) (PDPatternBase var)
- | PDSymbolPat (PDPatternBase var) (PDPatternBase var)
- | PDApply1Pat (PDPatternBase var) (PDPatternBase var)
- | PDApply2Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var)
- | PDApply3Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var)
- | PDApply4Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var)
- | PDQuotePat (PDPatternBase var)
- | PDFunctionPat (PDPatternBase var) (PDPatternBase var)
- | PDSubPat (PDPatternBase var)
- | PDSupPat (PDPatternBase var)
- | PDUserPat (PDPatternBase var)
Documentation
Constructors
Instances
Constructors
Constructors
Instances
data ILoopRange Source #
Constructors
| ILoopRange IExpr IExpr IPattern |
Instances
| Show ILoopRange Source # | |
Defined in Language.Egison.IExpr Methods showsPrec :: Int -> ILoopRange -> ShowS # show :: ILoopRange -> String # showList :: [ILoopRange] -> ShowS # | |
type IBindingExpr = (IPrimitiveDataPattern, IExpr) Source #
type IMatchClause = (IPattern, IExpr) Source #
type IPatternDef = (PrimitivePatPattern, IExpr, [(IPrimitiveDataPattern, IExpr)]) Source #
type IPrimitiveDataPattern = PDPatternBase Var Source #
Typed top-level expression (Phase 9: TITopExpr) Result of TypedDesugar phase, ready for evaluation.
Constructors
| TIDefine TypeScheme Var TIExpr | Typed definition with type scheme (includes type vars & constraints) |
| TIDefineMany [(Var, TIExpr)] | Multiple definitions (letrec) |
| TITest TIExpr | Test expression (REPL) |
| TIExecute TIExpr | Execute IO expression |
| TILoadFile String | Load file (should not appear after expandLoads) |
| TILoad String | Load library (should not appear after expandLoads) |
| TIDeclareSymbol [String] Type | Typed symbol declaration |
| TIPatternFunctionDecl String TypeScheme [(String, Type)] Type TIPattern | Typed pattern function declaration String: function name TypeScheme: type scheme with type parameters and constraints [(String, Type)]: parameters (name and type with type params substituted) Type: return type (with type params substituted) TIPattern: typed body |
Typed internal expression (Phase 9: TIExpr) Each expression node carries its inferred/checked type scheme with type variables and constraints. TypeScheme info is preserved for Phase 8 (TypedDesugar) to perform type-driven transformations such as type class dictionary passing and tensorMap insertion.
NEW: TIExpr is now RECURSIVE - each sub-expression is also a TIExpr, allowing type information to be preserved throughout the tree. This eliminates the need to re-run type inference during TypeClassExpand.
Constructors
| TIExpr | |
Fields
| |
data TIExprNode Source #
Typed expression node - each constructor contains typed sub-expressions (TIExpr) This mirrors IExpr but with TIExpr in place of IExpr for all sub-expressions
Constructors
Instances
| Show TIExprNode Source # | |
Defined in Language.Egison.IExpr Methods showsPrec :: Int -> TIExprNode -> ShowS # show :: TIExprNode -> String # showList :: [TIExprNode] -> ShowS # | |
Typed pattern with recursive structure (like TIExpr)
Constructors
| TIPattern | |
Fields
| |
data TIPatternNode Source #
Pattern node with type information (recursive structure)
Constructors
Instances
| Show TIPatternNode Source # | |
Defined in Language.Egison.IExpr Methods showsPrec :: Int -> TIPatternNode -> ShowS # show :: TIPatternNode -> String # showList :: [TIPatternNode] -> ShowS # | |
data TILoopRange Source #
Typed loop range
Constructors
| TILoopRange TIExpr TIExpr TIPattern |
Instances
| Show TILoopRange Source # | |
Defined in Language.Egison.IExpr Methods showsPrec :: Int -> TILoopRange -> ShowS # show :: TILoopRange -> String # showList :: [TILoopRange] -> ShowS # | |
type TIBindingExpr = (IPrimitiveDataPattern, TIExpr) Source #
Typed binding expression
type TIMatchClause = (TIPattern, TIExpr) Source #
Typed match clause
type TIPatternDef = (PrimitivePatPattern, TIExpr, [TIBindingExpr]) Source #
Typed pattern definition (for matcher expressions)
tiExprType :: TIExpr -> Type Source #
Get the type of a typed expression (extracts Type from TypeScheme)
tiExprScheme :: TIExpr -> TypeScheme Source #
Get the type scheme of a typed expression
tiExprTypeVars :: TIExpr -> [TyVar] Source #
Get the type variables of a typed expression
tiExprConstraints :: TIExpr -> [Constraint] Source #
Get the constraints of a typed expression
tipType :: TIPattern -> Type Source #
Get the type of a typed pattern (extracts Type from TypeScheme)
stripType :: TIExpr -> IExpr Source #
Strip type information, returning the untyped expression This recursively converts TIExpr back to IExpr for evaluation
stripTypeTopExpr :: TITopExpr -> ITopExpr Source #
Strip type information from top-level expression
Instances
stringToVar :: String -> Var Source #
extractNameFromVar :: Var -> String Source #
Constructors
| Sub a | |
| Sup a | |
| MultiSub a Integer a | |
| MultiSup a Integer a | |
| SupSub a | |
| User a | |
| DF Integer Integer |
Instances
| Foldable Index Source # | |||||
Defined in Language.Egison.IExpr Methods fold :: Monoid m => Index m -> m # foldMap :: Monoid m => (a -> m) -> Index a -> m # foldMap' :: Monoid m => (a -> m) -> Index a -> m # foldr :: (a -> b -> b) -> b -> Index a -> b # foldr' :: (a -> b -> b) -> b -> Index a -> b # foldl :: (b -> a -> b) -> b -> Index a -> b # foldl' :: (b -> a -> b) -> b -> Index a -> b # foldr1 :: (a -> a -> a) -> Index a -> a # foldl1 :: (a -> a -> a) -> Index a -> a # elem :: Eq a => a -> Index a -> Bool # maximum :: Ord a => Index a -> a # minimum :: Ord a => Index a -> a # | |||||
| Traversable Index Source # | |||||
| Functor Index Source # | |||||
| Generic (Index a) Source # | |||||
Defined in Language.Egison.IExpr Associated Types
| |||||
| Show (Index EgisonValue) Source # | |||||
Defined in Language.Egison.Data | |||||
| Show (Index ScalarData) Source # | |||||
Defined in Language.Egison.Math.Expr | |||||
| Show (Index String) Source # | |||||
| Show a => Show (Index a) Source # | |||||
| Eq a => Eq (Index a) Source # | |||||
| Ord a => Ord (Index a) Source # | |||||
Defined in Language.Egison.IExpr | |||||
| Hashable a => Hashable (Index a) Source # | |||||
Defined in Language.Egison.IExpr | |||||
| type Rep (Index a) Source # | |||||
Defined in Language.Egison.IExpr type Rep (Index a) = D1 ('MetaData "Index" "Language.Egison.IExpr" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) ((C1 ('MetaCons "Sub" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "Sup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "MultiSub" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))) :+: ((C1 ('MetaCons "MultiSup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) :+: C1 ('MetaCons "SupSub" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) :+: (C1 ('MetaCons "User" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "DF" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer))))) | |||||
extractSupOrSubIndex :: Index a -> Maybe a Source #
extractIndex :: Index a -> a Source #
data ConstantExpr Source #
Constructors
| CharExpr Char | |
| StringExpr Text | |
| BoolExpr Bool | |
| IntegerExpr Integer | |
| FloatExpr Double | |
| SomethingExpr | |
| UndefinedExpr |
Instances
| Show ConstantExpr Source # | |
Defined in Language.Egison.AST Methods showsPrec :: Int -> ConstantExpr -> ShowS # show :: ConstantExpr -> String # showList :: [ConstantExpr] -> ShowS # | |
| Pretty ConstantExpr Source # | |
Defined in Language.Egison.Pretty | |
data PrimitivePatPattern Source #
Constructors
| PPWildCard | |
| PPPatVar | |
| PPValuePat String | |
| PPInductivePat String [PrimitivePatPattern] | |
| PPTuplePat [PrimitivePatPattern] |
Instances
| Show PrimitivePatPattern Source # | |
Defined in Language.Egison.AST Methods showsPrec :: Int -> PrimitivePatPattern -> ShowS # show :: PrimitivePatPattern -> String # showList :: [PrimitivePatPattern] -> ShowS # | |
| Pretty PrimitivePatPattern Source # | |
Defined in Language.Egison.Pretty | |
data PDPatternBase var Source #
Constructors
| PDWildCard | |
| PDPatVar var | |
| PDInductivePat String [PDPatternBase var] | |
| PDTuplePat [PDPatternBase var] | |
| PDEmptyPat | |
| PDConsPat (PDPatternBase var) (PDPatternBase var) | |
| PDSnocPat (PDPatternBase var) (PDPatternBase var) | |
| PDConstantPat ConstantExpr | |
| PDDivPat (PDPatternBase var) (PDPatternBase var) | |
| PDPlusPat (PDPatternBase var) | |
| PDTermPat (PDPatternBase var) (PDPatternBase var) | |
| PDSymbolPat (PDPatternBase var) (PDPatternBase var) | |
| PDApply1Pat (PDPatternBase var) (PDPatternBase var) | |
| PDApply2Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) | |
| PDApply3Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) | |
| PDApply4Pat (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) (PDPatternBase var) | |
| PDQuotePat (PDPatternBase var) | |
| PDFunctionPat (PDPatternBase var) (PDPatternBase var) | |
| PDSubPat (PDPatternBase var) | |
| PDSupPat (PDPatternBase var) | |
| PDUserPat (PDPatternBase var) |
Instances
| Foldable PDPatternBase Source # | |
Defined in Language.Egison.AST Methods fold :: Monoid m => PDPatternBase m -> m # foldMap :: Monoid m => (a -> m) -> PDPatternBase a -> m # foldMap' :: Monoid m => (a -> m) -> PDPatternBase a -> m # foldr :: (a -> b -> b) -> b -> PDPatternBase a -> b # foldr' :: (a -> b -> b) -> b -> PDPatternBase a -> b # foldl :: (b -> a -> b) -> b -> PDPatternBase a -> b # foldl' :: (b -> a -> b) -> b -> PDPatternBase a -> b # foldr1 :: (a -> a -> a) -> PDPatternBase a -> a # foldl1 :: (a -> a -> a) -> PDPatternBase a -> a # toList :: PDPatternBase a -> [a] # null :: PDPatternBase a -> Bool # length :: PDPatternBase a -> Int # elem :: Eq a => a -> PDPatternBase a -> Bool # maximum :: Ord a => PDPatternBase a -> a # minimum :: Ord a => PDPatternBase a -> a # sum :: Num a => PDPatternBase a -> a # product :: Num a => PDPatternBase a -> a # | |
| Functor PDPatternBase Source # | |
Defined in Language.Egison.AST Methods fmap :: (a -> b) -> PDPatternBase a -> PDPatternBase b # (<$) :: a -> PDPatternBase b -> PDPatternBase a # | |
| Pretty PrimitiveDataPattern Source # | |
Defined in Language.Egison.Pretty | |
| Pretty IPrimitiveDataPattern Source # | |
Defined in Language.Egison.Pretty Methods pretty :: IPrimitiveDataPattern -> Doc ann # prettyList :: [IPrimitiveDataPattern] -> Doc ann # | |
| Show var => Show (PDPatternBase var) Source # | |
Defined in Language.Egison.AST Methods showsPrec :: Int -> PDPatternBase var -> ShowS # show :: PDPatternBase var -> String # showList :: [PDPatternBase var] -> ShowS # | |