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

Language.Egison.IExpr

Description

This module defines internal representation of Egison language.

Synopsis

Documentation

data IExpr Source #

Instances

Instances details
Show IExpr Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

showsPrec :: Int -> IExpr -> ShowS #

show :: IExpr -> String #

showList :: [IExpr] -> ShowS #

Pretty IExpr Source # 
Instance details

Defined in Language.Egison.Pretty

Methods

pretty :: IExpr -> Doc ann #

prettyList :: [IExpr] -> Doc ann #

data ILoopRange Source #

Instances

Instances details
Show ILoopRange Source # 
Instance details

Defined in Language.Egison.IExpr

data TITopExpr 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

Instances

Instances details
Show TITopExpr Source # 
Instance details

Defined in Language.Egison.IExpr

Pretty TITopExpr Source # 
Instance details

Defined in Language.Egison.Pretty

Methods

pretty :: TITopExpr -> Doc ann #

prettyList :: [TITopExpr] -> Doc ann #

data TIExpr Source #

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

Instances

Instances details
Show TIExpr Source # 
Instance details

Defined in Language.Egison.IExpr

Pretty TIExpr Source # 
Instance details

Defined in Language.Egison.Pretty

Methods

pretty :: TIExpr -> Doc ann #

prettyList :: [TIExpr] -> Doc ann #

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

Instances

Instances details
Show TIExprNode Source # 
Instance details

Defined in Language.Egison.IExpr

data TIPattern Source #

Typed pattern with recursive structure (like TIExpr)

Constructors

TIPattern 

Fields

Instances

Instances details
Show TIPattern Source # 
Instance details

Defined in Language.Egison.IExpr

Pretty TIPattern Source # 
Instance details

Defined in Language.Egison.Pretty

Methods

pretty :: TIPattern -> Doc ann #

prettyList :: [TIPattern] -> Doc ann #

data TILoopRange Source #

Typed loop range

Instances

Instances details
Show TILoopRange Source # 
Instance details

Defined in Language.Egison.IExpr

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

data Var Source #

Constructors

Var String [Index (Maybe Var)] 

Instances

Instances details
Generic Var Source # 
Instance details

Defined in Language.Egison.IExpr

Associated Types

type Rep Var 
Instance details

Defined in Language.Egison.IExpr

type Rep Var = D1 ('MetaData "Var" "Language.Egison.IExpr" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) (C1 ('MetaCons "Var" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Index (Maybe Var)])))

Methods

from :: Var -> Rep Var x #

to :: Rep Var x -> Var #

Show Var Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

showsPrec :: Int -> Var -> ShowS #

show :: Var -> String #

showList :: [Var] -> ShowS #

Eq Var Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

(==) :: Var -> Var -> Bool #

(/=) :: Var -> Var -> Bool #

Ord Var Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

compare :: Var -> Var -> Ordering #

(<) :: Var -> Var -> Bool #

(<=) :: Var -> Var -> Bool #

(>) :: Var -> Var -> Bool #

(>=) :: Var -> Var -> Bool #

max :: Var -> Var -> Var #

min :: Var -> Var -> Var #

Hashable Var Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

hashWithSalt :: Int -> Var -> Int #

hash :: Var -> Int #

Pretty IPrimitiveDataPattern Source # 
Instance details

Defined in Language.Egison.Pretty

type Rep Var Source # 
Instance details

Defined in Language.Egison.IExpr

type Rep Var = D1 ('MetaData "Var" "Language.Egison.IExpr" "egison-5.0.0-IKLJXBVxR779jp4wYu1Icq" 'False) (C1 ('MetaCons "Var" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Index (Maybe Var)])))

data Index a Source #

Constructors

Sub a 
Sup a 
MultiSub a Integer a 
MultiSup a Integer a 
SupSub a 
User a 
DF Integer Integer 

Instances

Instances details
Foldable Index Source # 
Instance details

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 #

toList :: Index a -> [a] #

null :: Index a -> Bool #

length :: Index a -> Int #

elem :: Eq a => a -> Index a -> Bool #

maximum :: Ord a => Index a -> a #

minimum :: Ord a => Index a -> a #

sum :: Num a => Index a -> a #

product :: Num a => Index a -> a #

Traversable Index Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

traverse :: Applicative f => (a -> f b) -> Index a -> f (Index b) #

sequenceA :: Applicative f => Index (f a) -> f (Index a) #

mapM :: Monad m => (a -> m b) -> Index a -> m (Index b) #

sequence :: Monad m => Index (m a) -> m (Index a) #

Functor Index Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

fmap :: (a -> b) -> Index a -> Index b #

(<$) :: a -> Index b -> Index a #

Generic (Index a) Source # 
Instance details

Defined in Language.Egison.IExpr

Associated Types

type Rep (Index a) 
Instance details

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)))))

Methods

from :: Index a -> Rep (Index a) x #

to :: Rep (Index a) x -> Index a #

Show (Index EgisonValue) Source # 
Instance details

Defined in Language.Egison.Data

Show (Index ScalarData) Source # 
Instance details

Defined in Language.Egison.Math.Expr

Show (Index String) Source # 
Instance details

Defined in Language.Egison.IExpr

Show a => Show (Index a) Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

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

show :: Index a -> String #

showList :: [Index a] -> ShowS #

Eq a => Eq (Index a) Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

(==) :: Index a -> Index a -> Bool #

(/=) :: Index a -> Index a -> Bool #

Ord a => Ord (Index a) Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

compare :: Index a -> Index a -> Ordering #

(<) :: Index a -> Index a -> Bool #

(<=) :: Index a -> Index a -> Bool #

(>) :: Index a -> Index a -> Bool #

(>=) :: Index a -> Index a -> Bool #

max :: Index a -> Index a -> Index a #

min :: Index a -> Index a -> Index a #

Hashable a => Hashable (Index a) Source # 
Instance details

Defined in Language.Egison.IExpr

Methods

hashWithSalt :: Int -> Index a -> Int #

hash :: Index a -> Int #

type Rep (Index a) Source # 
Instance details

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)))))

data PMMode Source #

Constructors

BFSMode 
DFSMode 

Instances

Instances details
Show PMMode Source # 
Instance details

Defined in Language.Egison.AST

data PDPatternBase var Source #

Instances

Instances details
Foldable PDPatternBase Source # 
Instance details

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 # 
Instance details

Defined in Language.Egison.AST

Methods

fmap :: (a -> b) -> PDPatternBase a -> PDPatternBase b #

(<$) :: a -> PDPatternBase b -> PDPatternBase a #

Pretty PrimitiveDataPattern Source # 
Instance details

Defined in Language.Egison.Pretty

Pretty IPrimitiveDataPattern Source # 
Instance details

Defined in Language.Egison.Pretty

Show var => Show (PDPatternBase var) Source # 
Instance details

Defined in Language.Egison.AST