language-ninja-0.1.0: A library for dealing with the Ninja build language.

CopyrightCopyright 2017 Awake Security
LicenseApache-2.0
Maintaineropensource@awakesecurity.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Language.Ninja.AST

Contents

Description

The Ninja build language after parsing.

This module re-exports all of the modules under the Language.Ninja.AST namespace for convenience.

It is recommended that you import it with the following style:

import qualified Language.Ninja.AST as AST

Since: 0.1.0

Synopsis

Language.Ninja.AST.Ninja

data Ninja ann Source #

A parsed Ninja file.

Since: 0.1.0

Instances

Functor Ninja Source # 

Methods

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

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

Foldable Ninja Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Ninja a -> [a] #

null :: Ninja a -> Bool #

length :: Ninja a -> Int #

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

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

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

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

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

Traversable Ninja Source # 

Methods

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

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

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

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

Annotated Ninja Source #

The usual definition for Annotated.

Since: 0.1.0

Methods

annotation' :: (ann -> ann') -> Lens (Ninja ann) (Ninja ann') ann ann' Source #

(Monad m, NinjaConstraint (Serial m) ann) => Serial m (Ninja ann) Source #

Default Serial instance via Generic.

Since: 0.1.0

Methods

series :: Series m (Ninja ann) #

(Monad m, NinjaConstraint (CoSerial m) ann) => CoSerial m (Ninja ann) Source #

Default CoSerial instance via Generic.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Ninja ann -> b) #

Eq ann => Eq (Ninja ann) Source # 

Methods

(==) :: Ninja ann -> Ninja ann -> Bool #

(/=) :: Ninja ann -> Ninja ann -> Bool #

Show ann => Show (Ninja ann) Source # 

Methods

showsPrec :: Int -> Ninja ann -> ShowS #

show :: Ninja ann -> String #

showList :: [Ninja ann] -> ShowS #

Generic (Ninja ann) Source # 

Associated Types

type Rep (Ninja ann) :: * -> * #

Methods

from :: Ninja ann -> Rep (Ninja ann) x #

to :: Rep (Ninja ann) x -> Ninja ann #

Arbitrary ann => Arbitrary (Ninja ann) Source #

Reasonable Arbitrary instance for Ninja.

Since: 0.1.0

Methods

arbitrary :: Gen (Ninja ann) #

shrink :: Ninja ann -> [Ninja ann] #

Hashable ann => Hashable (Ninja ann) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Ninja ann -> Int #

hash :: Ninja ann -> Int #

ToJSON ann => ToJSON (Ninja ann) Source #

Converts to {ann: …, rules: …, singles: …, multiples: …, phonys: …, defaults: …, pools: …, specials: …}.

Since: 0.1.0

Methods

toJSON :: Ninja ann -> Value #

toEncoding :: Ninja ann -> Encoding #

toJSONList :: [Ninja ann] -> Value #

toEncodingList :: [Ninja ann] -> Encoding #

FromJSON ann => FromJSON (Ninja ann) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Ninja ann) #

parseJSONList :: Value -> Parser [Ninja ann] #

NFData ann => NFData (Ninja ann) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Ninja ann -> () #

type Rep (Ninja ann) Source # 

makeNinja :: Monoid ann => Ninja ann Source #

Construct a Ninja with all default values

Since: 0.1.0

ninjaRules :: Lens' (Ninja ann) (HashMap Text (Rule ann)) Source #

The rules defined in a parsed Ninja file.

Since: 0.1.0

ninjaSingles :: Lens' (Ninja ann) (HashMap Text (Build ann)) Source #

The set of build declarations with precisely one output.

Since: 0.1.0

ninjaMultiples :: Lens' (Ninja ann) (HashMap Outputs (Build ann)) Source #

The set of build declarations with two or more outputs.

Since: 0.1.0

ninjaPhonys :: Lens' (Ninja ann) (HashMap Text (HashSet Text)) Source #

The set of phony build declarations.

Since: 0.1.0

ninjaDefaults :: Lens' (Ninja ann) (HashSet Text) Source #

The set of default targets.

Since: 0.1.0

ninjaPools :: Lens' (Ninja ann) (HashMap Text Int) Source #

A mapping from pool names to pool depth integers.

Since: 0.1.0

ninjaSpecials :: Lens' (Ninja ann) (HashMap Text Text) Source #

A map from "special" top-level variables to their values.

Since: 0.1.0

Language.Ninja.AST.Build

data Build ann Source #

A parsed Ninja build declaration.

Since: 0.1.0

Instances

Functor Build Source # 

Methods

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

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

Foldable Build Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Build a -> [a] #

null :: Build a -> Bool #

length :: Build a -> Int #

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

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

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

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

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

Traversable Build Source # 

Methods

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

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

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

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

Annotated Build Source #

The usual definition for Annotated.

Since: 0.1.0

Methods

annotation' :: (ann -> ann') -> Lens (Build ann) (Build ann') ann ann' Source #

(Monad m, BuildConstraint (Serial m) ann) => Serial m (Build ann) Source #

Default Serial instance via Generic.

Since: 0.1.0

Methods

series :: Series m (Build ann) #

(Monad m, BuildConstraint (CoSerial m) ann) => CoSerial m (Build ann) Source #

Default CoSerial instance via Generic.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Build ann -> b) #

Eq ann => Eq (Build ann) Source # 

Methods

(==) :: Build ann -> Build ann -> Bool #

(/=) :: Build ann -> Build ann -> Bool #

Show ann => Show (Build ann) Source # 

Methods

showsPrec :: Int -> Build ann -> ShowS #

show :: Build ann -> String #

showList :: [Build ann] -> ShowS #

Generic (Build ann) Source # 

Associated Types

type Rep (Build ann) :: * -> * #

Methods

from :: Build ann -> Rep (Build ann) x #

to :: Rep (Build ann) x -> Build ann #

Arbitrary ann => Arbitrary (Build ann) Source #

Reasonable Arbitrary instance for Build.

Since: 0.1.0

Methods

arbitrary :: Gen (Build ann) #

shrink :: Build ann -> [Build ann] #

Hashable ann => Hashable (Build ann) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Build ann -> Int #

hash :: Build ann -> Int #

ToJSON ann => ToJSON (Build ann) Source #

Converts to {ann: …, rule: …, env: …, deps: …, bind: …}.

Since: 0.1.0

Methods

toJSON :: Build ann -> Value #

toEncoding :: Build ann -> Encoding #

toJSONList :: [Build ann] -> Value #

toEncodingList :: [Build ann] -> Encoding #

FromJSON ann => FromJSON (Build ann) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Build ann) #

parseJSONList :: Value -> Parser [Build ann] #

NFData ann => NFData (Build ann) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Build ann -> () #

type Rep (Build ann) Source # 
type Rep (Build ann) = D1 (MetaData "Build" "Language.Ninja.AST.Build" "language-ninja-0.1.0-CTXTL0Lugm4Llo91nN4SIr" False) (C1 (MetaCons "MkBuild" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "_buildAnn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ann)) (S1 (MetaSel (Just Symbol "_buildRule") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Text))) ((:*:) (S1 (MetaSel (Just Symbol "_buildEnv") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Env Text Text))) ((:*:) (S1 (MetaSel (Just Symbol "_buildDeps") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Deps ann))) (S1 (MetaSel (Just Symbol "_buildBind") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashMap Text Text)))))))

makeBuild Source #

Arguments

:: Monoid ann 
=> Text

The rule name

-> Env Text Text

The environment

-> Build ann 

Construct a Build with all default values.

Since: 0.1.0

buildRule :: Lens' (Build ann) Text Source #

A lens into the rule name associated with a Build.

Since: 0.1.0

buildEnv :: Lens' (Build ann) (Env Text Text) Source #

A lens into the environment associated with a Build.

Since: 0.1.0

buildDeps :: Lens' (Build ann) (Deps ann) Source #

A lens into the dependencies associated with a Build.

Since: 0.1.0

buildBind :: Lens' (Build ann) (HashMap Text Text) Source #

A lens into the bindings associated with a Build.

Since: 0.1.0

Language.Ninja.AST.Deps

data Deps ann Source #

A set of Ninja build dependencies.

Since: 0.1.0

Instances

Functor Deps Source # 

Methods

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

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

Foldable Deps Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Deps a -> [a] #

null :: Deps a -> Bool #

length :: Deps a -> Int #

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

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

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

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

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

Traversable Deps Source # 

Methods

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

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

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

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

Annotated Deps Source #

The usual definition for Annotated.

Since: 0.1.0

Methods

annotation' :: (ann -> ann') -> Lens (Deps ann) (Deps ann') ann ann' Source #

(Monad m, DepsConstraint (Serial m) ann) => Serial m (Deps ann) Source #

Default Serial instance via Generic.

Since: 0.1.0

Methods

series :: Series m (Deps ann) #

(Monad m, DepsConstraint (CoSerial m) ann) => CoSerial m (Deps ann) Source #

Default CoSerial instance via Generic.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Deps ann -> b) #

Eq ann => Eq (Deps ann) Source # 

Methods

(==) :: Deps ann -> Deps ann -> Bool #

(/=) :: Deps ann -> Deps ann -> Bool #

Show ann => Show (Deps ann) Source # 

Methods

showsPrec :: Int -> Deps ann -> ShowS #

show :: Deps ann -> String #

showList :: [Deps ann] -> ShowS #

Generic (Deps ann) Source # 

Associated Types

type Rep (Deps ann) :: * -> * #

Methods

from :: Deps ann -> Rep (Deps ann) x #

to :: Rep (Deps ann) x -> Deps ann #

Arbitrary ann => Arbitrary (Deps ann) Source #

Reasonable Arbitrary instance for Deps.

Since: 0.1.0

Methods

arbitrary :: Gen (Deps ann) #

shrink :: Deps ann -> [Deps ann] #

Hashable ann => Hashable (Deps ann) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Deps ann -> Int #

hash :: Deps ann -> Int #

ToJSON ann => ToJSON (Deps ann) Source #

Converts to {ann: …, normal: …, implicit: …, order-only: …}.

Since: 0.1.0

Methods

toJSON :: Deps ann -> Value #

toEncoding :: Deps ann -> Encoding #

toJSONList :: [Deps ann] -> Value #

toEncodingList :: [Deps ann] -> Encoding #

FromJSON ann => FromJSON (Deps ann) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Deps ann) #

parseJSONList :: Value -> Parser [Deps ann] #

NFData ann => NFData (Deps ann) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Deps ann -> () #

type Rep (Deps ann) Source # 
type Rep (Deps ann) = D1 (MetaData "Deps" "Language.Ninja.AST.Deps" "language-ninja-0.1.0-CTXTL0Lugm4Llo91nN4SIr" False) (C1 (MetaCons "MkDeps" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "_depsAnn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ann)) (S1 (MetaSel (Just Symbol "_depsNormal") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashSet Text)))) ((:*:) (S1 (MetaSel (Just Symbol "_depsImplicit") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashSet Text))) (S1 (MetaSel (Just Symbol "_depsOrderOnly") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashSet Text))))))

makeDeps :: Monoid ann => Deps ann Source #

Construct a Deps with all default values

Since: 0.1.0

depsNormal :: Lens' (Deps ann) (HashSet Text) Source #

A lens into the set of normal dependencies in a Deps.

Since: 0.1.0

depsImplicit :: Lens' (Deps ann) (HashSet Text) Source #

A lens into the set of implicit dependencies in a Deps.

Since: 0.1.0

depsOrderOnly :: Lens' (Deps ann) (HashSet Text) Source #

A lens into the set of order-only dependencies in a Deps.

Since: 0.1.0

Language.Ninja.AST.Rule

data Rule ann Source #

A parsed Ninja rule declaration.

Since: 0.1.0

Instances

Functor Rule Source # 

Methods

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

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

Foldable Rule Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Rule a -> [a] #

null :: Rule a -> Bool #

length :: Rule a -> Int #

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

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

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

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

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

Traversable Rule Source # 

Methods

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

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

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

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

Annotated Rule Source #

The usual definition for Annotated.

Since: 0.1.0

Methods

annotation' :: (ann -> ann') -> Lens (Rule ann) (Rule ann') ann ann' Source #

(Monad m, RuleConstraint (Serial m) ann) => Serial m (Rule ann) Source #

Default Serial instance via Generic.

Since: 0.1.0

Methods

series :: Series m (Rule ann) #

(Monad m, RuleConstraint (CoSerial m) ann) => CoSerial m (Rule ann) Source #

Default CoSerial instance via Generic.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Rule ann -> b) #

Eq ann => Eq (Rule ann) Source # 

Methods

(==) :: Rule ann -> Rule ann -> Bool #

(/=) :: Rule ann -> Rule ann -> Bool #

Show ann => Show (Rule ann) Source # 

Methods

showsPrec :: Int -> Rule ann -> ShowS #

show :: Rule ann -> String #

showList :: [Rule ann] -> ShowS #

Generic (Rule ann) Source # 

Associated Types

type Rep (Rule ann) :: * -> * #

Methods

from :: Rule ann -> Rep (Rule ann) x #

to :: Rep (Rule ann) x -> Rule ann #

Arbitrary ann => Arbitrary (Rule ann) Source #

Reasonable Arbitrary instance for Rule.

Since: 0.1.0

Methods

arbitrary :: Gen (Rule ann) #

shrink :: Rule ann -> [Rule ann] #

Hashable ann => Hashable (Rule ann) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Rule ann -> Int #

hash :: Rule ann -> Int #

ToJSON ann => ToJSON (Rule ann) Source #

Converts to {ann: …, bind: …}.

Since: 0.1.0

Methods

toJSON :: Rule ann -> Value #

toEncoding :: Rule ann -> Encoding #

toJSONList :: [Rule ann] -> Value #

toEncodingList :: [Rule ann] -> Encoding #

FromJSON ann => FromJSON (Rule ann) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Rule ann) #

parseJSONList :: Value -> Parser [Rule ann] #

NFData ann => NFData (Rule ann) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Rule ann -> () #

type Rep (Rule ann) Source # 
type Rep (Rule ann) = D1 (MetaData "Rule" "Language.Ninja.AST.Rule" "language-ninja-0.1.0-CTXTL0Lugm4Llo91nN4SIr" False) (C1 (MetaCons "MkRule" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_ruleAnn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ann)) (S1 (MetaSel (Just Symbol "_ruleBind") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashMap Text (Expr ann))))))

makeRule :: Monoid ann => Rule ann Source #

Construct a Rule with all default values

Since: 0.1.0

ruleBind :: Lens' (Rule ann) (HashMap Text (Expr ann)) Source #

The set of bindings in scope during the execution of this rule.

Since: 0.1.0

Language.Ninja.AST.Expr

data Expr ann Source #

An expression containing variable references in the Ninja language.

Since: 0.1.0

Constructors

Exprs !ann ![Expr ann]

Sequencing of expressions.

Since: 0.1.0

Lit !ann !Text

A literal string.

Since: 0.1.0

Var !ann !Text

A variable reference.

Since: 0.1.0

Instances

Functor Expr Source # 

Methods

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

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

Foldable Expr Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Expr a -> [a] #

null :: Expr a -> Bool #

length :: Expr a -> Int #

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

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

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

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

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

Traversable Expr Source # 

Methods

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

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

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

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

Annotated Expr Source #

The usual definition for Annotated.

Since: 0.1.0

Methods

annotation' :: (ann -> ann') -> Lens (Expr ann) (Expr ann') ann ann' Source #

(Monad m, ExprConstraint (Serial m) ann) => Serial m (Expr ann) Source #

Default Serial instance via Generic.

Since: 0.1.0

Methods

series :: Series m (Expr ann) #

(Monad m, ExprConstraint (CoSerial m) ann) => CoSerial m (Expr ann) Source #

Default CoSerial instance via Generic.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Expr ann -> b) #

Eq ann => Eq (Expr ann) Source # 

Methods

(==) :: Expr ann -> Expr ann -> Bool #

(/=) :: Expr ann -> Expr ann -> Bool #

Data ann => Data (Expr ann) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Expr ann -> c (Expr ann) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Expr ann) #

toConstr :: Expr ann -> Constr #

dataTypeOf :: Expr ann -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Expr ann)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr ann)) #

gmapT :: (forall b. Data b => b -> b) -> Expr ann -> Expr ann #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr ann -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr ann -> r #

gmapQ :: (forall d. Data d => d -> u) -> Expr ann -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Expr ann -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Expr ann -> m (Expr ann) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr ann -> m (Expr ann) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr ann -> m (Expr ann) #

Show ann => Show (Expr ann) Source # 

Methods

showsPrec :: Int -> Expr ann -> ShowS #

show :: Expr ann -> String #

showList :: [Expr ann] -> ShowS #

Generic (Expr ann) Source # 

Associated Types

type Rep (Expr ann) :: * -> * #

Methods

from :: Expr ann -> Rep (Expr ann) x #

to :: Rep (Expr ann) x -> Expr ann #

Arbitrary ann => Arbitrary (Expr ann) Source #

Reasonable Arbitrary instance for Expr.

Since: 0.1.0

Methods

arbitrary :: Gen (Expr ann) #

shrink :: Expr ann -> [Expr ann] #

Hashable ann => Hashable (Expr ann) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Expr ann -> Int #

hash :: Expr ann -> Int #

ToJSON ann => ToJSON (Expr ann) Source #

Converts Exprs to {ann: …, exprs: […]}, Lit to {ann: …, lit: […]}, and Var to {ann: …, var: …}.

Since: 0.1.0

Methods

toJSON :: Expr ann -> Value #

toEncoding :: Expr ann -> Encoding #

toJSONList :: [Expr ann] -> Value #

toEncodingList :: [Expr ann] -> Encoding #

FromJSON ann => FromJSON (Expr ann) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Expr ann) #

parseJSONList :: Value -> Parser [Expr ann] #

NFData ann => NFData (Expr ann) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Expr ann -> () #

Data ann => Plated (Expr ann) Source #

The usual definition for Plated.

Since: 0.1.0

Methods

plate :: Traversal' (Expr ann) (Expr ann) #

type Rep (Expr ann) Source # 

_Exprs :: Prism' (Expr ann) (ann, [Expr ann]) Source #

A prism for the Exprs constructor.

Since: 0.1.0

_Lit :: Prism' (Expr ann) (ann, Text) Source #

A prism for the Lit constructor.

Since: 0.1.0

_Var :: Prism' (Expr ann) (ann, Text) Source #

A prism for the Var constructor.

Since: 0.1.0

askVar :: Env Text Text -> Text -> Text Source #

Look up the given variable in the given context, returning the empty string if the variable was not found.

Since: 0.1.0

askExpr :: Env Text Text -> Expr ann -> Text Source #

Evaluate the given Expr in the given context (Env Text Text).

Since: 0.1.0

addBind :: Text -> Expr ann -> Env Text Text -> Env Text Text Source #

Add a binding with the given name (Text) and value (Expr) to the given context.

Since: 0.1.0

addBinds :: [(Text, Expr ann)] -> Env Text Text -> Env Text Text Source #

Add bindings from a list. Note that this function evaluates all the right-hand-sides first, and then adds them all to the environment.

For example:

>>> :set -XOverloadedStrings
>>> let binds = [("x", Lit () "5"), ("y", Var () "x")]
>>> AST.headEnv (addBinds binds AST.makeEnv)
fromList [("x","5"),("y","")]

Since: 0.1.0

normalizeExpr :: forall ann. Monoid ann => Expr ann -> Expr ann Source #

Normalize an Expr by recursively flattening any Exprs nodes, removing empty Lit nodes, combining adjacent Lit nodes, and pulling out the interior of the top-level Exprs node if it has only one subnode.

The number of Exprs nodes in the output is guaranteed to be 0 or 1.

If it is 0, then there is exactly one node of any type in the output.

The output is thus isomorphic to (Maybe ann, [(ann, Either Text Text)]), where the Maybe ann represents the annotation of the top-level Exprs node if it exists.

Since: 0.1.0

Language.Ninja.AST.Env

data Env k v Source #

A Ninja-style environment, basically a nonempty list of hash tables.

Since: 0.1.0

Instances

(Monad m, EnvConstraint (Serial m) k v) => Serial m (Env k v) Source #

Uses the underlying Maps instance.

Since: 0.1.0

Methods

series :: Series m (Env k v) #

(Monad m, EnvConstraint (CoSerial m) k v) => CoSerial m (Env k v) Source #

Uses the underlying Maps instance.

Since: 0.1.0

Methods

coseries :: Series m b -> Series m (Env k v -> b) #

(Eq v, Eq k) => Eq (Env k v) Source # 

Methods

(==) :: Env k v -> Env k v -> Bool #

(/=) :: Env k v -> Env k v -> Bool #

(Show v, Show k) => Show (Env k v) Source # 

Methods

showsPrec :: Int -> Env k v -> ShowS #

show :: Env k v -> String #

showList :: [Env k v] -> ShowS #

Generic (Env k v) Source # 

Associated Types

type Rep (Env k v) :: * -> * #

Methods

from :: Env k v -> Rep (Env k v) x #

to :: Rep (Env k v) x -> Env k v #

(Key k, Arbitrary k, Arbitrary v) => Arbitrary (Env k v) Source #

Reasonable Arbitrary instance for Env.

Since: 0.1.0

Methods

arbitrary :: Gen (Env k v) #

shrink :: Env k v -> [Env k v] #

(Hashable k, Hashable v) => Hashable (Env k v) Source #

Default Hashable instance via Generic.

Since: 0.1.0

Methods

hashWithSalt :: Int -> Env k v -> Int #

hash :: Env k v -> Int #

(ToJSONKey k, ToJSON v) => ToJSON (Env k v) Source #

Converts to a (nonempty) array of JSON objects.

Since: 0.1.0

Methods

toJSON :: Env k v -> Value #

toEncoding :: Env k v -> Encoding #

toJSONList :: [Env k v] -> Value #

toEncodingList :: [Env k v] -> Encoding #

(Key k, FromJSONKey k, FromJSON v) => FromJSON (Env k v) Source #

Inverse of the ToJSON instance.

Since: 0.1.0

Methods

parseJSON :: Value -> Parser (Env k v) #

parseJSONList :: Value -> Parser [Env k v] #

(NFData k, NFData v) => NFData (Env k v) Source #

Default NFData instance via Generic.

Since: 0.1.0

Methods

rnf :: Env k v -> () #

type Rep (Env k v) Source # 
type Rep (Env k v) = D1 (MetaData "Env" "Language.Ninja.AST.Env" "language-ninja-0.1.0-CTXTL0Lugm4Llo91nN4SIr" True) (C1 (MetaCons "MkEnv" PrefixI True) (S1 (MetaSel (Just Symbol "_fromEnv") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maps k v))))

makeEnv :: Env k v Source #

Construct an empty environment.

Since: 0.1.0

fromEnv :: Iso' (Env k v) (Maps k v) Source #

An isomorphism between an Env and a nonempty list of HashMaps.

Since: 0.1.0

addEnv :: Key k => k -> v -> Env k v -> Env k v Source #

Add the given key and value to the given Env.

Since: 0.1.0

askEnv :: Key k => Env k v -> k -> Maybe v Source #

Look up the given key in the given Env.

Since: 0.1.0

scopeEnv :: Env k v -> Env k v Source #

Push a new Env onto the stack.

Since: 0.1.0