bricks-syntax-0.0.0.4: ...

Bricks.Expression.Construction

Description

Functions for constructing Expressions that match the Show implementations.

This module is only designed for testing and REPL use. It isn't re-exported into the main Bricks API because it's a bit messy:

• There are a lot of terse function names here that would clash with other things easily.
• Some functions are partial, such as those that require strings that can be rendered unquoted.
• It uses string overloading in a way that the regular API probably shouldn't.
• The functions are oriented toward constructing Expressions, skipping over the intermediary types they're composed of, which is convenient but may make them insufficient for some use cases.

Synopsis

# Dynamic strings

newtype Str'1'IsString Source #

A newtype for Str'1 just so we can give it the IsString instance which would be dubiously appropriate for the actual Str'1 type.

Constructors

 Str'1'IsString FieldsunStr'1'IsString :: Str'1

Instances

 Source # Methods

# Param builder

newtype Param'Builder Source #

Constructors

 Param'Builder (NonEmpty Param)

Instances

 Source # Methodsstimes :: Integral b => b -> Param'Builder -> Param'Builder #

# Re-exports

Instances

 Source # This instance is designed for doctests and REPL experimentation. The format is designed to strike a balance in verbosity between the derived Show implementations (which are unwieldily long) and the Bricks language itself (which is quite terse but unsuitable for demonstrating the parser, as outputting a Bricks rendering of parse result wouldn't illumunate anyone's understanding of the AST that the Show instances are here to depict). MethodsshowList :: [Expression] -> ShowS #

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

(a <> b) <> c = a <> (b <> c)


If a is also a Monoid we further require

(<>) = mappend


(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

Since: 4.8.0.0

data Maybe a :: * -> * #

The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error.

The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

Constructors

 Nothing Just a

Instances

 Since: 2.1 Methods(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b #(>>) :: Maybe a -> Maybe b -> Maybe b #return :: a -> Maybe a #fail :: String -> Maybe a # Since: 2.1 Methodsfmap :: (a -> b) -> Maybe a -> Maybe b #(<\$) :: a -> Maybe b -> Maybe a # Since: 2.1 Methodspure :: a -> Maybe a #(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b #liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c #(*>) :: Maybe a -> Maybe b -> Maybe b #(<*) :: Maybe a -> Maybe b -> Maybe a # Since: 2.1 Methodsfold :: Monoid m => Maybe m -> m #foldMap :: Monoid m => (a -> m) -> Maybe a -> m #foldr :: (a -> b -> b) -> b -> Maybe a -> b #foldr' :: (a -> b -> b) -> b -> Maybe a -> b #foldl :: (b -> a -> b) -> b -> Maybe a -> b #foldl' :: (b -> a -> b) -> b -> Maybe a -> b #foldr1 :: (a -> a -> a) -> Maybe a -> a #foldl1 :: (a -> a -> a) -> Maybe a -> a #toList :: Maybe a -> [a] #null :: Maybe a -> Bool #length :: Maybe a -> Int #elem :: Eq a => a -> Maybe a -> Bool #maximum :: Ord a => Maybe a -> a #minimum :: Ord a => Maybe a -> a #sum :: Num a => Maybe a -> a #product :: Num a => Maybe a -> a # Since: 2.1 Methodsempty :: Maybe a #(<|>) :: Maybe a -> Maybe a -> Maybe a #some :: Maybe a -> Maybe [a] #many :: Maybe a -> Maybe [a] # Since: 2.1 Methodsmzero :: Maybe a #mplus :: Maybe a -> Maybe a -> Maybe a # Eq a => Eq (Maybe a) Methods(==) :: Maybe a -> Maybe a -> Bool #(/=) :: Maybe a -> Maybe a -> Bool # Ord a => Ord (Maybe a) Methodscompare :: Maybe a -> Maybe a -> Ordering #(<) :: Maybe a -> Maybe a -> Bool #(<=) :: Maybe a -> Maybe a -> Bool #(>) :: Maybe a -> Maybe a -> Bool #(>=) :: Maybe a -> Maybe a -> Bool #max :: Maybe a -> Maybe a -> Maybe a #min :: Maybe a -> Maybe a -> Maybe a # Show a => Show (Maybe a) MethodsshowsPrec :: Int -> Maybe a -> ShowS #show :: Maybe a -> String #showList :: [Maybe a] -> ShowS # Semigroup a => Semigroup (Maybe a) Since: 4.9.0.0 Methods(<>) :: Maybe a -> Maybe a -> Maybe a #sconcat :: NonEmpty (Maybe a) -> Maybe a #stimes :: Integral b => b -> Maybe a -> Maybe a # Monoid a => Monoid (Maybe a) Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there used to be no "Semigroup" typeclass providing just mappend, we use Monoid instead.Since: 2.1 Methodsmempty :: Maybe a #mappend :: Maybe a -> Maybe a -> Maybe a #mconcat :: [Maybe a] -> Maybe a # type (==) (Maybe k) a b type (==) (Maybe k) a b = EqMaybe k a b