swarm-0.2.0.0: 2D resource gathering game with programmable robots
CopyrightBrent Yorgey
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Language.Context

Description

Generic contexts (mappings from variables to other things, such as types, values, or capability sets) used throughout the codebase.

Synopsis

Documentation

type Var = Text Source #

We use Text values to represent variables.

newtype Ctx t Source #

A context is a mapping from variable names to things.

Constructors

Ctx 

Fields

Instances

Instances details
Foldable Ctx Source # 
Instance details

Defined in Swarm.Language.Context

Methods

fold :: Monoid m => Ctx m -> m #

foldMap :: Monoid m => (a -> m) -> Ctx a -> m #

foldMap' :: Monoid m => (a -> m) -> Ctx a -> m #

foldr :: (a -> b -> b) -> b -> Ctx a -> b #

foldr' :: (a -> b -> b) -> b -> Ctx a -> b #

foldl :: (b -> a -> b) -> b -> Ctx a -> b #

foldl' :: (b -> a -> b) -> b -> Ctx a -> b #

foldr1 :: (a -> a -> a) -> Ctx a -> a #

foldl1 :: (a -> a -> a) -> Ctx a -> a #

toList :: Ctx a -> [a] #

null :: Ctx a -> Bool #

length :: Ctx a -> Int #

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

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

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

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

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

Traversable Ctx Source # 
Instance details

Defined in Swarm.Language.Context

Methods

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

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

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

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

Functor Ctx Source # 
Instance details

Defined in Swarm.Language.Context

Methods

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

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

HasBindings UCtx Source # 
Instance details

Defined in Swarm.Language.Typecheck

FromJSON t => FromJSON (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

parseJSON :: Value -> Parser (Ctx t) #

parseJSONList :: Value -> Parser [Ctx t] #

ToJSON t => ToJSON (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

toJSON :: Ctx t -> Value #

toEncoding :: Ctx t -> Encoding #

toJSONList :: [Ctx t] -> Value #

toEncodingList :: [Ctx t] -> Encoding #

Data t => Data (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ctx t -> c (Ctx t) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ctx t) #

toConstr :: Ctx t -> Constr #

dataTypeOf :: Ctx t -> DataType #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Ctx t)) #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Ctx t)) #

gmapT :: (forall b. Data b => b -> b) -> Ctx t -> Ctx t #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ctx t -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ctx t -> r #

gmapQ :: (forall d. Data d => d -> u) -> Ctx t -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Ctx t -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ctx t -> m (Ctx t) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ctx t -> m (Ctx t) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ctx t -> m (Ctx t) #

Monoid (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

mempty :: Ctx t #

mappend :: Ctx t -> Ctx t -> Ctx t #

mconcat :: [Ctx t] -> Ctx t #

Semigroup (Ctx t) Source #

The semigroup operation for contexts is right-biased union.

Instance details

Defined in Swarm.Language.Context

Methods

(<>) :: Ctx t -> Ctx t -> Ctx t #

sconcat :: NonEmpty (Ctx t) -> Ctx t #

stimes :: Integral b => b -> Ctx t -> Ctx t #

Generic (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Associated Types

type Rep (Ctx t) :: Type -> Type #

Methods

from :: Ctx t -> Rep (Ctx t) x #

to :: Rep (Ctx t) x -> Ctx t #

Show t => Show (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

showsPrec :: Int -> Ctx t -> ShowS #

show :: Ctx t -> String #

showList :: [Ctx t] -> ShowS #

Eq t => Eq (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

(==) :: Ctx t -> Ctx t -> Bool #

(/=) :: Ctx t -> Ctx t -> Bool #

AsEmpty (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

Methods

_Empty :: Prism' (Ctx t) () #

PrettyPrec t => PrettyPrec (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Pretty

Methods

prettyPrec :: Int -> Ctx t -> Doc ann Source #

type Rep (Ctx t) Source # 
Instance details

Defined in Swarm.Language.Context

type Rep (Ctx t) = D1 ('MetaData "Ctx" "Swarm.Language.Context" "swarm-0.2.0.0-D1mAmWsUEjoFqpCaq9DHG0" 'True) (C1 ('MetaCons "Ctx" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCtx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Var t))))

empty :: Ctx t Source #

The empty context.

singleton :: Var -> t -> Ctx t Source #

A singleton context.

lookup :: Var -> Ctx t -> Maybe t Source #

Look up a variable in a context.

delete :: Var -> Ctx t -> Ctx t Source #

Delete a variable from a context.

assocs :: Ctx t -> [(Var, t)] Source #

Get the list of key-value associations from a context.

addBinding :: Var -> t -> Ctx t -> Ctx t Source #

Add a key-value binding to a context (overwriting the old one if the key is already present).

union :: Ctx t -> Ctx t -> Ctx t Source #

Right-biased union of contexts.

withBinding :: MonadReader (Ctx t) m => Var -> t -> m a -> m a Source #

Locally extend the context with an additional binding.

withBindings :: MonadReader (Ctx t) m => Ctx t -> m a -> m a Source #

Locally extend the context with an additional context of bindings.