| License | BSD-3-Clause |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Language.Syntax.AST
Description
Types represeting 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
- | TRobot Int
- | TRef Int
- | TRequireDevice Text
- | TRequire 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 Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty)
- | STydef LocVar 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) Polytype
- | SSuspend (Syntax' ty)
- data DelayType
- = SimpleDelay
- | MemoizedDelay (Maybe Var)
Documentation
The surface syntax for the language, with location and type annotations.
Instances
| FromJSON Syntax Source # | |
Defined in Swarm.Language.JSON | |
| FromJSON TSyntax Source # | |
Defined in Swarm.Language.JSON | |
| ToJSON Syntax Source # | |
| ToJSON TSyntax Source # | |
| Foldable Syntax' Source # | |
Defined in Swarm.Language.Syntax.AST Methods fold :: Monoid m => Syntax' m -> m # foldMap :: Monoid m => (a -> m) -> Syntax' a -> m # foldMap' :: Monoid m => (a -> m) -> Syntax' a -> m # foldr :: (a -> b -> b) -> b -> Syntax' a -> b # foldr' :: (a -> b -> b) -> b -> Syntax' a -> b # foldl :: (b -> a -> b) -> b -> Syntax' a -> b # foldl' :: (b -> a -> b) -> b -> Syntax' a -> b # foldr1 :: (a -> a -> a) -> Syntax' a -> a # foldl1 :: (a -> a -> a) -> Syntax' a -> a # elem :: Eq a => a -> Syntax' a -> Bool # maximum :: Ord a => Syntax' a -> a # minimum :: Ord a => Syntax' a -> a # | |
| Traversable Syntax' Source # | |
| Functor Syntax' Source # | |
| FromJSON (Document Syntax) Source # | |
| ToJSON (Document Syntax) Source # | |
| ToJSON (Paragraph Syntax) Source # | |
| Data ty => Data (Syntax' 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) -> Syntax' ty -> c (Syntax' ty) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Syntax' ty) # toConstr :: Syntax' ty -> Constr # dataTypeOf :: Syntax' ty -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Syntax' ty)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Syntax' ty)) # gmapT :: (forall b. Data b => b -> b) -> Syntax' ty -> Syntax' ty # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Syntax' ty -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Syntax' ty -> r # gmapQ :: (forall d. Data d => d -> u) -> Syntax' ty -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Syntax' ty -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Syntax' ty -> m (Syntax' ty) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Syntax' ty -> m (Syntax' ty) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Syntax' ty -> m (Syntax' ty) # | |
| IsString (Document Syntax) Source # | |
Defined in Swarm.Language.Text.Markdown Methods fromString :: String -> Document Syntax # | |
| IsString (Paragraph Syntax) Source # | |
Defined in Swarm.Language.Text.Markdown Methods fromString :: String -> Paragraph Syntax # | |
| Generic (Syntax' ty) Source # | |
| Show ty => Show (Syntax' ty) Source # | |
| Eq ty => Eq (Syntax' ty) Source # | |
| Data ty => Plated (Syntax' ty) Source # | |
Defined in Swarm.Language.Syntax.AST Methods plate :: Traversal' (Syntax' ty) (Syntax' ty) # | |
| PrettyPrec (Syntax' ty) Source # | Pretty-print a syntax node with comments. |
Defined in Swarm.Language.Pretty | |
| type Rep (Syntax' ty) Source # | |
Defined in Swarm.Language.Syntax.AST type Rep (Syntax' ty) = D1 ('MetaData "Syntax'" "Swarm.Language.Syntax.AST" "swarm-0.6.0.0-ERx1HMcRMba59aI2b6aNrS-swarm-lang" 'False) (C1 ('MetaCons "Syntax'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_sLoc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SrcLoc) :*: S1 ('MetaSel ('Just "_sTerm") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Term' ty))) :*: (S1 ('MetaSel ('Just "_sComments") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Comments) :*: S1 ('MetaSel ('Just "_sType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ty)))) | |
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 appropriatly.
Instances
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. |
| 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. |
| TRequireDevice Text | Require a specific device to be installed. |
| TRequire 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 Polytype) (Maybe Requirements) (Syntax' ty) (Syntax' ty) | A (recursive) let/def expression, with or without a type
annotation on the variable. The The |
| STydef LocVar 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) Polytype | Annotate a term with a type |
| SSuspend (Syntax' ty) | Run the given command, then suspend and wait for a new REPL input. |
Instances
Different runtime behaviors for delayed expressions.
Constructors
| SimpleDelay | A simple delay, implemented via a (non-memoized) |
| MemoizedDelay (Maybe Var) | A memoized delay, implemented by allocating a mutable cell
with the delayed expression and returning a reference to it.
When the |
Instances
| FromJSON DelayType Source # | |
Defined in Swarm.Language.Syntax.AST | |
| ToJSON DelayType Source # | |
| Data DelayType 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) -> DelayType -> c DelayType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DelayType # toConstr :: DelayType -> Constr # dataTypeOf :: DelayType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DelayType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DelayType) # gmapT :: (forall b. Data b => b -> b) -> DelayType -> DelayType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DelayType -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DelayType -> r # gmapQ :: (forall d. Data d => d -> u) -> DelayType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DelayType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DelayType -> m DelayType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DelayType -> m DelayType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DelayType -> m DelayType # | |
| Generic DelayType Source # | |
| Show DelayType Source # | |
| Eq DelayType Source # | |
| type Rep DelayType Source # | |
Defined in Swarm.Language.Syntax.AST type Rep DelayType = D1 ('MetaData "DelayType" "Swarm.Language.Syntax.AST" "swarm-0.6.0.0-ERx1HMcRMba59aI2b6aNrS-swarm-lang" 'False) (C1 ('MetaCons "SimpleDelay" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MemoizedDelay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Var)))) | |