-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A parser generator -- -- Ptera is haskell libraries and toolchains for generating parser. @package ptera-core @version 0.1.0.0 module Language.Parser.Ptera.Prelude -- | Append two lists, i.e., -- --
-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] -- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] ---- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] infixr 5 ++ -- | The value of seq a b is bottom if a is bottom, and -- otherwise equal to b. In other words, it evaluates the first -- argument a to weak head normal form (WHNF). seq is -- usually introduced to improve performance by avoiding unneeded -- laziness. -- -- A note on evaluation order: the expression seq a b does -- not guarantee that a will be evaluated before -- b. The only guarantee given by seq is that the both -- a and b will be evaluated before seq -- returns a value. In particular, this means that b may be -- evaluated before a. If you need to guarantee a specific order -- of evaluation, you must use the function pseq from the -- "parallel" package. seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b infixr 0 `seq` -- | <math>. filter, applied to a predicate and a list, -- returns the list of those elements that satisfy the predicate; i.e., -- --
-- filter p xs = [ x | x <- xs, p x] ---- --
-- >>> filter odd [1, 2, 3] -- [1,3] --filter :: (a -> Bool) -> [a] -> [a] -- | <math>. zip takes two lists and returns a list of -- corresponding pairs. -- --
-- zip [1, 2] ['a', 'b'] = [(1, 'a'), (2, 'b')] ---- -- If one input list is short, excess elements of the longer list are -- discarded: -- --
-- zip [1] ['a', 'b'] = [(1, 'a')] -- zip [1, 2] ['a'] = [(1, 'a')] ---- -- zip is right-lazy: -- --
-- zip [] _|_ = [] -- zip _|_ [] = _|_ ---- -- zip is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zip :: [a] -> [b] -> [(a, b)] -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- --
-- main = print ([(n, 2^n) | n <- [0..19]]) --print :: Show a => a -> IO () -- | Extract the first component of a pair. fst :: (a, b) -> a -- | Extract the second component of a pair. snd :: (a, b) -> b -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
-- f x | x < 0 = ... -- | otherwise = ... --otherwise :: Bool -- | <math>. map f xs is the list obtained by -- applying f to each element of xs, i.e., -- --
-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] -- map f [x1, x2, ...] == [f x1, f x2, ...] ---- --
-- >>> map (+1) [1, 2, 3] --map :: (a -> b) -> [a] -> [b] -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- --
-- enumFrom x = enumFromTo x maxBound -- enumFromThen x y = enumFromThenTo x y bound -- where -- bound | fromEnum y >= fromEnum x = maxBound -- | otherwise = minBound --class Enum a -- | the successor of a value. For numeric types, succ adds 1. succ :: Enum a => a -> a -- | the predecessor of a value. For numeric types, pred subtracts -- 1. pred :: Enum a => a -> a -- | Convert from an Int. toEnum :: Enum a => Int -> a -- | Convert to an Int. It is implementation-dependent what -- fromEnum returns when applied to a value that is too large to -- fit in an Int. fromEnum :: Enum a => a -> Int -- | Used in Haskell's translation of [n..] with [n..] = -- enumFrom n, a possible implementation being enumFrom n = n : -- enumFrom (succ n). For example: -- --
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: -- Int]
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: -- Int]
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo 4 2 -6 :: [Integer] = -- [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
-- (x `quot` y)*y + (x `rem` y) == x --rem :: Integral a => a -> a -> a -- | integer division truncated toward negative infinity div :: Integral a => a -> a -> a -- | integer modulus, satisfying -- --
-- (x `div` y)*y + (x `mod` y) == x --mod :: Integral a => a -> a -> a -- | simultaneous quot and rem quotRem :: Integral a => a -> a -> (a, a) -- | simultaneous div and mod divMod :: Integral a => a -> a -> (a, a) -- | conversion to Integer toInteger :: Integral a => a -> Integer infixl 7 `mod` infixl 7 `div` infixl 7 `rem` infixl 7 `quot` -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following: -- --
-- do a <- as -- bs a --(>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. -- -- 'as >> bs' can be understood as the do -- expression -- --
-- do as -- bs --(>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a infixl 1 >>= infixl 1 >> -- | A type f is a Functor if it provides a function fmap -- which, given any types a and b lets you apply any -- function from (a -> b) to turn an f a into an -- f b, preserving the structure of f. Furthermore -- f needs to adhere to the following: -- -- -- -- Note, that the second law follows from the free theorem of the type -- fmap and the first law, so you need only check that the former -- condition holds. class Functor (f :: Type -> Type) -- | Using ApplicativeDo: 'fmap f as' can be -- understood as the do expression -- --
-- do a <- as -- pure (f a) ---- -- with an inferred Functor constraint. fmap :: Functor f => (a -> b) -> f a -> f b -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. -- -- Using ApplicativeDo: 'a <$ bs' can be -- understood as the do expression -- --
-- do bs -- pure a ---- -- with an inferred Functor constraint. (<$) :: Functor f => a -> f b -> f a infixl 4 <$ -- | Basic numeric class. -- -- The Haskell Report defines no laws for Num. However, -- (+) and (*) are customarily expected -- to define a ring and have the following properties: -- --
-- abs x * signum x == x ---- -- For real numbers, the signum is either -1 (negative), -- 0 (zero) or 1 (positive). signum :: Num a => a -> a -- | Conversion from an Integer. An integer literal represents the -- application of the function fromInteger to the appropriate -- value of type Integer, so such literals have type -- (Num a) => a. fromInteger :: Num a => Integer -> a infixl 6 - infixl 6 + infixl 7 * -- | The Ord class is used for totally ordered datatypes. -- -- Instances of Ord can be derived for any user-defined datatype -- whose constituent types are in Ord. The declared order of the -- constructors in the data declaration determines the ordering in -- derived Ord instances. The Ordering datatype allows a -- single comparison to determine the precise ordering of two objects. -- -- The Haskell Report defines no laws for Ord. However, -- <= is customarily expected to implement a non-strict partial -- order and have the following properties: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Read in Haskell 2010 is equivalent to -- --
-- instance (Read a) => Read (Tree a) where
--
-- readsPrec d r = readParen (d > app_prec)
-- (\r -> [(Leaf m,t) |
-- ("Leaf",s) <- lex r,
-- (m,t) <- readsPrec (app_prec+1) s]) r
--
-- ++ readParen (d > up_prec)
-- (\r -> [(u:^:v,w) |
-- (u,s) <- readsPrec (up_prec+1) r,
-- (":^:",t) <- lex s,
-- (v,w) <- readsPrec (up_prec+1) t]) r
--
-- where app_prec = 10
-- up_prec = 5
--
--
-- Note that right-associativity of :^: is unused.
--
-- The derived instance in GHC is equivalent to
--
-- -- instance (Read a) => Read (Tree a) where -- -- readPrec = parens $ (prec app_prec $ do -- Ident "Leaf" <- lexP -- m <- step readPrec -- return (Leaf m)) -- -- +++ (prec up_prec $ do -- u <- step readPrec -- Symbol ":^:" <- lexP -- v <- step readPrec -- return (u :^: v)) -- -- where app_prec = 10 -- up_prec = 5 -- -- readListPrec = readListPrecDefault ---- -- Why do both readsPrec and readPrec exist, and why does -- GHC opt to implement readPrec in derived Read instances -- instead of readsPrec? The reason is that readsPrec is -- based on the ReadS type, and although ReadS is mentioned -- in the Haskell 2010 Report, it is not a very efficient parser data -- structure. -- -- readPrec, on the other hand, is based on a much more efficient -- ReadPrec datatype (a.k.a "new-style parsers"), but its -- definition relies on the use of the RankNTypes language -- extension. Therefore, readPrec (and its cousin, -- readListPrec) are marked as GHC-only. Nevertheless, it is -- recommended to use readPrec instead of readsPrec -- whenever possible for the efficiency improvements it brings. -- -- As mentioned above, derived Read instances in GHC will -- implement readPrec instead of readsPrec. The default -- implementations of readsPrec (and its cousin, readList) -- will simply use readPrec under the hood. If you are writing a -- Read instance by hand, it is recommended to write it like so: -- --
-- instance Read T where -- readPrec = ... -- readListPrec = readListPrecDefault --class Read a -- | attempts to parse a value from the front of the string, returning a -- list of (parsed value, remaining string) pairs. If there is no -- successful parse, the returned list is empty. -- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. readsPrec :: Read a => Int -> ReadS a -- | The method readList is provided to allow the programmer to give -- a specialised way of parsing lists of values. For example, this is -- used by the predefined Read instance of the Char type, -- where values of type String should be are expected to use -- double quotes, rather than square brackets. readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a -- | a constant function, returning the radix of the representation (often -- 2) floatRadix :: RealFloat a => a -> Integer -- | a constant function, returning the number of digits of -- floatRadix in the significand floatDigits :: RealFloat a => a -> Int -- | a constant function, returning the lowest and highest values the -- exponent may assume floatRange :: RealFloat a => a -> (Int, Int) -- | The function decodeFloat applied to a real floating-point -- number returns the significand expressed as an Integer and an -- appropriately scaled exponent (an Int). If -- decodeFloat x yields (m,n), then x -- is equal in value to m*b^^n, where b is the -- floating-point radix, and furthermore, either m and -- n are both zero or else b^(d-1) <= abs m < -- b^d, where d is the value of floatDigits -- x. In particular, decodeFloat 0 = (0,0). If the -- type contains a negative zero, also decodeFloat (-0.0) = -- (0,0). The result of decodeFloat x is -- unspecified if either of isNaN x or -- isInfinite x is True. decodeFloat :: RealFloat a => a -> (Integer, Int) -- | encodeFloat performs the inverse of decodeFloat in the -- sense that for finite x with the exception of -0.0, -- uncurry encodeFloat (decodeFloat x) = x. -- encodeFloat m n is one of the two closest -- representable floating-point numbers to m*b^^n (or -- ±Infinity if overflow occurs); usually the closer, but if -- m contains too many bits, the result may be rounded in the -- wrong direction. encodeFloat :: RealFloat a => Integer -> Int -> a -- | exponent corresponds to the second component of -- decodeFloat. exponent 0 = 0 and for finite -- nonzero x, exponent x = snd (decodeFloat x) -- + floatDigits x. If x is a finite floating-point -- number, it is equal in value to significand x * b ^^ -- exponent x, where b is the floating-point radix. -- The behaviour is unspecified on infinite or NaN values. exponent :: RealFloat a => a -> Int -- | The first component of decodeFloat, scaled to lie in the open -- interval (-1,1), either 0.0 or of absolute -- value >= 1/b, where b is the floating-point -- radix. The behaviour is unspecified on infinite or NaN -- values. significand :: RealFloat a => a -> a -- | multiplies a floating-point number by an integer power of the radix scaleFloat :: RealFloat a => Int -> a -> a -- | True if the argument is an IEEE "not-a-number" (NaN) value isNaN :: RealFloat a => a -> Bool -- | True if the argument is an IEEE infinity or negative infinity isInfinite :: RealFloat a => a -> Bool -- | True if the argument is too small to be represented in -- normalized format isDenormalized :: RealFloat a => a -> Bool -- | True if the argument is an IEEE negative zero isNegativeZero :: RealFloat a => a -> Bool -- | True if the argument is an IEEE floating point number isIEEE :: RealFloat a => a -> Bool -- | a version of arctangent taking two real floating-point arguments. For -- real floating x and y, atan2 y x -- computes the angle (from the positive x-axis) of the vector from the -- origin to the point (x,y). atan2 y x returns -- a value in the range [-pi, pi]. It follows the -- Common Lisp semantics for the origin when signed zeroes are supported. -- atan2 y 1, with y in a type that is -- RealFloat, should return the same value as atan -- y. A default definition of atan2 is provided, but -- implementors can provide a more accurate implementation. atan2 :: RealFloat a => a -> a -> a -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | The function properFraction takes a real fractional number -- x and returns a pair (n,f) such that x = -- n+f, and: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Show is equivalent to -- --
-- instance (Show a) => Show (Tree a) where -- -- showsPrec d (Leaf m) = showParen (d > app_prec) $ -- showString "Leaf " . showsPrec (app_prec+1) m -- where app_prec = 10 -- -- showsPrec d (u :^: v) = showParen (d > up_prec) $ -- showsPrec (up_prec+1) u . -- showString " :^: " . -- showsPrec (up_prec+1) v -- where up_prec = 5 ---- -- Note that right-associativity of :^: is ignored. For example, -- --
-- showsPrec d x r ++ s == showsPrec d x (r ++ s) ---- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. showsPrec :: Show a => Int -> a -> ShowS -- | A specialised variant of showsPrec, using precedence context -- zero, and returning an ordinary String. show :: Show a => a -> String -- | The method showList is provided to allow the programmer to give -- a specialised way of showing lists of values. For example, this is -- used by the predefined Show instance of the Char type, -- where values of type String should be shown in double quotes, -- rather than between square brackets. showList :: Show a => [a] -> ShowS -- | When a value is bound in do-notation, the pattern on the left -- hand side of <- might not match. In this case, this class -- provides a function to recover. -- -- A Monad without a MonadFail instance may only be used in -- conjunction with pattern that always match, such as newtypes, tuples, -- data types with only a single data constructor, and irrefutable -- patterns (~pat). -- -- Instances of MonadFail should satisfy the following law: -- fail s should be a left zero for >>=, -- --
-- fail s >>= f = fail s ---- -- If your Monad is also MonadPlus, a popular definition is -- --
-- fail _ = mzero --class Monad m => MonadFail (m :: Type -> Type) fail :: MonadFail m => String -> m a -- | A functor with application, providing operations to -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- -- Using ApplicativeDo: 'fs <*> as' can be -- understood as the do expression -- --
-- do f <- fs -- a <- as -- pure (f a) --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Sequence actions, discarding the value of the first argument. -- -- 'as *> bs' can be understood as the do -- expression -- --
-- do as -- bs ---- -- This is a tad complicated for our ApplicativeDo extension -- which will give it a Monad constraint. For an -- Applicative constraint we write it of the form -- --
-- do _ <- as -- b <- bs -- pure b --(*>) :: Applicative f => f a -> f b -> f b -- | Sequence actions, discarding the value of the second argument. -- -- Using ApplicativeDo: 'as <* bs' can be -- understood as the do expression -- --
-- do a <- as -- bs -- pure a --(<*) :: Applicative f => f a -> f b -> f a infixl 4 <* infixl 4 *> infixl 4 <*> -- | Data structures that can be folded. -- -- For example, given a data type -- --
-- data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) ---- -- a suitable instance would be -- --
-- instance Foldable Tree where -- foldMap f Empty = mempty -- foldMap f (Leaf x) = f x -- foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r ---- -- This is suitable even for abstract types, as the monoid is assumed to -- satisfy the monoid laws. Alternatively, one could define -- foldr: -- --
-- instance Foldable Tree where -- foldr f z Empty = z -- foldr f z (Leaf x) = f x z -- foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l ---- -- Foldable instances are expected to satisfy the following -- laws: -- --
-- foldr f z t = appEndo (foldMap (Endo . f) t ) z ---- --
-- foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z ---- --
-- fold = foldMap id ---- --
-- length = getSum . foldMap (Sum . const 1) ---- -- sum, product, maximum, and minimum -- should all be essentially equivalent to foldMap forms, such -- as -- --
-- sum = getSum . foldMap Sum ---- -- but may be less defined. -- -- If the type is also a Functor instance, it should satisfy -- --
-- foldMap f = fold . fmap f ---- -- which implies that -- --
-- foldMap f . fmap g = foldMap (f . g) --class Foldable (t :: Type -> Type) -- | Map each element of the structure to a monoid, and combine the -- results. foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | A variant of foldr that has no base case, and thus may only be -- applied to non-empty structures. -- --
-- foldr1 f = foldr1 f . toList --foldr1 :: Foldable t => (a -> a -> a) -> t a -> a -- | A variant of foldl that has no base case, and thus may only be -- applied to non-empty structures. -- --
-- foldl1 f = foldl1 f . toList --foldl1 :: Foldable t => (a -> a -> a) -> t a -> a -- | Test whether the structure is empty. The default implementation is -- optimized for structures that are similar to cons-lists, because there -- is no general way to do better. null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation is optimized for structures that are similar to -- cons-lists, because there is no general way to do better. length :: Foldable t => t a -> Int -- | Does the element occur in the structure? elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The largest element of a non-empty structure. maximum :: (Foldable t, Ord a) => t a -> a -- | The least element of a non-empty structure. minimum :: (Foldable t, Ord a) => t a -> a -- | The sum function computes the sum of the numbers of a -- structure. sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | Functors representing data structures that can be traversed from left -- to right. -- -- A definition of traverse must satisfy the following laws: -- --
-- t :: (Applicative f, Applicative g) => f a -> g a ---- -- preserving the Applicative operations, i.e. -- --
-- t (pure x) = pure x -- t (f <*> x) = t f <*> t x ---- -- and the identity functor Identity and composition functors -- Compose are from Data.Functor.Identity and -- Data.Functor.Compose. -- -- A result of the naturality law is a purity law for traverse -- --
-- traverse pure = pure ---- -- (The naturality law is implied by parametricity and thus so is the -- purity law [1, p15].) -- -- Instances are similar to Functor, e.g. given a data type -- --
-- data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) ---- -- a suitable instance would be -- --
-- instance Traversable Tree where -- traverse f Empty = pure Empty -- traverse f (Leaf x) = Leaf <$> f x -- traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r ---- -- This is suitable even for abstract types, as the laws for -- <*> imply a form of associativity. -- -- The superclass instances should satisfy the following: -- --
-- >>> [1,2,3] <> [4,5,6] -- [1,2,3,4,5,6] --(<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following: -- --
-- >>> "Hello world" <> mempty -- "Hello world" --mempty :: Monoid a => a -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a -- | Fold a list using the monoid. -- -- For most types, the default definition for mconcat will be -- used, but the function is included in the class definition so that an -- optimized version can be provided for specific types. -- --
-- >>> mconcat ["Hello", " ", "Haskell", "!"] -- "Hello Haskell!" --mconcat :: Monoid a => [a] -> a data Bool False :: Bool True :: Bool -- | The character type Char is an enumeration whose values -- represent Unicode (or equivalently ISO/IEC 10646) code points (i.e. -- characters, see http://www.unicode.org/ for details). This set -- extends the ISO 8859-1 (Latin-1) character set (the first 256 -- characters), which is itself an extension of the ASCII character set -- (the first 128 characters). A character literal in Haskell has type -- Char. -- -- To convert a Char to or from the corresponding Int value -- defined by Unicode, use toEnum and fromEnum from the -- Enum class respectively (or equivalently ord and -- chr). data Char -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double -- | Single-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- single-precision type. data Float -- | A fixed-precision integer type with at least the range [-2^29 .. -- 2^29-1]. The exact range for a given implementation can be -- determined by using minBound and maxBound from the -- Bounded class. data Int -- | Arbitrary precision integers. In contrast with fixed-size integral -- types such as Int, the Integer type represents the -- entire infinite range of integers. -- -- For more information about this type's representation, see the -- comments in its implementation. data Integer -- | 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. data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Arbitrary-precision rational numbers, represented as a ratio of two -- Integer values. A rational number may be constructed using the -- % operator. type Rational = Ratio Integer -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= -- operations from the Monad class. data IO a -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> s -- Left "foo" -- -- >>> let n = Right 3 :: Either String Int -- -- >>> n -- Right 3 -- -- >>> :type s -- s :: Either String Int -- -- >>> :type n -- n :: Either String Int ---- -- The fmap from our Functor instance will ignore -- Left values, but will apply the supplied function to values -- contained in a Right: -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> fmap (*2) s -- Left "foo" -- -- >>> fmap (*2) n -- Right 6 ---- -- The Monad instance for Either allows us to chain -- together multiple actions which may fail, and fail overall if any of -- the individual steps failed. First we'll write a function that can -- either parse an Int from a Char, or fail. -- --
-- >>> import Data.Char ( digitToInt, isDigit )
--
-- >>> :{
-- let parseEither :: Char -> Either String Int
-- parseEither c
-- | isDigit c = Right (digitToInt c)
-- | otherwise = Left "parse error"
--
-- >>> :}
--
--
-- The following should work, since both '1' and '2'
-- can be parsed as Ints.
--
--
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither '1'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Right 3 ---- -- But the following should fail overall, since the first operation where -- we attempt to parse 'm' as an Int will fail: -- --
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither 'm'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Left "parse error" --data Either a b Left :: a -> Either a b Right :: b -> Either a b -- | The readIO function is similar to read except that it -- signals parse failure to the IO monad instead of terminating -- the program. readIO :: Read a => String -> IO a -- | The readLn function combines getLine and readIO. readLn :: Read a => IO a -- | The computation appendFile file str function appends -- the string str, to the file file. -- -- Note that writeFile and appendFile write a literal -- string to a file. To write a value of any printable type, as with -- print, use the show function to convert the value to a -- string first. -- --
-- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) --appendFile :: FilePath -> String -> IO () -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | The interact function takes a function of type -- String->String as its argument. The entire input from the -- standard input device is passed to this function as its argument, and -- the resulting string is output on the standard output device. interact :: (String -> String) -> IO () -- | The getContents operation returns all user input as a single -- string, which is read lazily as it is needed (same as -- hGetContents stdin). getContents :: IO String -- | Read a line from the standard input device (same as hGetLine -- stdin). getLine :: IO String -- | Read a character from the standard input device (same as -- hGetChar stdin). getChar :: IO Char -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | Write a string to the standard output device (same as hPutStr -- stdout). putStr :: String -> IO () -- | Write a character to the standard output device (same as -- hPutChar stdout). putChar :: Char -> IO () -- | Raise an IOError in the IO monad. ioError :: IOError -> IO a -- | File and directory names are values of type String, whose -- precise meaning is operating system dependent. Files can be opened, -- yielding a handle which can then be used to operate on the contents of -- that file. type FilePath = String -- | Construct an IOError value with a string describing the error. -- The fail method of the IO instance of the Monad -- class raises a userError, thus: -- --
-- instance Monad IO where -- ... -- fail s = ioError (userError s) --userError :: String -> IOError -- | The Haskell 2010 type for exceptions in the IO monad. Any I/O -- operation may raise an IOError instead of returning a result. -- For a more general type of exception, including also those that arise -- in pure code, see Exception. -- -- In Haskell 2010, this is an opaque type. type IOError = IOException -- | notElem is the negation of elem. notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | Determines whether all elements of the structure satisfy the -- predicate. all :: Foldable t => (a -> Bool) -> t a -> Bool -- | Determines whether any element of the structure satisfies the -- predicate. any :: Foldable t => (a -> Bool) -> t a -> Bool -- | or returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. or :: Foldable t => t Bool -> Bool -- | and returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. and :: Foldable t => t Bool -> Bool -- | Map a function over all the elements of a container and concatenate -- the resulting lists. concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | The concatenation of all the elements of a container of lists. concat :: Foldable t => t [a] -> [a] -- | Evaluate each monadic action in the structure from left to right, and -- ignore the results. For a version that doesn't ignore the results see -- sequence. -- -- As of base 4.8.0.0, sequence_ is just sequenceA_, -- specialized to Monad. sequence_ :: (Foldable t, Monad m) => t (m a) -> m () -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- As of base 4.8.0.0, mapM_ is just traverse_, specialized -- to Monad. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | unwords is an inverse operation to words. It joins words -- with separating spaces. -- --
-- >>> unwords ["Lorem", "ipsum", "dolor"] -- "Lorem ipsum dolor" --unwords :: [String] -> String -- | words breaks a string up into a list of words, which were -- delimited by white space. -- --
-- >>> words "Lorem ipsum\ndolor" -- ["Lorem","ipsum","dolor"] --words :: String -> [String] -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. -- --
-- >>> unlines ["Hello", "World", "!"] -- "Hello\nWorld\n!\n" --unlines :: [String] -> String -- | lines breaks a string up into a list of strings at newline -- characters. The resulting strings do not contain newlines. -- -- Note that after splitting the string at newline characters, the last -- part of the string is considered a line even if it doesn't end with a -- newline. For example, -- --
-- >>> lines "" -- [] ---- --
-- >>> lines "\n" -- [""] ---- --
-- >>> lines "one" -- ["one"] ---- --
-- >>> lines "one\n" -- ["one"] ---- --
-- >>> lines "one\n\n" -- ["one",""] ---- --
-- >>> lines "one\ntwo" -- ["one","two"] ---- --
-- >>> lines "one\ntwo\n" -- ["one","two"] ---- -- Thus lines s contains at least as many elements as -- newlines in s. lines :: String -> [String] -- | The read function reads input from a string, which must be -- completely consumed by the input process. read fails with an -- error if the parse is unsuccessful, and it is therefore -- discouraged from being used in real applications. Use readMaybe -- or readEither for safe alternatives. -- --
-- >>> read "123" :: Int -- 123 ---- --
-- >>> read "hello" :: Int -- *** Exception: Prelude.read: no parse --read :: Read a => String -> a -- | equivalent to readsPrec with a precedence of 0. reads :: Read a => ReadS a -- | Case analysis for the Either type. If the value is -- Left a, apply the first function to a; if it -- is Right b, apply the second function to b. -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> either length (*2) s -- 3 -- -- >>> either length (*2) n -- 6 --either :: (a -> c) -> (b -> c) -> Either a b -> c -- | The lex function reads a single lexeme from the input, -- discarding initial white space, and returning the characters that -- constitute the lexeme. If the input string contains only white space, -- lex returns a single successful `lexeme' consisting of the -- empty string. (Thus lex "" = [("","")].) If there is -- no legal lexeme at the beginning of the input string, lex fails -- (i.e. returns []). -- -- This lexer is not completely faithful to the Haskell lexical syntax in -- the following respects: -- --
-- >>> zipWith (+) [1, 2, 3] [4, 5, 6] -- [5,7,9] ---- -- zipWith is right-lazy: -- --
-- zipWith f [] _|_ = [] ---- -- zipWith is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] -- | zip3 takes three lists and returns a list of triples, analogous -- to zip. It is capable of list fusion, but it is restricted to -- its first list argument and its resulting list. zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] -- | List index (subscript) operator, starting from 0. It is an instance of -- the more general genericIndex, which takes an index of any -- integral type. (!!) :: [a] -> Int -> a infixl 9 !! -- | <math>. lookup key assocs looks up a key in an -- association list. -- --
-- >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] -- Just "second" --lookup :: Eq a => a -> [(a, b)] -> Maybe b -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. reverse :: [a] -> [a] -- | break, applied to a predicate p and a list -- xs, returns a tuple where first element is longest prefix -- (possibly empty) of xs of elements that do not satisfy -- p and second element is the remainder of the list: -- --
-- break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4]) -- break (< 9) [1,2,3] == ([],[1,2,3]) -- break (> 9) [1,2,3] == ([1,2,3],[]) ---- -- break p is equivalent to span (not . -- p). break :: (a -> Bool) -> [a] -> ([a], [a]) -- | span, applied to a predicate p and a list xs, -- returns a tuple where first element is longest prefix (possibly empty) -- of xs of elements that satisfy p and second element -- is the remainder of the list: -- --
-- span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4]) -- span (< 9) [1,2,3] == ([1,2,3],[]) -- span (< 0) [1,2,3] == ([],[1,2,3]) ---- -- span p xs is equivalent to (takeWhile p xs, -- dropWhile p xs) span :: (a -> Bool) -> [a] -> ([a], [a]) -- | splitAt n xs returns a tuple where first element is -- xs prefix of length n and second element is the -- remainder of the list: -- --
-- splitAt 6 "Hello World!" == ("Hello ","World!")
-- splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
-- splitAt 1 [1,2,3] == ([1],[2,3])
-- splitAt 3 [1,2,3] == ([1,2,3],[])
-- splitAt 4 [1,2,3] == ([1,2,3],[])
-- splitAt 0 [1,2,3] == ([],[1,2,3])
-- splitAt (-1) [1,2,3] == ([],[1,2,3])
--
--
-- It is equivalent to (take n xs, drop n xs) when
-- n is not _|_ (splitAt _|_ xs = _|_).
-- splitAt is an instance of the more general
-- genericSplitAt, in which n may be of any integral
-- type.
splitAt :: Int -> [a] -> ([a], [a])
-- | drop n xs returns the suffix of xs after the
-- first n elements, or [] if n > length
-- xs:
--
-- -- drop 6 "Hello World!" == "World!" -- drop 3 [1,2,3,4,5] == [4,5] -- drop 3 [1,2] == [] -- drop 3 [] == [] -- drop (-1) [1,2] == [1,2] -- drop 0 [1,2] == [1,2] ---- -- It is an instance of the more general genericDrop, in which -- n may be of any integral type. drop :: Int -> [a] -> [a] -- | take n, applied to a list xs, returns the -- prefix of xs of length n, or xs itself if -- n > length xs: -- --
-- take 5 "Hello World!" == "Hello" -- take 3 [1,2,3,4,5] == [1,2,3] -- take 3 [1,2] == [1,2] -- take 3 [] == [] -- take (-1) [1,2] == [] -- take 0 [1,2] == [] ---- -- It is an instance of the more general genericTake, in which -- n may be of any integral type. take :: Int -> [a] -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs: -- --
-- dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3] -- dropWhile (< 9) [1,2,3] == [] -- dropWhile (< 0) [1,2,3] == [1,2,3] --dropWhile :: (a -> Bool) -> [a] -> [a] -- | takeWhile, applied to a predicate p and a list -- xs, returns the longest prefix (possibly empty) of -- xs of elements that satisfy p: -- --
-- takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2] -- takeWhile (< 9) [1,2,3] == [1,2,3] -- takeWhile (< 0) [1,2,3] == [] --takeWhile :: (a -> Bool) -> [a] -> [a] -- | cycle ties a finite list into a circular one, or equivalently, -- the infinite repetition of the original list. It is the identity on -- infinite lists. cycle :: [a] -> [a] -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general genericReplicate, in which n may be of any -- integral type. replicate :: Int -> a -> [a] -- | repeat x is an infinite list, with x the -- value of every element. repeat :: a -> [a] -- | iterate f x returns an infinite list of repeated -- applications of f to x: -- --
-- iterate f x == [x, f x, f (f x), ...] ---- -- Note that iterate is lazy, potentially leading to thunk -- build-up if the consumer doesn't force each iterate. See -- iterate' for a strict variant of this function. iterate :: (a -> a) -> a -> [a] -- | <math>. scanr1 is a variant of scanr that has no -- starting value argument. scanr1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanr is the right-to-left dual of scanl. -- Note that -- --
-- head (scanr f z xs) == foldr f z xs. --scanr :: (a -> b -> b) -> b -> [a] -> [b] -- | <math>. scanl1 is a variant of scanl that has no -- starting value argument: -- --
-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...] --scanl1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanl is similar to foldl, but returns a -- list of successive reduced values from the left: -- --
-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...] ---- -- Note that -- --
-- last (scanl f z xs) == foldl f z xs. --scanl :: (b -> a -> b) -> b -> [a] -> [b] -- | <math>. Return all the elements of a list except the last one. -- The list must be non-empty. init :: [a] -> [a] -- | <math>. Extract the last element of a list, which must be finite -- and non-empty. last :: [a] -> a -- | The maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. -- --
-- >>> maybe False odd (Just 3) -- True ---- --
-- >>> maybe False odd Nothing -- False ---- -- Read an integer from a string using readMaybe. If we succeed, -- return twice the integer; that is, apply (*2) to it. If -- instead we fail to parse an integer, return 0 by default: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> maybe 0 (*2) (readMaybe "5") -- 10 -- -- >>> maybe 0 (*2) (readMaybe "") -- 0 ---- -- Apply show to a Maybe Int. If we have Just n, -- we want to show the underlying Int n. But if we have -- Nothing, we return the empty string instead of (for example) -- "Nothing": -- --
-- >>> maybe "" show (Just 5) -- "5" -- -- >>> maybe "" show Nothing -- "" --maybe :: b -> (a -> b) -> Maybe a -> b -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | uncurry converts a curried function to a function on pairs. -- --
-- >>> uncurry (+) (1,2) -- 3 ---- --
-- >>> uncurry ($) (show, 1) -- "1" ---- --
-- >>> map (uncurry max) [(1,2), (3,4), (6,8)] -- [2,4,8] --uncurry :: (a -> b -> c) -> (a, b) -> c -- | curry converts an uncurried function to a curried function. -- --
-- >>> curry fst 1 2 -- 1 --curry :: ((a, b) -> c) -> a -> b -> c -- | the same as flip (-). -- -- Because - is treated specially in the Haskell grammar, -- (- e) is not a section, but an application of -- prefix negation. However, (subtract -- exp) is equivalent to the disallowed section. subtract :: Num a => a -> a -> a -- | asTypeOf is a type-restricted version of const. It is -- usually used as an infix operator, and its typing forces its first -- argument (which is usually overloaded) to have the same type as the -- second. asTypeOf :: a -> a -> a -- | until p f yields the result of applying f -- until p holds. until :: (a -> Bool) -> (a -> a) -> a -> a -- | Strict (call-by-value) application operator. It takes a function and -- an argument, evaluates the argument to weak head normal form (WHNF), -- then calls the function with that value. ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $! -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
-- >>> flip (++) "hello" "world" -- "worldhello" --flip :: (a -> b -> c) -> b -> a -> c -- | Function composition. (.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 . -- | const x is a unary function which evaluates to x for -- all inputs. -- --
-- >>> const 42 "hello" -- 42 ---- --
-- >>> map (const 42) [0..3] -- [42,42,42,42] --const :: a -> b -> a -- | Identity function. -- --
-- id x = x --id :: a -> a -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | A special case of error. It is expected that compilers will -- recognize this and insert error messages which are more appropriate to -- the context in which undefined appears. undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a -- | A variant of error that does not produce a stack trace. errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a -- | error stops execution and displays an error message. error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a -- | Boolean "and", lazy in the second argument (&&) :: Bool -> Bool -> Bool infixr 3 && -- | Boolean "or", lazy in the second argument (||) :: Bool -> Bool -> Bool infixr 2 || -- | Boolean "not" not :: Bool -> Bool -- | Convert a ExceptT computation to MaybeT, discarding the -- value of any exception. exceptToMaybeT :: forall (m :: Type -> Type) e a. Functor m => ExceptT e m a -> MaybeT m a -- | Convert a MaybeT computation to ExceptT, with a default -- exception value. maybeToExceptT :: forall (m :: Type -> Type) e a. Functor m => e -> MaybeT m a -> ExceptT e m a -- | Transform the computation inside a MaybeT. -- -- mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b -- | The parameterizable maybe monad, obtained by composing an arbitrary -- monad with the Maybe monad. -- -- Computations are actions that may produce a value or exit. -- -- The return function yields a computation that produces that -- value, while >>= sequences two subcomputations, exiting -- if either computation does. newtype MaybeT (m :: Type -> Type) a MaybeT :: m (Maybe a) -> MaybeT (m :: Type -> Type) a [runMaybeT] :: MaybeT (m :: Type -> Type) a -> m (Maybe a) -- | A monad transformer that adds exceptions to other monads. -- -- ExceptT constructs a monad parameterized over two things: -- --
runExceptT (mapExceptT f m) = f -- (runExceptT m)
evalStateT m s = liftM fst -- (runStateT m s)
execStateT m s = liftM snd -- (runStateT m s)
withStateT f m = modify f >> m
-- data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) ---- -- a suitable instance would be -- --
-- instance Foldable Tree where -- foldMap f Empty = mempty -- foldMap f (Leaf x) = f x -- foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r ---- -- This is suitable even for abstract types, as the monoid is assumed to -- satisfy the monoid laws. Alternatively, one could define -- foldr: -- --
-- instance Foldable Tree where -- foldr f z Empty = z -- foldr f z (Leaf x) = f x z -- foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l ---- -- Foldable instances are expected to satisfy the following -- laws: -- --
-- foldr f z t = appEndo (foldMap (Endo . f) t ) z ---- --
-- foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z ---- --
-- fold = foldMap id ---- --
-- length = getSum . foldMap (Sum . const 1) ---- -- sum, product, maximum, and minimum -- should all be essentially equivalent to foldMap forms, such -- as -- --
-- sum = getSum . foldMap Sum ---- -- but may be less defined. -- -- If the type is also a Functor instance, it should satisfy -- --
-- foldMap f = fold . fmap f ---- -- which implies that -- --
-- foldMap f . fmap g = foldMap (f . g) --class Foldable (t :: Type -> Type) -- | Combine the elements of a structure using a monoid. fold :: (Foldable t, Monoid m) => t m -> m -- | Map each element of the structure to a monoid, and combine the -- results. foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | A variant of foldMap that is strict in the accumulator. foldMap' :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | Right-associative fold of a structure. -- -- In the case of lists, foldr, when applied to a binary operator, -- a starting value (typically the right-identity of the operator), and a -- list, reduces the list using the binary operator, from right to left: -- --
-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...) ---- -- Note that, since the head of the resulting expression is produced by -- an application of the operator to the first element of the list, -- foldr can produce a terminating expression from an infinite -- list. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldr f z = foldr f z . toList --foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b -- | Left-associative fold of a structure but with strict application of -- the operator. -- -- This ensures that each step of the fold is forced to weak head normal -- form before being applied, avoiding the collection of thunks that -- would otherwise occur. This is often what you want to strictly reduce -- a finite list to a single, monolithic result (e.g. length). -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldl' f z = foldl' f z . toList --foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | A variant of foldr that has no base case, and thus may only be -- applied to non-empty structures. -- --
-- foldr1 f = foldr1 f . toList --foldr1 :: Foldable t => (a -> a -> a) -> t a -> a -- | A variant of foldl that has no base case, and thus may only be -- applied to non-empty structures. -- --
-- foldl1 f = foldl1 f . toList --foldl1 :: Foldable t => (a -> a -> a) -> t a -> a -- | List of elements of a structure, from left to right. toList :: Foldable t => t a -> [a] -- | Test whether the structure is empty. The default implementation is -- optimized for structures that are similar to cons-lists, because there -- is no general way to do better. null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation is optimized for structures that are similar to -- cons-lists, because there is no general way to do better. length :: Foldable t => t a -> Int -- | Does the element occur in the structure? elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The largest element of a non-empty structure. maximum :: (Foldable t, Ord a) => t a -> a -- | The least element of a non-empty structure. minimum :: (Foldable t, Ord a) => t a -> a -- | The sum function computes the sum of the numbers of a -- structure. sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | The find function takes a predicate and a structure and returns -- the leftmost element of the structure matching the predicate, or -- Nothing if there is no such element. find :: Foldable t => (a -> Bool) -> t a -> Maybe a -- | notElem is the negation of elem. notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | The least element of a non-empty structure with respect to the given -- comparison function. minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -- | The largest element of a non-empty structure with respect to the given -- comparison function. maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -- | Determines whether all elements of the structure satisfy the -- predicate. all :: Foldable t => (a -> Bool) -> t a -> Bool -- | Determines whether any element of the structure satisfies the -- predicate. any :: Foldable t => (a -> Bool) -> t a -> Bool -- | or returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. or :: Foldable t => t Bool -> Bool -- | and returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. and :: Foldable t => t Bool -> Bool -- | Map a function over all the elements of a container and concatenate -- the resulting lists. concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | The concatenation of all the elements of a container of lists. concat :: Foldable t => t [a] -> [a] -- | The sum of a collection of actions, generalizing concat. As of -- base 4.8.0.0, msum is just asum, specialized to -- MonadPlus. msum :: (Foldable t, MonadPlus m) => t (m a) -> m a -- | The sum of a collection of actions, generalizing concat. -- --
-- >>> asum [Just "Hello", Nothing, Just "World"] -- Just "Hello" --asum :: (Foldable t, Alternative f) => t (f a) -> f a -- | Evaluate each monadic action in the structure from left to right, and -- ignore the results. For a version that doesn't ignore the results see -- sequence. -- -- As of base 4.8.0.0, sequence_ is just sequenceA_, -- specialized to Monad. sequence_ :: (Foldable t, Monad m) => t (m a) -> m () -- | Evaluate each action in the structure from left to right, and ignore -- the results. For a version that doesn't ignore the results see -- sequenceA. sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f () -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore the results see forM. -- -- As of base 4.8.0.0, forM_ is just for_, specialized to -- Monad. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- As of base 4.8.0.0, mapM_ is just traverse_, specialized -- to Monad. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | for_ is traverse_ with its arguments flipped. For a -- version that doesn't ignore the results see for. -- --
-- >>> for_ [1..4] print -- 1 -- 2 -- 3 -- 4 --for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and ignore the results. For a version that doesn't -- ignore the results see traverse. traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () -- | Monadic fold over the elements of a structure, associating to the -- left, i.e. from left to right. foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b -- | Monadic fold over the elements of a structure, associating to the -- right, i.e. from right to left. foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b -- | & 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 $. -- --
-- >>> 5 & (+1) & show -- "6" --(&) :: a -> (a -> b) -> b infixl 1 & -- | on b u x y runs the binary function b -- on the results of applying unary function u to two -- arguments x and y. From the opposite perspective, it -- transforms two inputs and combines the outputs. -- --
-- ((+) `on` f) x y = f x + f y ---- -- Typical usage: sortBy (compare `on` -- fst). -- -- Algebraic properties: -- --
(*) `on` id = (*) -- (if (*) ∉ {⊥, const -- ⊥})
((*) `on` f) `on` g = (*) `on` (f . g)
flip on f . flip on g = flip on (g . -- f)
-- >>> let fac n = if n <= 1 then 1 else n * fac (n-1) in fac 5 -- 120 ---- -- This uses the fact that Haskell’s let introduces recursive -- bindings. We can rewrite this definition using fix, -- --
-- >>> fix (\rec n -> if n <= 1 then 1 else n * rec (n-1)) 5 -- 120 ---- -- Instead of making a recursive call, we introduce a dummy parameter -- rec; when used within fix, this parameter then refers -- to fix’s argument, hence the recursion is reintroduced. fix :: (a -> a) -> a -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
-- >>> flip (++) "hello" "world" -- "worldhello" --flip :: (a -> b -> c) -> b -> a -> c -- | Function composition. (.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 . -- | const x is a unary function which evaluates to x for -- all inputs. -- --
-- >>> const 42 "hello" -- 42 ---- --
-- >>> map (const 42) [0..3] -- [42,42,42,42] --const :: a -> b -> a -- | Identity function. -- --
-- id x = x --id :: a -> a -- | The class of types that can be converted to a hash value. -- -- Minimal implementation: hashWithSalt. -- -- Note: the hash is not guaranteed to be stable across library -- versions, operating systems or architectures. For stable hashing use -- named hashes: SHA256, CRC32 etc. -- -- If you are looking for Hashable instance in time -- package, check time-compat class Hashable a -- | The Ix class is used to map a contiguous subrange of values in -- a type onto integers. It is used primarily for array indexing (see the -- array package). -- -- The first argument (l,u) of each of these operations is a -- pair specifying the lower and upper bounds of a contiguous subrange of -- values. -- -- An implementation is entitled to assume the following laws about these -- operations: -- --
-- >>> Proxy :: Proxy (Void, Int -> Int) -- Proxy ---- -- Proxy can even hold types of higher kinds, -- --
-- >>> Proxy :: Proxy Either -- Proxy ---- --
-- >>> Proxy :: Proxy Functor -- Proxy ---- --
-- >>> Proxy :: Proxy complicatedStructure -- Proxy --data Proxy (t :: k) Proxy :: Proxy (t :: k) -- | The class Typeable allows a concrete representation of a type -- to be calculated. class Typeable (a :: k) -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | 8-bit unsigned integer type data Word8 -- | Witness for an unboxed Proxy# value, which has no runtime -- representation. proxy# :: forall k (a :: k). Proxy# a -- | The type constructor Proxy# is used to bear witness to some -- type variable. It's used when you want to pass around proxy values for -- doing things like modelling type applications. A Proxy# is -- not only unboxed, it also has a polymorphic kind, and has no runtime -- representation, being totally free. data Proxy# (a :: k) :: TYPE 'TupleRep '[] :: [RuntimeRep] -- | Representable types of kind *. This class is derivable in GHC -- with the DeriveGeneric flag on. -- -- A Generic instance must satisfy the following laws: -- --
-- from . to ≡ id -- to . from ≡ id --class Generic a -- | This class gives the integer associated with a type-level natural. -- There are instances of the class for every concrete literal: 0, 1, 2, -- etc. class KnownNat (n :: Nat) -- | This class gives the string associated with a type-level symbol. There -- are instances of the class for every concrete literal: "hello", etc. class KnownSymbol (n :: Symbol) -- | (Kind) This is the kind of type-level natural numbers. data Nat -- | (Kind) This is the kind of type-level symbols. Declared here because -- class IP needs it data Symbol symbolVal' :: forall (n :: Symbol). KnownSymbol n => Proxy# n -> String natVal' :: forall (n :: Nat). KnownNat n => Proxy# n -> Integer symbolVal :: forall (n :: Symbol) proxy. KnownSymbol n => proxy n -> String natVal :: forall (n :: Nat) proxy. KnownNat n => proxy n -> Integer type StringLit = String debugTrace :: StringLit -> a -> a debugTraceShow :: Show a => a -> b -> b debugTraceShowId :: Show a => a -> a module Language.Parser.Ptera.Data.Symbolic.IntSet type T = IntSet type Key = Int data IntSet StraightSet :: IntSet -> IntSet NegativeSet :: IntSet -> IntSet full :: IntSet singleton :: Key -> IntSet invert :: IntSet -> IntSet fromList :: [Key] -> IntSet insert :: Key -> IntSet -> IntSet delete :: Key -> IntSet -> IntSet member :: Key -> IntSet -> Bool union :: IntSet -> IntSet -> IntSet intersection :: IntSet -> IntSet -> IntSet difference :: IntSet -> IntSet -> IntSet instance GHC.Show.Show Language.Parser.Ptera.Data.Symbolic.IntSet.IntSet instance GHC.Classes.Eq Language.Parser.Ptera.Data.Symbolic.IntSet.IntSet instance GHC.Base.Semigroup Language.Parser.Ptera.Data.Symbolic.IntSet.IntSet instance GHC.Base.Monoid Language.Parser.Ptera.Data.Symbolic.IntSet.IntSet module Language.Parser.Ptera.Data.Symbolic.IntMap type T = IntMap type Key = Int data IntMap a IntMap :: IntMap (Maybe a) -> Maybe a -> IntMap a [$sel:intMapStraight:IntMap] :: IntMap a -> IntMap (Maybe a) [$sel:intMapNegative:IntMap] :: IntMap a -> Maybe a empty :: IntMap a full :: a -> IntMap a singleton :: Key -> a -> IntMap a normalize :: Eq a => IntMap a -> IntMap a insert :: Key -> a -> IntMap a -> IntMap a insertBulk :: T -> a -> IntMap a -> IntMap a delete :: Key -> IntMap a -> IntMap a update :: (a -> Maybe a) -> Key -> IntMap a -> IntMap a alter :: (Maybe a -> Maybe a) -> Key -> IntMap a -> IntMap a alterBulk :: (Maybe a -> Maybe a) -> T -> IntMap a -> IntMap a lookup :: Key -> IntMap a -> Maybe a keys :: IntMap a -> T restrictKeys :: IntMap a -> T -> IntMap a merge :: (a -> b -> Maybe c) -> (a -> Maybe c) -> (b -> Maybe c) -> IntMap a -> IntMap b -> IntMap c groupBy :: Eq b => Hashable b => (a -> b) -> IntMap a -> HashMap b T instance Data.Traversable.Traversable Language.Parser.Ptera.Data.Symbolic.IntMap.IntMap instance Data.Foldable.Foldable Language.Parser.Ptera.Data.Symbolic.IntMap.IntMap instance GHC.Base.Functor Language.Parser.Ptera.Data.Symbolic.IntMap.IntMap instance GHC.Show.Show a => GHC.Show.Show (Language.Parser.Ptera.Data.Symbolic.IntMap.IntMap a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.Parser.Ptera.Data.Symbolic.IntMap.IntMap a) module Language.Parser.Ptera.Data.IntMap.GreaterRestriction restrictGreater :: Key -> IntMap a -> IntMap a module Language.Parser.Ptera.Data.HFList type T = HFList data HFList :: (k -> Type) -> [k] -> Type [HFNil] :: HFList f '[] [HFCons] :: f x -> HFList f xs -> HFList f (x : xs) -- | A witness that of x is a member of a type level set -- xs. data Membership (xs :: [k]) (x :: k) type family Concat (xs1 :: [k]) (xs2 :: [k]) :: [k] hconcat :: HFList f xs1 -> HFList f xs2 -> HFList f (Concat xs1 xs2) hfoldrWithIndex :: forall f r xs. (forall x ys. Membership xs x -> f x -> r ys -> r (x : ys)) -> r '[] -> HFList f xs -> r xs htraverseWithIndex :: forall m f g xs. Applicative m => (forall x. Membership xs x -> f x -> m (g x)) -> HFList f xs -> m (HFList g xs) hmapWithIndex :: (forall x. Membership xs x -> f x -> g x) -> HFList f xs -> HFList g xs hfoldMWithIndex :: forall m r f xs. Monad m => r -> (forall x. r -> Membership xs x -> f x -> m r) -> HFList f xs -> m r hforMWithIndex :: forall m f xs. Applicative m => HFList f xs -> (forall x. Membership xs x -> f x -> m ()) -> m () hfoldlWithIndex :: r -> (forall x. r -> Membership xs x -> f x -> r) -> HFList f xs -> r data DictF :: (k -> Constraint) -> k -> Type [DictF] :: c x => DictF c x module Language.Parser.Ptera.Data.Alignable type T = Alignable class Coercible Int i => Alignable i initialAlign :: Alignable i => i nextAlign :: Alignable i => i -> i numIncrements :: Alignable i => i -> Int newtype Inst Inst :: Int -> Inst instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Data.Alignable.Inst module Language.Parser.Ptera.Data.Alignable.Set type T = Set data Set n empty :: Set n singleton :: T n => n -> Set n insert :: T n => n -> Set n -> Set n delete :: T n => n -> Set n -> Set n fromList :: T n => [n] -> Set n toList :: T n => Set n -> [n] null :: Set n -> Bool intersection :: Set n -> Set n -> Set n union :: Set n -> Set n -> Set n difference :: Set n -> Set n -> Set n length :: Set n -> Int member :: T n => n -> Set n -> Bool instance forall k (n :: k). GHC.Base.Semigroup (Language.Parser.Ptera.Data.Alignable.Set.Set n) instance forall k (n :: k). GHC.Show.Show (Language.Parser.Ptera.Data.Alignable.Set.Set n) instance forall k (n :: k). GHC.Classes.Eq (Language.Parser.Ptera.Data.Alignable.Set.Set n) module Language.Parser.Ptera.Data.Alignable.Map type T = Map data Map n a empty :: Map n a singleton :: forall n a. T n => n -> a -> Map n a insert :: forall n a. T n => n -> a -> Map n a -> Map n a lookup :: forall n a. T n => n -> Map n a -> Maybe a assocs :: forall n a. T n => Map n a -> [(n, a)] toAscList :: forall n a. T n => Map n a -> [(n, a)] restrictGreaterOrEqual :: forall n a. T n => n -> Map n a -> Map n a instance forall k (n :: k). Data.Traversable.Traversable (Language.Parser.Ptera.Data.Alignable.Map.Map n) instance forall k (n :: k). Data.Foldable.Foldable (Language.Parser.Ptera.Data.Alignable.Map.Map n) instance forall k (n :: k). GHC.Base.Functor (Language.Parser.Ptera.Data.Alignable.Map.Map n) instance forall k (n :: k) a. GHC.Show.Show a => GHC.Show.Show (Language.Parser.Ptera.Data.Alignable.Map.Map n a) instance forall k (n :: k) a. GHC.Classes.Eq a => GHC.Classes.Eq (Language.Parser.Ptera.Data.Alignable.Map.Map n a) module Language.Parser.Ptera.Data.Alignable.Array type T = Array newtype Array n a Array :: Array Int a -> Array n a fromTotalMap :: T n => n -> T n a -> Array n a fromList :: forall n a. T n => [a] -> Array n a mapWithIx :: T n => (n -> a -> a) -> Array n a -> Array n a index :: forall n a. T n => Array n a -> n -> Maybe a forceIndex :: forall n a. T n => Array n a -> n -> a assocs :: forall n a. T n => Array n a -> [(n, a)] instance forall k (n :: k). Data.Foldable.Foldable (Language.Parser.Ptera.Data.Alignable.Array.Array n) instance forall k (n :: k). GHC.Base.Functor (Language.Parser.Ptera.Data.Alignable.Array.Array n) instance forall k (n :: k) a. GHC.Show.Show a => GHC.Show.Show (Language.Parser.Ptera.Data.Alignable.Array.Array n a) instance forall k (n :: k) a. GHC.Classes.Eq a => GHC.Classes.Eq (Language.Parser.Ptera.Data.Alignable.Array.Array n a) module Language.Parser.Ptera.Machine.PEG type T = PEG data PEG start varDoc altDoc a PEG :: T VarNum (Var varDoc) -> T VarNum Rule -> T AltNum (Alt altDoc a) -> EnumMap start VarNum -> PEG start varDoc altDoc a [$sel:vars:PEG] :: PEG start varDoc altDoc a -> T VarNum (Var varDoc) [$sel:rules:PEG] :: PEG start varDoc altDoc a -> T VarNum Rule [$sel:alts:PEG] :: PEG start varDoc altDoc a -> T AltNum (Alt altDoc a) [$sel:initials:PEG] :: PEG start varDoc altDoc a -> EnumMap start VarNum newtype VarNum VarNum :: Int -> VarNum newtype AltNum AltNum :: Int -> AltNum newtype Rule Rule :: [AltNum] -> Rule [$sel:ruleAlts:Rule] :: Rule -> [AltNum] newtype Var varDoc Var :: varDoc -> Var varDoc [$sel:varHelp:Var] :: Var varDoc -> varDoc data Alt altDoc a Alt :: AltKind -> [Unit] -> a -> altDoc -> Alt altDoc a [$sel:altKind:Alt] :: Alt altDoc a -> AltKind [$sel:altUnitSeq:Alt] :: Alt altDoc a -> [Unit] [$sel:altAction:Alt] :: Alt altDoc a -> a [$sel:altHelp:Alt] :: Alt altDoc a -> altDoc data AltKind AltSeq :: AltKind AltNot :: AltKind AltAnd :: AltKind data Unit UnitTerminal :: Terminal -> Unit UnitNonTerminal :: VarNum -> Unit type Terminal = Int instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.PEG.VarNum instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.PEG.VarNum instance GHC.Show.Show Language.Parser.Ptera.Machine.PEG.VarNum instance GHC.Classes.Eq Language.Parser.Ptera.Machine.PEG.VarNum instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.PEG.AltNum instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.PEG.AltNum instance GHC.Show.Show Language.Parser.Ptera.Machine.PEG.AltNum instance GHC.Classes.Eq Language.Parser.Ptera.Machine.PEG.AltNum instance GHC.Show.Show Language.Parser.Ptera.Machine.PEG.Rule instance GHC.Classes.Eq Language.Parser.Ptera.Machine.PEG.Rule instance GHC.Base.Functor Language.Parser.Ptera.Machine.PEG.Var instance GHC.Show.Show varDoc => GHC.Show.Show (Language.Parser.Ptera.Machine.PEG.Var varDoc) instance GHC.Classes.Eq varDoc => GHC.Classes.Eq (Language.Parser.Ptera.Machine.PEG.Var varDoc) instance GHC.Show.Show Language.Parser.Ptera.Machine.PEG.AltKind instance GHC.Classes.Eq Language.Parser.Ptera.Machine.PEG.AltKind instance GHC.Show.Show Language.Parser.Ptera.Machine.PEG.Unit instance GHC.Classes.Eq Language.Parser.Ptera.Machine.PEG.Unit instance GHC.Base.Functor (Language.Parser.Ptera.Machine.PEG.Alt altDoc) instance (GHC.Show.Show a, GHC.Show.Show altDoc) => GHC.Show.Show (Language.Parser.Ptera.Machine.PEG.Alt altDoc a) instance (GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.PEG.Alt altDoc a) instance GHC.Base.Functor (Language.Parser.Ptera.Machine.PEG.PEG start varDoc altDoc) instance (GHC.Enum.Enum start, GHC.Show.Show varDoc, GHC.Show.Show a, GHC.Show.Show altDoc, GHC.Show.Show start) => GHC.Show.Show (Language.Parser.Ptera.Machine.PEG.PEG start varDoc altDoc a) instance (GHC.Classes.Eq varDoc, GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.PEG.PEG start varDoc altDoc a) module Language.Parser.Ptera.Machine.PEG.Builder type T start varDoc altDoc a = BuilderT start varDoc altDoc a type BuilderT start varDoc altDoc a = StateT (Context start varDoc altDoc a) data Context start varDoc altDoc a Context :: EnumMap start VarNum -> VarNum -> AltNum -> T VarNum (Var varDoc) -> T VarNum Rule -> T AltNum (Alt altDoc a) -> Context start varDoc altDoc a [$sel:ctxInitials:Context] :: Context start varDoc altDoc a -> EnumMap start VarNum [$sel:ctxNextVarNum:Context] :: Context start varDoc altDoc a -> VarNum [$sel:ctxNextAltNum:Context] :: Context start varDoc altDoc a -> AltNum [$sel:ctxVars:Context] :: Context start varDoc altDoc a -> T VarNum (Var varDoc) [$sel:ctxRules:Context] :: Context start varDoc altDoc a -> T VarNum Rule [$sel:ctxAlts:Context] :: Context start varDoc altDoc a -> T AltNum (Alt altDoc a) build :: Monad m => BuilderT start varDoc altDoc a m () -> m (T start varDoc altDoc a) genNewVar :: Monad m => Var varDoc -> BuilderT start varDoc altDoc a m VarNum genNewAlt :: Monad m => Alt altDoc a -> BuilderT start varDoc altDoc a m AltNum addInitial :: Monad m => Enum start => start -> VarNum -> BuilderT start varDoc altDoc a m () addRule :: Monad m => VarNum -> Rule -> BuilderT start varDoc altDoc a m () instance GHC.Base.Functor (Language.Parser.Ptera.Machine.PEG.Builder.Context start varDoc altDoc) instance (GHC.Enum.Enum start, GHC.Show.Show start, GHC.Show.Show varDoc, GHC.Show.Show a, GHC.Show.Show altDoc) => GHC.Show.Show (Language.Parser.Ptera.Machine.PEG.Builder.Context start varDoc altDoc a) instance (GHC.Classes.Eq varDoc, GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.PEG.Builder.Context start varDoc altDoc a) module Language.Parser.Ptera.Machine.LAPEG type T = LAPEG data LAPEG start varDoc altDoc a LAPEG :: T VarNum (Var varDoc) -> T VarNum Rule -> T AltNum (Alt altDoc a) -> EnumMap start VarNum -> LAPEG start varDoc altDoc a [$sel:vars:LAPEG] :: LAPEG start varDoc altDoc a -> T VarNum (Var varDoc) [$sel:rules:LAPEG] :: LAPEG start varDoc altDoc a -> T VarNum Rule [$sel:alts:LAPEG] :: LAPEG start varDoc altDoc a -> T AltNum (Alt altDoc a) [$sel:initials:LAPEG] :: LAPEG start varDoc altDoc a -> EnumMap start VarNum newtype VarNum VarNum :: Int -> VarNum newtype AltNum AltNum :: Int -> AltNum data Rule Rule :: HeadRange -> [AltNum] -> Rule [$sel:ruleRange:Rule] :: Rule -> HeadRange [$sel:ruleAlts:Rule] :: Rule -> [AltNum] data Alt altDoc a Alt :: VarNum -> AltKind -> T Position (HeadRange, Unit) -> a -> altDoc -> Alt altDoc a [$sel:altVar:Alt] :: Alt altDoc a -> VarNum [$sel:altKind:Alt] :: Alt altDoc a -> AltKind [$sel:altUnitSeqWithLookAHead:Alt] :: Alt altDoc a -> T Position (HeadRange, Unit) [$sel:altAction:Alt] :: Alt altDoc a -> a [$sel:altHelp:Alt] :: Alt altDoc a -> altDoc newtype Position Position :: Int -> Position data HeadRange HeadRange :: Bool -> T -> HeadRange [$sel:headRangeEpsilon:HeadRange] :: HeadRange -> Bool [$sel:headRangeConsume:HeadRange] :: HeadRange -> T data Unit UnitTerminal :: Terminal -> Unit UnitNonTerminal :: VarNum -> Unit UnitNot :: Unit type Terminal = Int instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.LAPEG.VarNum instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.LAPEG.VarNum instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.VarNum instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.VarNum instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.LAPEG.AltNum instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.LAPEG.AltNum instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.AltNum instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.AltNum instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.LAPEG.Position instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.LAPEG.Position instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.Position instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.Position instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.HeadRange instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.HeadRange instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.Rule instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.Rule instance GHC.Show.Show Language.Parser.Ptera.Machine.LAPEG.Unit instance GHC.Classes.Eq Language.Parser.Ptera.Machine.LAPEG.Unit instance GHC.Base.Functor (Language.Parser.Ptera.Machine.LAPEG.Alt altDoc) instance (GHC.Show.Show a, GHC.Show.Show altDoc) => GHC.Show.Show (Language.Parser.Ptera.Machine.LAPEG.Alt altDoc a) instance (GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.LAPEG.Alt altDoc a) instance GHC.Base.Functor (Language.Parser.Ptera.Machine.LAPEG.LAPEG start varDoc altDoc) instance (GHC.Enum.Enum start, GHC.Show.Show varDoc, GHC.Show.Show a, GHC.Show.Show altDoc, GHC.Show.Show start) => GHC.Show.Show (Language.Parser.Ptera.Machine.LAPEG.LAPEG start varDoc altDoc a) instance (GHC.Classes.Eq varDoc, GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.LAPEG.LAPEG start varDoc altDoc a) instance GHC.Base.Semigroup Language.Parser.Ptera.Machine.LAPEG.HeadRange instance GHC.Base.Monoid Language.Parser.Ptera.Machine.LAPEG.HeadRange module Language.Parser.Ptera.Machine.SRB type T = SRB data SRB start varDoc altDoc a SRB :: EnumMap start StateNum -> T StateNum MState -> T AltNum (Alt altDoc a) -> T VarNum (Var varDoc) -> SRB start varDoc altDoc a [$sel:initials:SRB] :: SRB start varDoc altDoc a -> EnumMap start StateNum [$sel:states:SRB] :: SRB start varDoc altDoc a -> T StateNum MState [$sel:alts:SRB] :: SRB start varDoc altDoc a -> T AltNum (Alt altDoc a) [$sel:vars:SRB] :: SRB start varDoc altDoc a -> T VarNum (Var varDoc) newtype StateNum StateNum :: Int -> StateNum data MState MState :: StateNum -> T Trans -> [AltItem] -> MState [$sel:stateNum:MState] :: MState -> StateNum [$sel:stateTrans:MState] :: MState -> T Trans [$sel:stateAltItems:MState] :: MState -> [AltItem] data Trans TransWithOps :: [TransOp] -> StateNum -> Trans TransReduce :: AltNum -> Trans data TransOp TransOpEnter :: VarNum -> Bool -> Maybe StateNum -> TransOp TransOpPushBackpoint :: StateNum -> TransOp TransOpHandleNot :: AltNum -> TransOp TransOpShift :: TransOp data AltItem AltItem :: AltNum -> Position -> AltItem [$sel:altItemAltNum:AltItem] :: AltItem -> AltNum [$sel:altItemCurPos:AltItem] :: AltItem -> Position instance Language.Parser.Ptera.Data.Alignable.Alignable Language.Parser.Ptera.Machine.SRB.StateNum instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.SRB.StateNum instance GHC.Show.Show Language.Parser.Ptera.Machine.SRB.StateNum instance GHC.Classes.Eq Language.Parser.Ptera.Machine.SRB.StateNum instance GHC.Generics.Generic Language.Parser.Ptera.Machine.SRB.TransOp instance GHC.Show.Show Language.Parser.Ptera.Machine.SRB.TransOp instance GHC.Classes.Eq Language.Parser.Ptera.Machine.SRB.TransOp instance GHC.Show.Show Language.Parser.Ptera.Machine.SRB.Trans instance GHC.Classes.Eq Language.Parser.Ptera.Machine.SRB.Trans instance GHC.Show.Show Language.Parser.Ptera.Machine.SRB.AltItem instance GHC.Classes.Eq Language.Parser.Ptera.Machine.SRB.AltItem instance GHC.Show.Show Language.Parser.Ptera.Machine.SRB.MState instance GHC.Classes.Eq Language.Parser.Ptera.Machine.SRB.MState instance GHC.Base.Functor (Language.Parser.Ptera.Machine.SRB.SRB start varDoc altDoc) instance (GHC.Enum.Enum start, GHC.Show.Show start, GHC.Show.Show a, GHC.Show.Show altDoc, GHC.Show.Show varDoc) => GHC.Show.Show (Language.Parser.Ptera.Machine.SRB.SRB start varDoc altDoc a) instance (GHC.Classes.Eq a, GHC.Classes.Eq altDoc, GHC.Classes.Eq varDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.SRB.SRB start varDoc altDoc a) instance Data.Hashable.Class.Hashable Language.Parser.Ptera.Machine.SRB.TransOp module Language.Parser.Ptera.Machine.SRB.Builder type T start a = BuilderT start a type BuilderT start a = StateT (Context start a) data Context start a Context :: EnumMap start StateNum -> StateNum -> T StateNum MState -> Context start a [$sel:ctxInitials:Context] :: Context start a -> EnumMap start StateNum [$sel:ctxNextStateNum:Context] :: Context start a -> StateNum [$sel:ctxStates:Context] :: Context start a -> T StateNum MState type Vars varDoc = T VarNum (Var varDoc) type Alts altDoc a = T AltNum (Alt altDoc a) build :: Monad m => Vars varDoc -> Alts altDoc a -> BuilderT start a m () -> m (T start varDoc altDoc a) genNewStateNum :: Monad m => BuilderT start a m StateNum registerInitial :: Monad m => Enum start => start -> StateNum -> BuilderT start a m () addState :: Monad m => MState -> BuilderT s a m () instance forall start k (a :: k). (GHC.Enum.Enum start, GHC.Show.Show start) => GHC.Show.Show (Language.Parser.Ptera.Machine.SRB.Builder.Context start a) instance forall start k (a :: k). GHC.Classes.Eq (Language.Parser.Ptera.Machine.SRB.Builder.Context start a) module Language.Parser.Ptera.Pipeline.LAPEG2SRB laPeg2Srb :: Enum start => T start varDoc altDoc a -> T start varDoc altDoc a type Pipeline start altDoc a = State (Context start altDoc a) data Context start altDoc a Context :: Context start a -> T VarNum StateNum -> T AltNum StateNum -> T VarNum (T (Bool, StateNum)) -> HashMap (Position, NonEmpty AltNum) StateNum -> [(StateNum, Position, NonEmpty AltNum)] -> T VarNum Rule -> T AltNum (Alt altDoc a) -> Context start altDoc a [$sel:ctxBuilder:Context] :: Context start altDoc a -> Context start a [$sel:ctxInitialVarState:Context] :: Context start altDoc a -> T VarNum StateNum [$sel:ctxReduceNotState:Context] :: Context start altDoc a -> T AltNum StateNum [$sel:ctxVarMap:Context] :: Context start altDoc a -> T VarNum (T (Bool, StateNum)) [$sel:ctxStateMap:Context] :: Context start altDoc a -> HashMap (Position, NonEmpty AltNum) StateNum [$sel:ctxStateQueue:Context] :: Context start altDoc a -> [(StateNum, Position, NonEmpty AltNum)] [$sel:ctxOriginalRules:Context] :: Context start altDoc a -> T VarNum Rule [$sel:ctxOriginalAlts:Context] :: Context start altDoc a -> T AltNum (Alt altDoc a) laPegInitialPipeline :: Enum start => start -> VarNum -> Pipeline start altDoc a () laPegStateQueuePipeline :: Pipeline start altDoc a () laPegVarPipeline :: VarNum -> Pipeline start altDoc a (T (Bool, StateNum)) laPegRulePipeline :: VarNum -> Rule -> Pipeline start altDoc a (T (Bool, StateNum)) laPegEnterStatePipeline :: NonEmpty AltNum -> Pipeline start altDoc a (T (Bool, StateNum)) laPegStatePipeline :: StateNum -> Position -> NonEmpty AltNum -> Pipeline start altDoc a () laPegTransPipeline :: Position -> NonEmpty AltNum -> Pipeline start altDoc a (T Trans) genAltMapForTrans :: Position -> NonEmpty AltNum -> Pipeline start altDoc a (T AltItemsForTrans) data AltItemsForTrans AltMapForTrans :: AltItemsOpForTrans -> NonEmpty AltNum -> [AltNum] -> AltItemsForTrans [$sel:altItemsForTransOp:AltMapForTrans] :: AltItemsForTrans -> AltItemsOpForTrans [$sel:altItemsForTransRevAlts:AltMapForTrans] :: AltItemsForTrans -> NonEmpty AltNum [$sel:altItemsForTransRest:AltMapForTrans] :: AltItemsForTrans -> [AltNum] data AltItemsOpForTrans AltItemsOpShift :: AltItemsOpForTrans AltItemsOpEnter :: VarNum -> Bool -> StateNum -> AltItemsOpForTrans AltItemsOpNot :: AltItemsOpForTrans AltItemsOpReduce :: AltItemsOpForTrans getStateForAltItems :: Position -> NonEmpty AltNum -> Pipeline start altDoc a StateNum isNeedBackAlts :: NonEmpty AltNum -> Pipeline start altDoc a Bool getUnitForAltItem :: Position -> AltNum -> Pipeline start altDoc a (Maybe (T, Unit)) getAlt :: AltNum -> Pipeline start altDoc a (Alt altDoc a) getCtx :: (Context start altDoc a -> r) -> Pipeline start altDoc a r liftBuilder :: T start a Identity r -> Pipeline start altDoc a r instance GHC.Show.Show Language.Parser.Ptera.Pipeline.LAPEG2SRB.AltItemsOpForTrans instance GHC.Classes.Eq Language.Parser.Ptera.Pipeline.LAPEG2SRB.AltItemsOpForTrans instance GHC.Show.Show Language.Parser.Ptera.Pipeline.LAPEG2SRB.AltItemsForTrans instance GHC.Classes.Eq Language.Parser.Ptera.Pipeline.LAPEG2SRB.AltItemsForTrans module Language.Parser.Ptera.Machine.LAPEG.Builder type T start varDoc altDoc a = BuilderT start varDoc altDoc a type BuilderT start varDoc altDoc a = StateT (Context start varDoc altDoc a) data Context start varDoc altDoc a Context :: EnumMap start VarNum -> VarNum -> AltNum -> T VarNum (Var varDoc) -> T VarNum Rule -> T AltNum (Alt altDoc a) -> Context start varDoc altDoc a [$sel:ctxInitials:Context] :: Context start varDoc altDoc a -> EnumMap start VarNum [$sel:ctxNextVarNum:Context] :: Context start varDoc altDoc a -> VarNum [$sel:ctxNextAltNum:Context] :: Context start varDoc altDoc a -> AltNum [$sel:ctxVars:Context] :: Context start varDoc altDoc a -> T VarNum (Var varDoc) [$sel:ctxRules:Context] :: Context start varDoc altDoc a -> T VarNum Rule [$sel:ctxAlts:Context] :: Context start varDoc altDoc a -> T AltNum (Alt altDoc a) build :: Monad m => BuilderT start varDoc altDoc a m () -> m (T start varDoc altDoc a) genNewVar :: Monad m => Var varDoc -> BuilderT start varDoc altDoc a m VarNum genNewAlt :: Monad m => Alt altDoc a -> BuilderT start varDoc altDoc a m AltNum addInitial :: Monad m => Enum start => start -> VarNum -> BuilderT start varDoc altDoc a m () addRule :: Monad m => VarNum -> Rule -> BuilderT start varDoc altDoc a m () instance GHC.Base.Functor (Language.Parser.Ptera.Machine.LAPEG.Builder.Context start varDoc altDoc) instance (GHC.Enum.Enum start, GHC.Show.Show start, GHC.Show.Show varDoc, GHC.Show.Show a, GHC.Show.Show altDoc) => GHC.Show.Show (Language.Parser.Ptera.Machine.LAPEG.Builder.Context start varDoc altDoc a) instance (GHC.Classes.Eq varDoc, GHC.Classes.Eq a, GHC.Classes.Eq altDoc) => GHC.Classes.Eq (Language.Parser.Ptera.Machine.LAPEG.Builder.Context start varDoc altDoc a) module Language.Parser.Ptera.Pipeline.PEG2LAPEG peg2LaPeg :: Enum start => T start varDoc altDoc a -> Except (T VarNum) (T start varDoc altDoc a) type Pipeline start varDoc altDoc a = ExceptT (T VarNum) (State (Context start varDoc altDoc a)) data Context start varDoc altDoc a Context :: Context start varDoc altDoc a -> T VarNum VarNum -> T VarNum (Maybe HeadRange) -> [(VarNum, HeadRange, [Alt altDoc a])] -> T VarNum (Var varDoc) -> T VarNum Rule -> T AltNum (Alt altDoc a) -> Context start varDoc altDoc a [$sel:ctxBuilder:Context] :: Context start varDoc altDoc a -> Context start varDoc altDoc a [$sel:ctxVarMap:Context] :: Context start varDoc altDoc a -> T VarNum VarNum [$sel:ctxAvailableRuleRanges:Context] :: Context start varDoc altDoc a -> T VarNum (Maybe HeadRange) [$sel:ctxUpdateRuleStack:Context] :: Context start varDoc altDoc a -> [(VarNum, HeadRange, [Alt altDoc a])] [$sel:ctxOriginalVars:Context] :: Context start varDoc altDoc a -> T VarNum (Var varDoc) [$sel:ctxOriginalRules:Context] :: Context start varDoc altDoc a -> T VarNum Rule [$sel:ctxOriginalAlts:Context] :: Context start varDoc altDoc a -> T AltNum (Alt altDoc a) pegInitialPipeline :: Enum start => start -> VarNum -> Pipeline start varDoc altDoc a () pegRuleStackPipeline :: Pipeline start varDoc altDoc a () pegVarPipeline :: VarNum -> Pipeline start varDoc altDoc a (VarNum, HeadRange) pegRuleHeadRangePipeline :: VarNum -> Rule -> Pipeline start varDoc altDoc a HeadRange pegAltHeadRangePipeline :: Alt altDoc a -> Pipeline start varDoc altDoc a HeadRange pegRulePipeline :: VarNum -> HeadRange -> [Alt altDoc a] -> Pipeline start varDoc altDoc a () pegAltPipeline :: VarNum -> Alt altDoc a -> Pipeline start varDoc altDoc a AltNum pegUnitPipeline :: Unit -> Pipeline start varDoc altDoc a (Unit, HeadRange) getNewVar :: VarNum -> Pipeline start varDoc altDoc a VarNum startUpdateAvailableRuleRange :: VarNum -> Pipeline start varDoc altDoc a () saveNewRuleRange :: VarNum -> HeadRange -> Pipeline start varDoc altDoc a () getAvailableVar :: VarNum -> Pipeline start varDoc altDoc a (Maybe VarNum) popUpdateRuleItem :: Pipeline start varDoc altDoc a (Maybe (VarNum, HeadRange, [Alt altDoc a])) pushUpdateRuleItem :: VarNum -> HeadRange -> [Alt altDoc a] -> Pipeline start varDoc altDoc a () getCtx :: (Context start varDoc altDoc a -> r) -> Pipeline start varDoc altDoc a r throwV :: VarNum -> Pipeline start varDoc altDoc a r liftBuilder :: T start varDoc altDoc a Identity r -> Pipeline start varDoc altDoc a r module Language.Parser.Ptera.Syntax.Grammar type T start nonTerminal terminal elem varDoc altDoc action = GrammarT start nonTerminal terminal elem varDoc altDoc action type GrammarT start nonTerminal terminal elem varDoc altDoc action = StateT (Context start nonTerminal terminal elem varDoc altDoc action) data Context start nonTerminal terminal elem varDoc altDoc action Context :: EnumMap start nonTerminal -> EnumMap nonTerminal (RuleExpr nonTerminal terminal elem altDoc action) -> EnumMap nonTerminal varDoc -> Context start nonTerminal terminal elem varDoc altDoc action [$sel:ctxStarts:Context] :: Context start nonTerminal terminal elem varDoc altDoc action -> EnumMap start nonTerminal [$sel:ctxRules:Context] :: Context start nonTerminal terminal elem varDoc altDoc action -> EnumMap nonTerminal (RuleExpr nonTerminal terminal elem altDoc action) [$sel:ctxDisplayNonTerminals:Context] :: Context start nonTerminal terminal elem varDoc altDoc action -> EnumMap nonTerminal varDoc fixGrammarT :: Monad m => GrammarT start nonTerminal terminal elem varDoc altDoc action m () -> m (FixedGrammar start nonTerminal terminal elem varDoc altDoc action) data FixedGrammar start nonTerminal terminal elem varDoc altDoc action FixedGrammar :: EnumMap start nonTerminal -> EnumMap nonTerminal (RuleExpr nonTerminal terminal elem altDoc action) -> EnumMap nonTerminal varDoc -> FixedGrammar start nonTerminal terminal elem varDoc altDoc action [$sel:grammarStarts:FixedGrammar] :: FixedGrammar start nonTerminal terminal elem varDoc altDoc action -> EnumMap start nonTerminal [$sel:grammarRules:FixedGrammar] :: FixedGrammar start nonTerminal terminal elem varDoc altDoc action -> EnumMap nonTerminal (RuleExpr nonTerminal terminal elem altDoc action) [$sel:grammarDisplayNonTerminals:FixedGrammar] :: FixedGrammar start nonTerminal terminal elem varDoc altDoc action -> EnumMap nonTerminal varDoc data Action (action :: [Type] -> Type -> Type) [Action] :: action us a -> Action action data RuleExpr nonTerminal terminal elem altDoc action [RuleExpr] :: [Alt nonTerminal terminal elem altDoc action a] -> RuleExpr nonTerminal terminal elem altDoc action data Alt nonTerminal terminal elem altDoc action a [Alt] :: Expr nonTerminal terminal elem us -> altDoc -> action us a -> Alt nonTerminal terminal elem altDoc action a type Expr nonTerminal terminal elem = T (Unit nonTerminal terminal elem) data Unit nonTerminal terminal elem u [UnitToken] :: terminal -> Unit nonTerminal terminal elem elem [UnitVar] :: nonTerminal -> Unit nonTerminal terminal elem u initialT :: Enum start => Monad m => start -> nonTerminal -> GrammarT start nonTerminal terminal elem varDoc altDoc action m () ruleT :: Enum nonTerminal => Monad m => nonTerminal -> varDoc -> RuleExpr nonTerminal terminal elem altDoc action -> GrammarT start nonTerminal terminal elem varDoc altDoc action m () module Language.Parser.Ptera.Pipeline.Grammar2PEG grammar2Peg :: Enum start => Enum nonTerminal => Enum terminal => FixedGrammar start nonTerminal terminal elem varDoc altDoc action -> T start varDoc altDoc (Action action) type Pipeline start nonTerminal varDoc altDoc action = State (Context start nonTerminal varDoc altDoc action) data Context start nonTerminal varDoc altDoc action Context :: Context start varDoc altDoc (Action action) -> EnumMap nonTerminal VarNum -> EnumMap nonTerminal varDoc -> Context start nonTerminal varDoc altDoc action [$sel:ctxBuilder:Context] :: Context start nonTerminal varDoc altDoc action -> Context start varDoc altDoc (Action action) [$sel:ctxVarMap:Context] :: Context start nonTerminal varDoc altDoc action -> EnumMap nonTerminal VarNum [$sel:ctxDisplayNonTerminals:Context] :: Context start nonTerminal varDoc altDoc action -> EnumMap nonTerminal varDoc grammarStartPipeline :: Enum start => Enum nonTerminal => start -> nonTerminal -> Pipeline start nonTerminal varDoc altDoc action () grammarRulePipeline :: Enum nonTerminal => Enum terminal => nonTerminal -> RuleExpr nonTerminal terminal elem altDoc action -> Pipeline start nonTerminal varDoc altDoc action () grammarAltPipeline :: Enum nonTerminal => Enum terminal => Alt nonTerminal terminal elem altDoc action r -> Pipeline start nonTerminal varDoc altDoc action AltNum grammarExprPipeline :: forall start nonTerminal terminal elem varDoc altDoc action us. Enum nonTerminal => Enum terminal => Expr nonTerminal terminal elem us -> Pipeline start nonTerminal varDoc altDoc action [Unit] grammarUnitPipeline :: Enum nonTerminal => Enum terminal => Unit nonTerminal terminal elem u -> Pipeline start nonTerminal varDoc altDoc action Unit getNewVar :: Enum nonTerminal => nonTerminal -> Pipeline start nonTerminal varDoc altDoc action VarNum liftBuilder :: T start varDoc altDoc (Action action) Identity r -> Pipeline start nonTerminal varDoc altDoc action r