License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Language.Syntax.AST
Description
Types representing the surface syntax and terms for Swarm programming language.
Synopsis
- data Syntax' ty = Syntax' {}
- data LetSyntax
- data Term' ty
- = TUnit
- | TConst Const
- | TDir Direction
- | TInt Integer
- | TAntiInt Text
- | TText Text
- | TAntiText Text
- | TBool Bool
- | TAntiSyn Text
- | TRobot Int
- | TRef Int
- | TRequire Text
- | TStock Int Text
- | SRequirements Text (Syntax' ty)
- | TVar Var
- | SPair (Syntax' ty) (Syntax' ty)
- | SLam LocVar (Maybe Type) (Syntax' ty)
- | SApp (Syntax' ty) (Syntax' ty)
- | SLet LetSyntax Bool LocVar (Maybe RawPolytype) (Maybe Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty)
- | STydef (Located TDVar) Polytype (Maybe TydefInfo) (Syntax' ty)
- | SBind (Maybe LocVar) (Maybe ty) (Maybe Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty)
- | SDelay (Syntax' ty)
- | SRcd (Map Var (Maybe (Syntax' ty)))
- | SProj (Syntax' ty) Var
- | SAnnotate (Syntax' ty) RawPolytype
- | SSuspend (Syntax' ty)
- | SParens (Syntax' ty)
- | TType Type
Documentation
The surface syntax for the language, with location and type annotations.
Instances
A let
expression can be written either as let x = e1 in e2
or
as def x = e1 end; e2
. This enumeration simply records which it
was so that we can pretty-print appropriately.
Instances
FromJSON LetSyntax Source # | |
Defined in Swarm.Language.Syntax.AST | |
ToJSON LetSyntax Source # | |
Data LetSyntax Source # | |
Defined in Swarm.Language.Syntax.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LetSyntax -> c LetSyntax # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LetSyntax # toConstr :: LetSyntax -> Constr # dataTypeOf :: LetSyntax -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c LetSyntax) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LetSyntax) # gmapT :: (forall b. Data b => b -> b) -> LetSyntax -> LetSyntax # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LetSyntax -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LetSyntax -> r # gmapQ :: (forall d. Data d => d -> u) -> LetSyntax -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> LetSyntax -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LetSyntax -> m LetSyntax # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LetSyntax -> m LetSyntax # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LetSyntax -> m LetSyntax # | |
Bounded LetSyntax Source # | |
Enum LetSyntax Source # | |
Defined in Swarm.Language.Syntax.AST Methods succ :: LetSyntax -> LetSyntax # pred :: LetSyntax -> LetSyntax # fromEnum :: LetSyntax -> Int # enumFrom :: LetSyntax -> [LetSyntax] # enumFromThen :: LetSyntax -> LetSyntax -> [LetSyntax] # enumFromTo :: LetSyntax -> LetSyntax -> [LetSyntax] # enumFromThenTo :: LetSyntax -> LetSyntax -> LetSyntax -> [LetSyntax] # | |
Generic LetSyntax Source # | |
Defined in Swarm.Language.Syntax.AST | |
Show LetSyntax Source # | |
Eq LetSyntax Source # | |
Ord LetSyntax Source # | |
Hashable LetSyntax Source # | |
Defined in Swarm.Language.Syntax.AST | |
type Rep LetSyntax Source # | |
Terms of the Swarm language.
Constructors
TUnit | The unit value. |
TConst Const | A constant. |
TDir Direction | A direction literal. |
TInt Integer | An integer literal. |
TAntiInt Text | An antiquoted Haskell variable name of type Integer. |
TText Text | A text literal. |
TAntiText Text | An antiquoted Haskell variable name of type Text. |
TBool Bool | A Boolean literal. |
TAntiSyn Text | An antiquoted Haskell variable name of type Syntax. |
TRobot Int | A robot reference. These never show up in surface syntax, but are here so we can factor pretty-printing for Values through pretty-printing for Terms. |
TRef Int | A memory reference. These likewise never show up in surface syntax, but are here to facilitate pretty-printing. |
TRequire Text | Require a specific device to be installed. |
TStock Int Text | Require a certain number of an entity. |
SRequirements Text (Syntax' ty) | Primitive command to log requirements of a term. The Text
field is to store the unaltered original text of the term, for use
in displaying the log message (since once we get to execution time the
original term may have been elaborated, e.g. |
TVar Var | A variable. |
SPair (Syntax' ty) (Syntax' ty) | A pair. |
SLam LocVar (Maybe Type) (Syntax' ty) | A lambda expression, with or without a type annotation on the binder. |
SApp (Syntax' ty) (Syntax' ty) | Function application. |
SLet LetSyntax Bool LocVar (Maybe RawPolytype) (Maybe Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty) | A (recursive) let/def expression, with or without a type
annotation on the variable. The The |
STydef (Located TDVar) Polytype (Maybe TydefInfo) (Syntax' ty) | A type synonym definition. Note that this acts like a |
SBind (Maybe LocVar) (Maybe ty) (Maybe Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty) | A monadic bind for commands, of the form The The |
SDelay (Syntax' ty) | Delay evaluation of a term, written |
SRcd (Map Var (Maybe (Syntax' ty))) | Record literals |
SProj (Syntax' ty) Var | Record projection |
SAnnotate (Syntax' ty) RawPolytype | Annotate a term with a type |
SSuspend (Syntax' ty) | Run the given command, then suspend and wait for a new REPL input. |
SParens (Syntax' ty) | An explicit representation of parentheses in the input. We need this to be able to print formatted code with parentheses and comments preserved, but we get rid of them during elaboration. |
TType Type | A type literal. |
Instances
FromJSON Term Source # | |||||
Defined in Swarm.Language.JSON | |||||
ToJSON Term Source # | |||||
Foldable Term' Source # | |||||
Defined in Swarm.Language.Syntax.AST Methods fold :: Monoid m => Term' m -> m # foldMap :: Monoid m => (a -> m) -> Term' a -> m # foldMap' :: Monoid m => (a -> m) -> Term' a -> m # foldr :: (a -> b -> b) -> b -> Term' a -> b # foldr' :: (a -> b -> b) -> b -> Term' a -> b # foldl :: (b -> a -> b) -> b -> Term' a -> b # foldl' :: (b -> a -> b) -> b -> Term' a -> b # foldr1 :: (a -> a -> a) -> Term' a -> a # foldl1 :: (a -> a -> a) -> Term' a -> a # elem :: Eq a => a -> Term' a -> Bool # maximum :: Ord a => Term' a -> a # minimum :: Ord a => Term' a -> a # | |||||
Traversable Term' Source # | The Traversable instance for Term (and for Syntax') is used during
typechecking: during intermediate type inference, many of the type
annotations placed on AST nodes will have unification variables in
them. Once we have finished solving everything we need to do a
final traversal over all the types in the AST to substitute away
all the unification variables (and generalize, i.e. stick | ||||
Functor Term' Source # | |||||
Data ty => Data (Term' ty) Source # | |||||
Defined in Swarm.Language.Syntax.AST Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Term' ty -> c (Term' ty) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Term' ty) # toConstr :: Term' ty -> Constr # dataTypeOf :: Term' ty -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Term' ty)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Term' ty)) # gmapT :: (forall b. Data b => b -> b) -> Term' ty -> Term' ty # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Term' ty -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Term' ty -> r # gmapQ :: (forall d. Data d => d -> u) -> Term' ty -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Term' ty -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Term' ty -> m (Term' ty) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Term' ty -> m (Term' ty) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Term' ty -> m (Term' ty) # | |||||
Generic (Term' ty) Source # | |||||
Defined in Swarm.Language.Syntax.AST Associated Types
| |||||
Show ty => Show (Term' ty) Source # | |||||
Eq ty => Eq (Term' ty) Source # | |||||
Hashable ty => Hashable (Term' ty) Source # | |||||
Defined in Swarm.Language.Syntax.AST | |||||
Data ty => Plated (Term' ty) Source # | |||||
Defined in Swarm.Language.Syntax.AST Methods plate :: Traversal' (Term' ty) (Term' ty) # | |||||
PrettyPrec (Term' ty) | |||||
Defined in Swarm.Language.Syntax.Pretty Methods prettyPrec :: Int -> Term' ty -> Doc ann | |||||
type Rep (Term' ty) Source # | |||||
Defined in Swarm.Language.Syntax.AST type Rep (Term' ty) = D1 ('MetaData "Term'" "Swarm.Language.Syntax.AST" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-lang" 'False) ((((C1 ('MetaCons "TUnit" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TConst" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Const)) :+: C1 ('MetaCons "TDir" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Direction)))) :+: ((C1 ('MetaCons "TInt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Integer)) :+: C1 ('MetaCons "TAntiInt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))) :+: (C1 ('MetaCons "TText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "TAntiText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))))) :+: ((C1 ('MetaCons "TBool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :+: (C1 ('MetaCons "TAntiSyn" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "TRobot" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)))) :+: ((C1 ('MetaCons "TRef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "TRequire" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))) :+: (C1 ('MetaCons "TStock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "SRequirements" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty))))))) :+: (((C1 ('MetaCons "TVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Var)) :+: (C1 ('MetaCons "SPair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty))) :+: C1 ('MetaCons "SLam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LocVar) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Type)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)))))) :+: ((C1 ('MetaCons "SApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty))) :+: C1 ('MetaCons "SLet" 'PrefixI 'False) (((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LetSyntax) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LocVar) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe RawPolytype)))) :*: ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Polytype)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Requirements))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)))))) :+: (C1 ('MetaCons "STydef" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Located TDVar)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Polytype)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe TydefInfo)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)))) :+: C1 ('MetaCons "SBind" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe LocVar)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Polytype)))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Requirements)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)))))))) :+: ((C1 ('MetaCons "SDelay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty))) :+: (C1 ('MetaCons "SRcd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Map Var (Maybe (Syntax' ty))))) :+: C1 ('MetaCons "SProj" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Var)))) :+: ((C1 ('MetaCons "SAnnotate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 RawPolytype)) :+: C1 ('MetaCons "SSuspend" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty)))) :+: (C1 ('MetaCons "SParens" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Syntax' ty))) :+: C1 ('MetaCons "TType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Type))))))) |