-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | ITProTV's custom prelude -- -- Prolude is ITProTV's custom prelude. https://www.itpro.tv @package prolude @version 0.0.0.21 module Prolude.Aeson -- | A configurable generic JSON creator. This function applied to -- defaultOptions is used as the default for toJSON when -- the type is an instance of Generic. genericToJSON :: (Generic a, GToJSON' Value Zero (Rep a)) => Options -> a -> Value -- | A type that can be converted to JSON. -- -- Instances in general must specify toJSON and -- should (but don't need to) specify toEncoding. -- -- An example type and instance: -- --
--   -- Allow ourselves to write Text literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance ToJSON Coord where
--     toJSON (Coord x y) = object ["x" .= x, "y" .= y]
--   
--     toEncoding (Coord x y) = pairs ("x" .= x <> "y" .= y)
--   
-- -- Instead of manually writing your ToJSON instance, there are two -- options to do it automatically: -- -- -- -- To use the second, simply add a deriving Generic -- clause to your datatype and declare a ToJSON instance. If you -- require nothing other than defaultOptions, it is sufficient to -- write (and this is the only alternative where the default -- toJSON implementation is sufficient): -- --
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving Generic
--   
--   instance ToJSON Coord where
--       toEncoding = genericToEncoding defaultOptions
--   
-- -- If on the other hand you wish to customize the generic decoding, you -- have to implement both methods: -- --
--   customOptions = defaultOptions
--                   { fieldLabelModifier = map toUpper
--                   }
--   
--   instance ToJSON Coord where
--       toJSON     = genericToJSON customOptions
--       toEncoding = genericToEncoding customOptions
--   
-- -- Previous versions of this library only had the toJSON method. -- Adding toEncoding had two reasons: -- --
    --
  1. toEncoding is more efficient for the common case that the output -- of toJSON is directly serialized to a ByteString. -- Further, expressing either method in terms of the other would be -- non-optimal.
  2. --
  3. The choice of defaults allows a smooth transition for existing -- users: Existing instances that do not define toEncoding still -- compile and have the correct semantics. This is ensured by making the -- default implementation of toEncoding use toJSON. This -- produces correct results, but since it performs an intermediate -- conversion to a Value, it will be less efficient than directly -- emitting an Encoding. (this also means that specifying nothing -- more than instance ToJSON Coord would be sufficient as a -- generically decoding instance, but there probably exists no good -- reason to not specify toEncoding in new instances.)
  4. --
class ToJSON a -- | Convert a Haskell value to a JSON-friendly intermediate type. toJSON :: ToJSON a => a -> Value (.=) :: (KeyValue kv, ToJSON v) => Text -> v -> kv infixr 8 .= -- | Helper for use in combination with .:? to provide default -- values for optional JSON object fields. -- -- This combinator is most useful if the key and value can be absent from -- an object without affecting its validity and we know a default value -- to assign in that case. If the key and value are mandatory, use -- .: instead. -- -- Example usage: -- --
--   v1 <- o .:? "opt_field_with_dfl" .!= "default_val"
--   v2 <- o .:  "mandatory_field"
--   v3 <- o .:? "opt_field2"
--   
(.!=) :: Parser (Maybe a) -> a -> Parser a -- | Retrieve the value associated with the given key of an Object. -- The result is Nothing if the key is not present or if its value -- is Null, or empty if the value cannot be converted to -- the desired type. -- -- This accessor is most useful if the key and value can be absent from -- an object without affecting its validity. If the key and value are -- mandatory, use .: instead. (.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a) -- | Retrieve the value associated with the given key of an Object. -- The result is empty if the key is not present or the value -- cannot be converted to the desired type. -- -- This accessor is appropriate if the key and value must be -- present in an object for it to be valid. If the key and value are -- optional, use .:? instead. (.:) :: FromJSON a => Object -> Text -> Parser a -- | Convert a value from JSON, failing if the types do not match. fromJSON :: FromJSON a => Value -> Result a -- | A configurable generic JSON decoder. This function applied to -- defaultOptions is used as the default for parseJSON when -- the type is an instance of Generic. genericParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Options -> Value -> Parser a -- | A type that can be converted from JSON, with the possibility of -- failure. -- -- In many cases, you can get the compiler to generate parsing code for -- you (see below). To begin, let's cover writing an instance by hand. -- -- There are various reasons a conversion could fail. For example, an -- Object could be missing a required key, an Array could -- be of the wrong size, or a value could be of an incompatible type. -- -- The basic ways to signal a failed conversion are as follows: -- -- -- -- prependFailure (or modifyFailure) add more information -- to a parser's error messages. -- -- An example type and instance using typeMismatch and -- prependFailure: -- --
--   -- Allow ourselves to write Text literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance FromJSON Coord where
--       parseJSON (Object v) = Coord
--           <$> v .: "x"
--           <*> v .: "y"
--   
--       -- We do not expect a non-Object value here.
--       -- We could use empty to fail, but typeMismatch
--       -- gives a much more informative error message.
--       parseJSON invalid    =
--           prependFailure "parsing Coord failed, "
--               (typeMismatch "Object" invalid)
--   
-- -- For this common case of only being concerned with a single type of -- JSON value, the functions withObject, withScientific, -- etc. are provided. Their use is to be preferred when possible, since -- they are more terse. Using withObject, we can rewrite the above -- instance (assuming the same language extension and data type) as: -- --
--   instance FromJSON Coord where
--       parseJSON = withObject "Coord" $ \v -> Coord
--           <$> v .: "x"
--           <*> v .: "y"
--   
-- -- Instead of manually writing your FromJSON instance, there are -- two options to do it automatically: -- -- -- -- To use the second, simply add a deriving Generic -- clause to your datatype and declare a FromJSON instance for -- your datatype without giving a definition for parseJSON. -- -- For example, the previous example can be simplified to just: -- --
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving Generic
--   
--   instance FromJSON Coord
--   
-- -- The default implementation will be equivalent to parseJSON = -- genericParseJSON defaultOptions; if you need -- different options, you can customize the generic decoding by defining: -- --
--   customOptions = defaultOptions
--                   { fieldLabelModifier = map toUpper
--                   }
--   
--   instance FromJSON Coord where
--       parseJSON = genericParseJSON customOptions
--   
class FromJSON a parseJSON :: FromJSON a => Value -> Parser a type JsonOptions = Options type JsonValue = Value pattern JsonArray :: Vector JsonValue -> JsonValue pattern JsonBoolean :: Bool -> JsonValue pattern JsonNull :: JsonValue pattern JsonNumber :: Scientific -> JsonValue pattern JsonObject :: Object -> JsonValue pattern JsonString :: Text -> JsonValue module Prolude.Aws -- | Monads in which AWS actions may be embedded. class (Functor m, Applicative m, Monad m, MonadIO m, MonadCatch m) => MonadAWS (m :: Type -> Type) -- | Lift a computation to the AWS monad. liftAWS :: MonadAWS m => AWS a -> m a type AwsEnv = Env sendAws :: (MonadAWS m, AWSRequest a) => a -> m (Rs a) module Prolude.ByteString -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A ByteString contains 8-bit bytes, or by using the operations -- from Data.ByteString.Char8 it can be interpreted as containing -- 8-bit characters. data ByteString writeByteStringToFile :: MonadIO m => FilePath -> ByteString -> m () type LazyByteString = ByteString putLazyByteString :: MonadIO m => LazyByteString -> m () module Prolude.Core -- | A functor with application, providing operations to -- -- -- -- A minimal complete definition must include implementations of -- pure and of either <*> or liftA2. If it -- defines both, then they must behave the same as their default -- definitions: -- --
--   (<*>) = liftA2 id
--   
-- --
--   liftA2 f x y = f <$> x <*> y
--   
-- -- Further, any definition must satisfy the following: -- -- -- -- The other methods have the following default definitions, which may be -- overridden with equivalent specialized implementations: -- -- -- -- As a consequence of these laws, the Functor instance for -- f will satisfy -- -- -- -- It may be useful to note that supposing -- --
--   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 <*> -- | 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: -- -- -- -- Furthermore, the Monad and Applicative operations should -- relate as follows: -- -- -- -- The above laws imply: -- -- -- -- and that pure and (<*>) satisfy the applicative -- functor laws. -- -- The instances of Monad for lists, Maybe and IO -- defined in the Prelude satisfy these laws. class Applicative m => Monad (m :: Type -> Type) -- | Sequentially compose two actions, passing any value produced by the -- first as an argument to the second. -- -- 'as >>= bs' can be understood as the do -- expression -- --
--   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 infixl 1 >>= infixl 1 >> -- | 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 -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following: -- -- -- -- The method names refer to the monoid of lists under concatenation, but -- there are many other instances. -- -- Some types can be viewed as a monoid in more than one way, e.g. both -- addition and multiplication on numbers. In such cases we often define -- newtypes and make those instances of Monoid, e.g. -- Sum and Product. -- -- NOTE: Semigroup is a superclass of Monoid since -- base-4.11.0.0. class Semigroup a => Monoid a -- | Identity of mappend -- --
--   >>> "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 -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
--   f x | x < 0     = ...
--       | otherwise = ...
--   
otherwise :: Bool data Bool False :: Bool True :: Bool -- | 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 -- | A bifunctor is a type constructor that takes two type arguments and is -- a functor in both arguments. That is, unlike with -- Functor, a type constructor such as Either does not need -- to be partially applied for a Bifunctor instance, and the -- methods in this class permit mapping functions over the Left -- value or the Right value, or both at the same time. -- -- Formally, the class Bifunctor represents a bifunctor from -- Hask -> Hask. -- -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- -- You can define a Bifunctor by either defining bimap or -- by defining both first and second. -- -- If you supply bimap, you should ensure that: -- --
--   bimap id idid
--   
-- -- If you supply first and second, ensure: -- --
--   first idid
--   second idid
--   
-- -- If you supply both, you should also ensure: -- --
--   bimap f g ≡ first f . second g
--   
-- -- These ensure by parametricity: -- --
--   bimap  (f . g) (h . i) ≡ bimap f h . bimap g i
--   first  (f . g) ≡ first  f . first  g
--   second (f . g) ≡ second f . second g
--   
class Bifunctor (p :: Type -> Type -> Type) -- | Map over both arguments at the same time. -- --
--   bimap f g ≡ first f . second g
--   
-- --

Examples

-- --
--   >>> bimap toUpper (+1) ('j', 3)
--   ('J',4)
--   
-- --
--   >>> bimap toUpper (+1) (Left 'j')
--   Left 'J'
--   
-- --
--   >>> bimap toUpper (+1) (Right 3)
--   Right 4
--   
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d -- | Map covariantly over the first argument. -- --
--   first f ≡ bimap f id
--   
-- --

Examples

-- --
--   >>> first toUpper ('j', 3)
--   ('J',3)
--   
-- --
--   >>> first toUpper (Left 'j')
--   Left 'J'
--   
first :: Bifunctor p => (a -> b) -> p a c -> p b c -- | Map covariantly over the second argument. -- --
--   secondbimap id
--   
-- --

Examples

-- --
--   >>> second (+1) ('j', 3)
--   ('j',4)
--   
-- --
--   >>> second (+1) (Right 3)
--   Right 4
--   
second :: Bifunctor p => (b -> c) -> p a b -> p a c -- | 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"). -- --

Examples

-- -- The type Either String Int is the type -- of values which can be either a String or an Int. The -- Left constructor can be used only on Strings, and the -- Right constructor can be used only on Ints: -- --
--   >>> 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 -- | 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. -- --

Examples

-- -- We create two values of type Either String -- Int, one using the Left constructor and another -- using the Right constructor. Then we apply "either" the -- length function (if we have a String) or the "times-two" -- function (if we have an Int): -- --
--   >>> 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 Eq class defines equality (==) and inequality -- (/=). All the basic datatypes exported by the Prelude -- are instances of Eq, and Eq may be derived for any -- datatype whose constituents are also instances of Eq. -- -- The Haskell Report defines no laws for Eq. However, == -- is customarily expected to implement an equivalence relationship where -- two values comparing equal are indistinguishable by "public" -- functions, with a "public" function being one not allowing to see -- implementation details. For example, for a type representing -- non-normalised natural numbers modulo 100, a "public" function doesn't -- make the difference between 1 and 201. It is expected to have the -- following properties: -- -- -- -- Minimal complete definition: either == or /=. class Eq a (==) :: Eq a => a -> a -> Bool (/=) :: Eq a => a -> a -> Bool infix 4 == infix 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 -- | 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 -- | 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 sum function computes the sum of the numbers of a -- structure. sum :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | 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 () -- | 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] -- | & 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 & -- | 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 <$ -- | 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. -- --

Examples

-- -- Convert from a Maybe Int to a Maybe -- String using show: -- --
--   >>> 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 <$> -- | The kind of types with lifted values. For example Int :: -- Type. type Type = Type -- | The kind of constraints, like Show a data Constraint -- | 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: -- -- -- -- Note that the following operator interactions are expected to hold: -- --
    --
  1. x >= y = y <= x
  2. --
  3. x < y = x <= y && x /= y
  4. --
  5. x > y = y < x
  6. --
  7. x < y = compare x y == LT
  8. --
  9. x > y = compare x y == GT
  10. --
  11. x == y = compare x y == EQ
  12. --
  13. min x y == if x <= y then x else y = True
  14. --
  15. max x y == if x >= y then x else y = True
  16. --
-- -- Note that (7.) and (8.) do not require min and -- max to return either of their arguments. The result is merely -- required to equal one of the arguments in terms of (==). -- -- Minimal complete definition: either compare or <=. -- Using compare can be more efficient for complex types. class Eq a => Ord a compare :: Ord a => a -> a -> Ordering (<) :: Ord a => a -> a -> Bool (<=) :: Ord a => a -> a -> Bool (>) :: Ord a => a -> a -> Bool (>=) :: Ord a => a -> a -> Bool max :: Ord a => a -> a -> a min :: Ord a => a -> a -> a infix 4 < infix 4 <= infix 4 > infix 4 >= data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the undefined :: a idiom. -- --
--   >>> 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 of semigroups (types with an associative binary operation). -- -- Instances should satisfy the following: -- -- class Semigroup a -- | An associative operation. -- --
--   >>> [1,2,3] <> [4,5,6]
--   [1,2,3,4,5,6]
--   
(<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | Functors representing data structures that can be traversed from left -- to right. -- -- A definition of traverse must satisfy the following laws: -- -- -- -- A definition of sequenceA must satisfy the following laws: -- -- -- -- where an applicative transformation is a function -- --
--   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: -- -- -- -- References: [1] The Essence of the Iterator Pattern, Jeremy Gibbons -- and Bruno C. d. S. Oliveira class (Functor t, Foldable t) => Traversable (t :: Type -> Type) -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) -- | Evaluate each monadic action in the structure from left to right, and -- collect the results. For a version that ignores the results see -- sequence_. sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) -- | 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` -- | Application operator. This operator is redundant, since ordinary -- application (f x) means the same as (f $ x). -- However, $ has low, right-associative binding precedence, so it -- sometimes allows parentheses to be omitted; for example: -- --
--   f $ g $ h x  =  f (g (h x))
--   
-- -- It is also useful in higher-order situations, such as map -- ($ 0) xs, or zipWith ($) fs xs. -- -- Note that ($) is levity-polymorphic in its result -- type, so that foo $ True where foo :: Bool -> -- Int# is well-typed. ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $ -- | Inject a value into the monadic type. return :: Monad m => a -> m a -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | 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 -- | Function composition. (.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 . -- | 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 -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
--   >>> flip (++) "hello" "world"
--   "worldhello"
--   
flip :: (a -> b -> c) -> b -> a -> c -- | 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 -- | error stops execution and displays an error message. error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a -- | Representable types of kind *. This class is derivable in GHC -- with the DeriveGeneric flag on. -- -- A Generic instance must satisfy the following laws: -- --
--   from . toid
--   to . fromid
--   
class Generic a -- | 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 -- | Conversion of values to readable Strings. -- -- Derived instances of Show have the following properties, which -- are compatible with derived instances of Read: -- -- -- -- For example, given the declarations -- --
--   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, -- -- class Show a -- | A specialised variant of showsPrec, using precedence context -- zero, and returning an ordinary String. show :: Show a => a -> String -- | 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 () -- | 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 -- | 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 -- | 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 () -- | Parsing of Strings, producing values. -- -- Derived instances of Read make the following assumptions, which -- derived instances of Show obey: -- -- -- -- For example, given the declarations -- --
--   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 -- | 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 -- | <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)] -- | 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] -- | unzip transforms a list of pairs into a list of first -- components and a list of second components. unzip :: [(a, b)] -> ([a], [b]) -- | <math>. zipWith generalises zip by zipping with -- the function given as the first argument, instead of a tupling -- function. For example, zipWith (+) is applied to two -- lists to produce the list of corresponding sums: -- --
--   >>> 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] -- | 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]) -- | 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] -- | 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] -- | <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 -- | 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]) -- | 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 -- | 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 -- | Trigonometric and hyperbolic functions and related functions. -- -- The Haskell Report defines no laws for Floating. However, -- (+), (*) and exp are -- customarily expected to define an exponential field and have the -- following properties: -- -- class Fractional a => Floating a (**) :: Floating a => a -> a -> a logBase :: Floating a => a -> a -> a infixr 8 ** -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat 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 -- | 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 -- | 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: -- -- -- -- Note that it isn't customarily expected that a type instance of -- both Num and Ord implement an ordered ring. Indeed, in -- base only Integer and Rational do. class Num a (+) :: Num a => a -> a -> a (-) :: Num a => a -> a -> a (*) :: Num a => a -> a -> a -- | Unary negation. negate :: Num a => a -> a -- | Absolute value. abs :: Num a => a -> a -- | Sign of a number. The functions abs and signum should -- satisfy the law: -- --
--   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 * -- | 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 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 -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | Fractional numbers, supporting real division. -- -- The Haskell Report defines no laws for Fractional. However, -- (+) and (*) are customarily expected -- to define a division ring and have the following properties: -- -- -- -- Note that it isn't customarily expected that a type instance of -- Fractional implement a field. However, all instances in -- base do. class Num a => Fractional a -- | Fractional division. (/) :: Fractional a => a -> a -> a -- | Reciprocal fraction. recip :: Fractional a => a -> a -- | Conversion from a Rational (that is Ratio -- Integer). A floating literal stands for an application of -- fromRational to a value of type Rational, so such -- literals have type (Fractional a) => a. fromRational :: Fractional a => Rational -> a infixl 7 / -- | Integral numbers, supporting integer division. -- -- The Haskell Report defines no laws for Integral. However, -- Integral instances are customarily expected to define a -- Euclidean domain and have the following properties for the -- div/mod and quot/rem pairs, given suitable -- Euclidean functions f and g: -- -- -- -- An example of a suitable Euclidean function, for Integer's -- instance, is abs. class (Real a, Enum a) => Integral a -- | integer division truncated toward zero quot :: Integral a => a -> a -> a -- | integer remainder, satisfying -- --
--   (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` class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | truncate x returns the integer nearest x -- between zero and x truncate :: (RealFrac a, Integral b) => a -> b -- | round x returns the nearest integer to x; the -- even integer if x is equidistant between two integers round :: (RealFrac a, Integral b) => a -> b -- | ceiling x returns the least integer not less than -- x ceiling :: (RealFrac a, Integral b) => a -> b -- | floor x returns the greatest integer not greater than -- x floor :: (RealFrac a, Integral b) => a -> b -- | Rational numbers, with numerator and denominator of some -- Integral type. -- -- Note that Ratio's instances inherit the deficiencies from the -- type parameter's. For example, Ratio Natural's Num -- instance has similar problems to Natural's. data Ratio a -- | 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 -- | lcm x y is the smallest positive integer that both -- x and y divide. lcm :: Integral a => a -> a -> a -- | gcd x y is the non-negative factor of both x -- and y of which every common factor of x and -- y is also a factor; for example gcd 4 2 = 2, -- gcd (-4) 6 = 2, gcd 0 4 = 4. -- gcd 0 0 = 0. (That is, the common divisor -- that is "greatest" in the divisibility preordering.) -- -- Note: Since for signed fixed-width integer types, abs -- minBound < 0, the result may be negative if one of the -- arguments is minBound (and necessarily is if the other -- is 0 or minBound) for such types. gcd :: Integral a => a -> a -> a -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 ^^ -- | raise a number to a non-negative integral power (^) :: (Num a, Integral b) => a -> b -> a infixr 8 ^ odd :: Integral a => a -> Bool even :: Integral a => a -> Bool -- | Type representing arbitrary-precision non-negative integers. -- --
--   >>> 2^100 :: Natural
--   1267650600228229401496703205376
--   
-- -- Operations whose result would be negative throw -- (Underflow :: ArithException), -- --
--   >>> -1 :: Natural
--   *** Exception: arithmetic underflow
--   
data Natural -- | 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 -- | The toEnum method restricted to the type Char. chr :: Int -> Char -- | The fromEnum method restricted to the type Char. ord :: Char -> Int -- | A String is a list of characters. String constants in Haskell -- are values of type String. -- -- See Data.List for operations on lists. type String = [Char] -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | Extract the first component of a pair. fst :: (a, b) -> a -- | Extract the second component of a pair. snd :: (a, b) -> b -- | uncurry converts a curried function to a function on pairs. -- --

Examples

-- --
--   >>> 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. -- --

Examples

-- --
--   >>> curry fst 1 2
--   1
--   
curry :: ((a, b) -> c) -> a -> b -> c identity :: a -> a stm :: MonadIO m => STM a -> m a module Prolude.Csv -- | A type that can be converted to a single CSV record. -- -- An example type and instance: -- --
--   data Person = Person { name :: !Text, age :: !Int }
--   
--   instance ToNamedRecord Person where
--       toNamedRecord (Person name age) = namedRecord [
--           "name" .= name, "age" .= age]
--   
class ToNamedRecord a -- | A type that has a default field order when converted to CSV. This -- class lets you specify how to get the headers to use for a record type -- that's an instance of ToNamedRecord. -- -- To derive an instance, the type is required to only have one -- constructor and that constructor must have named fields (also known as -- selectors) for all fields. -- -- Right: data Foo = Foo { foo :: !Int } -- -- Wrong: data Bar = Bar Int -- -- If you try to derive an instance using GHC generics and your type -- doesn't have named fields, you will get an error along the lines of: -- --
--   <interactive>:9:10:
--       No instance for (DefaultOrdered (M1 S NoSelector (K1 R Char) ()))
--         arising from a use of ‘Data.Csv.Conversion.$gdmheader’
--       In the expression: Data.Csv.Conversion.$gdmheader
--       In an equation for ‘header’:
--           header = Data.Csv.Conversion.$gdmheader
--       In the instance declaration for ‘DefaultOrdered Foo’
--   
class DefaultOrdered a type FromCsvField = FromField type ToCsvField = ToField parseCsvField :: FromCsvField a => Field -> Parser a toCsvField :: ToCsvField a => a -> Field module Prolude.Esqueleto -- | A left-precedence pair. Pronounced "and". Used to represent -- expressions that have been joined together. -- -- The precedence behavior can be demonstrated by: -- --
--   a :& b :& c == ((a :& b) :& c)
--   
-- -- See the examples at the beginning of this module to see how this -- operator is used in JOIN operations. data a :& b infixl 2 :& (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Entity val) -> SqlExpr Update infixr 3 =. (||.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool) infixr 2 ||. (&&.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool) infixr 3 &&. (!=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 !=. (<.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 <. (<=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 <=. (>.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 >. (>=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 >=. (==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 ==. -- | Project a field of an entity that may be null. (?.) :: (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) -- | Project a field of an entity. (^.) :: forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) infixl 9 ^. module Prolude.Exception -- | If the first argument evaluates to True, then the result is the -- second argument. Otherwise an AssertionFailed exception is -- raised, containing a String with the source file and line -- number of the call to assert. -- -- Assertions can normally be turned on or off with a compiler flag (for -- GHC, assertions are normally on unless optimisation is turned on with -- -O or the -fignore-asserts option is given). When -- assertions are turned off, the first argument to assert is -- ignored, and the second argument is returned as the result. assert :: Bool -> a -> a -- | The class Typeable allows a concrete representation of a type -- to be calculated. class Typeable (a :: k) -- | Superclass for asynchronous exceptions. data SomeAsyncException SomeAsyncException :: e -> SomeAsyncException -- | Exceptions that occur in the IO monad. An -- IOException records a more specific error type, a descriptive -- string and maybe the handle that was used when the error was flagged. data IOException -- | Any type that you wish to throw or catch as an exception must be an -- instance of the Exception class. The simplest case is a new -- exception type directly below the root: -- --
--   data MyException = ThisException | ThatException
--       deriving Show
--   
--   instance Exception MyException
--   
-- -- The default method definitions in the Exception class do what -- we need in this case. You can now throw and catch -- ThisException and ThatException as exceptions: -- --
--   *Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
--   Caught ThisException
--   
-- -- In more complicated examples, you may wish to define a whole hierarchy -- of exceptions: -- --
--   ---------------------------------------------------------------------
--   -- Make the root exception type for all the exceptions in a compiler
--   
--   data SomeCompilerException = forall e . Exception e => SomeCompilerException e
--   
--   instance Show SomeCompilerException where
--       show (SomeCompilerException e) = show e
--   
--   instance Exception SomeCompilerException
--   
--   compilerExceptionToException :: Exception e => e -> SomeException
--   compilerExceptionToException = toException . SomeCompilerException
--   
--   compilerExceptionFromException :: Exception e => SomeException -> Maybe e
--   compilerExceptionFromException x = do
--       SomeCompilerException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make a subhierarchy for exceptions in the frontend of the compiler
--   
--   data SomeFrontendException = forall e . Exception e => SomeFrontendException e
--   
--   instance Show SomeFrontendException where
--       show (SomeFrontendException e) = show e
--   
--   instance Exception SomeFrontendException where
--       toException = compilerExceptionToException
--       fromException = compilerExceptionFromException
--   
--   frontendExceptionToException :: Exception e => e -> SomeException
--   frontendExceptionToException = toException . SomeFrontendException
--   
--   frontendExceptionFromException :: Exception e => SomeException -> Maybe e
--   frontendExceptionFromException x = do
--       SomeFrontendException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make an exception type for a particular frontend compiler exception
--   
--   data MismatchedParentheses = MismatchedParentheses
--       deriving Show
--   
--   instance Exception MismatchedParentheses where
--       toException   = frontendExceptionToException
--       fromException = frontendExceptionFromException
--   
-- -- We can now catch a MismatchedParentheses exception as -- MismatchedParentheses, SomeFrontendException or -- SomeCompilerException, but not other types, e.g. -- IOException: -- --
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
--   *** Exception: MismatchedParentheses
--   
class (Typeable e, Show e) => Exception e toException :: Exception e => e -> SomeException fromException :: Exception e => SomeException -> Maybe e -- | Render this exception value in a human-friendly manner. -- -- Default implementation: show. displayException :: Exception e => e -> String -- | The SomeException type is the root of the exception type -- hierarchy. When an exception of type e is thrown, behind the -- scenes it is encapsulated in a SomeException. data SomeException SomeException :: e -> SomeException -- | A class for monads in which exceptions may be thrown. -- -- Instances should obey the following law: -- --
--   throwM e >> x = throwM e
--   
-- -- In other words, throwing an exception short-circuits the rest of the -- monadic computation. class Monad m => MonadThrow (m :: Type -> Type) -- | Flipped catchIOError handleIOError :: MonadCatch m => (IOError -> m a) -> m a -> m a -- | Catch all IOError (eqv. IOException) exceptions. Still -- somewhat too general, but better than using catchAll. See -- catchIf for an easy way of catching specific IOErrors -- based on the predicates in System.IO.Error. catchIOError :: MonadCatch m => m a -> (IOError -> m a) -> m a -- | Like uninterruptibleMask, but does not pass a restore -- action to the argument. uninterruptibleMask_ :: MonadMask m => m a -> m a -- | Like mask, but does not pass a restore action to the -- argument. mask_ :: MonadMask m => m a -> m a -- | A class for monads which allow exceptions to be caught, in particular -- exceptions which were thrown by throwM. -- -- Instances should obey the following law: -- --
--   catch (throwM e) f = f e
--   
-- -- Note that the ability to catch an exception does not guarantee -- that we can deal with all possible exit points from a computation. -- Some monads, such as continuation-based stacks, allow for more than -- just a success/failure strategy, and therefore catch -- cannot be used by those monads to properly implement a function -- such as finally. For more information, see MonadMask. class MonadThrow m => MonadCatch (m :: Type -> Type) -- | A class for monads which provide for the ability to account for all -- possible exit points from a computation, and to mask asynchronous -- exceptions. Continuation-based monads are invalid instances of this -- class. -- -- Instances should ensure that, in the following code: -- --
--   fg = f `finally` g
--   
-- -- The action g is called regardless of what occurs within -- f, including async exceptions. Some monads allow f -- to abort the computation via other effects than throwing an exception. -- For simplicity, we will consider aborting and throwing an exception to -- be two forms of "throwing an error". -- -- If f and g both throw an error, the error thrown by -- fg depends on which errors we're talking about. In a monad -- transformer stack, the deeper layers override the effects of the inner -- layers; for example, ExceptT e1 (Except e2) a represents a -- value of type Either e2 (Either e1 a), so throwing both an -- e1 and an e2 will result in Left e2. If -- f and g both throw an error from the same layer, -- instances should ensure that the error from g wins. -- -- Effects other than throwing an error are also overriden by the deeper -- layers. For example, StateT s Maybe a represents a value of -- type s -> Maybe (a, s), so if an error thrown from -- f causes this function to return Nothing, any -- changes to the state which f also performed will be erased. -- As a result, g will see the state as it was before -- f. Once g completes, f's error will be -- rethrown, so g' state changes will be erased as well. This is -- the normal interaction between effects in a monad transformer stack. -- -- By contrast, lifted-base's version of finally always -- discards all of g's non-IO effects, and g never sees -- any of f's non-IO effects, regardless of the layer ordering -- and regardless of whether f throws an error. This is not the -- result of interacting effects, but a consequence of -- MonadBaseControl's approach. class MonadCatch m => MonadMask (m :: Type -> Type) -- | Runs an action with asynchronous exceptions disabled. The action is -- provided a method for restoring the async. environment to what it was -- at the mask call. See Control.Exception's mask. mask :: MonadMask m => ((forall a. () => m a -> m a) -> m b) -> m b -- | Like mask, but the masked computation is not interruptible (see -- Control.Exception's uninterruptibleMask. WARNING: Only -- use if you need to mask exceptions around an interruptible operation -- AND you can guarantee the interruptible operation will only block for -- a short period of time. Otherwise you render the program/thread -- unresponsive and/or unkillable. uninterruptibleMask :: MonadMask m => ((forall a. () => m a -> m a) -> m b) -> m b -- | A generalized version of bracket which uses ExitCase to -- distinguish the different exit cases, and returns the values of both -- the use and release actions. In practice, this extra -- information is rarely needed, so it is often more convenient to use -- one of the simpler functions which are defined in terms of this one, -- such as bracket, finally, onError, and -- bracketOnError. -- -- This function exists because in order to thread their effects through -- the execution of bracket, monad transformers need values to be -- threaded from use to release and from -- release to the output value. -- -- NOTE This method was added in version 0.9.0 of this library. -- Previously, implementation of functions like bracket and -- finally in this module were based on the mask and -- uninterruptibleMask functions only, disallowing some classes of -- tranformers from having MonadMask instances (notably -- multi-exit-point transformers like ExceptT). If you are a -- library author, you'll now need to provide an implementation for this -- method. The StateT implementation demonstrates most of the -- subtleties: -- --
--   generalBracket acquire release use = StateT $ s0 -> do
--     ((b, _s2), (c, s3)) <- generalBracket
--       (runStateT acquire s0)
--       ((resource, s1) exitCase -> case exitCase of
--         ExitCaseSuccess (b, s2) -> runStateT (release resource (ExitCaseSuccess b)) s2
--   
--         -- In the two other cases, the base monad overrides use's state
--         -- changes and the state reverts to s1.
--         ExitCaseException e     -> runStateT (release resource (ExitCaseException e)) s1
--         ExitCaseAbort           -> runStateT (release resource ExitCaseAbort) s1
--       )
--       ((resource, s1) -> runStateT (use resource) s1)
--     return ((b, c), s3)
--   
-- -- The StateT s m implementation of generalBracket -- delegates to the m implementation of generalBracket. -- The acquire, use, and release arguments -- given to StateT's implementation produce actions of type -- StateT s m a, StateT s m b, and StateT s m -- c. In order to run those actions in the base monad, we need to -- call runStateT, from which we obtain actions of type m -- (a, s), m (b, s), and m (c, s). Since each -- action produces the next state, it is important to feed the state -- produced by the previous action to the next action. -- -- In the ExitCaseSuccess case, the state starts at s0, -- flows through acquire to become s1, flows through -- use to become s2, and finally flows through -- release to become s3. In the other two cases, -- release does not receive the value s2, so its action -- cannot see the state changes performed by use. This is fine, -- because in those two cases, an error was thrown in the base monad, so -- as per the usual interaction between effects in a monad transformer -- stack, those state changes get reverted. So we start from s1 -- instead. -- -- Finally, the m implementation of generalBracket -- returns the pairs (b, s) and (c, s). For monad -- transformers other than StateT, this will be some other type -- representing the effects and values performed and returned by the -- use and release actions. The effect part of the -- use result, in this case _s2, usually needs to be -- discarded, since those effects have already been incorporated in the -- release action. -- -- The only effect which is intentionally not incorporated in the -- release action is the effect of throwing an error. In that -- case, the error must be re-thrown. One subtlety which is easy to miss -- is that in the case in which use and release both -- throw an error, the error from release should take priority. -- Here is an implementation for ExceptT which demonstrates how -- to do this. -- --
--   generalBracket acquire release use = ExceptT $ do
--     (eb, ec) <- generalBracket
--       (runExceptT acquire)
--       (eresource exitCase -> case eresource of
--         Left e -> return (Left e) -- nothing to release, acquire didn't succeed
--         Right resource -> case exitCase of
--           ExitCaseSuccess (Right b) -> runExceptT (release resource (ExitCaseSuccess b))
--           ExitCaseException e       -> runExceptT (release resource (ExitCaseException e))
--           _                         -> runExceptT (release resource ExitCaseAbort))
--       (either (return . Left) (runExceptT . use))
--     return $ do
--       -- The order in which we perform those two Either effects determines
--       -- which error will win if they are both Lefts. We want the error from
--       -- release to win.
--       c <- ec
--       b <- eb
--       return (b, c)
--   
generalBracket :: MonadMask m => m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c) -- | Generalized version of Handler data Handler (m :: Type -> Type) a Handler :: (e -> m a) -> Handler (m :: Type -> Type) a -- | catches without async exception safety -- -- Generally it's better to avoid using this function since we do not -- want to recover from async exceptions, see -- https://github.com/fpco/safe-exceptions#quickstart catchesAsync :: (MonadCatch m, MonadThrow m) => m a -> [Handler m a] -> m a -- | Same as catches, but fully force evaluation of the result value -- to find all impure exceptions. catchesDeep :: (MonadCatch m, MonadThrow m, MonadIO m, NFData a) => m a -> [Handler m a] -> m a -- | Same as upstream catches, but will not catch asynchronous -- exceptions catches :: (MonadCatch m, MonadThrow m) => m a -> [Handler m a] -> m a -- | Check if the given exception is asynchronous isAsyncException :: Exception e => e -> Bool -- | Check if the given exception is synchronous isSyncException :: Exception e => e -> Bool -- | Convert an exception into an asynchronous exception -- -- For asynchronous exceptions, this is the same as toException. -- For synchronous exceptions, this will wrap up the exception with -- AsyncExceptionWrapper toAsyncException :: Exception e => e -> SomeException -- | Convert an exception into a synchronous exception -- -- For synchronous exceptions, this is the same as toException. -- For asynchronous exceptions, this will wrap up the exception with -- SyncExceptionWrapper toSyncException :: Exception e => e -> SomeException -- | Async safe version of bracket with access to the exception in -- the cleanup action. bracketWithError :: MonadMask m => m a -> (Maybe SomeException -> a -> m b) -> (a -> m c) -> m c -- | A variant of bracketOnError where the return value from the -- first computation is not required. bracketOnError_ :: MonadMask m => m a -> m b -> m c -> m c -- | Async safe version of bracketOnError bracketOnError :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c -- | Async safe version of finally finally :: MonadMask m => m a -> m b -> m a -- | Async safe version of bracket_ bracket_ :: MonadMask m => m a -> m b -> m c -> m c -- | Async safe version of bracket bracket :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c -- | Like onException, but provides the handler the thrown -- exception. withException :: (MonadMask m, Exception e) => m a -> (e -> m b) -> m a -- | Async safe version of onException onException :: MonadMask m => m a -> m b -> m a -- | A variant of try that takes an exception predicate to select -- which exceptions are caught. tryJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) -- | try without async exception safety -- -- Generally it's better to avoid using this function since we do not -- want to recover from async exceptions, see -- https://github.com/fpco/safe-exceptions#quickstart tryAsync :: (MonadCatch m, Exception e) => m a -> m (Either e a) -- | tryDeep specialized to catch all synchronous exceptions tryAnyDeep :: (MonadCatch m, MonadIO m, NFData a) => m a -> m (Either SomeException a) -- | Same as try, but fully force evaluation of the result value to -- find all impure exceptions. tryDeep :: (MonadCatch m, MonadIO m, Exception e, NFData a) => m a -> m (Either e a) -- | try specialized to catch all synchronous exceptions tryAny :: MonadCatch m => m a -> m (Either SomeException a) -- | try specialized to only catching IOExceptions tryIO :: MonadCatch m => m a -> m (Either IOException a) -- | Same as upstream try, but will not catch asynchronous -- exceptions try :: (MonadCatch m, Exception e) => m a -> m (Either e a) -- | Flipped catchJust. handleJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a -- | Flipped version of catchAsync -- -- Generally it's better to avoid using this function since we do not -- want to recover from async exceptions, see -- https://github.com/fpco/safe-exceptions#quickstart handleAsync :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a -- | Flipped version of catchAnyDeep handleAnyDeep :: (MonadCatch m, MonadIO m, NFData a) => (SomeException -> m a) -> m a -> m a -- | Flipped version of catchDeep handleDeep :: (MonadCatch m, Exception e, MonadIO m, NFData a) => (e -> m a) -> m a -> m a -- | Flipped version of catchAny handleAny :: MonadCatch m => (SomeException -> m a) -> m a -> m a -- | handle specialized to only catching IOExceptions handleIO :: MonadCatch m => (IOException -> m a) -> m a -> m a -- | Flipped version of catch handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a -- | catchJust is like catch but it takes an extra argument -- which is an exception predicate, a function which selects which type -- of exceptions we're interested in. catchJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a -- | catch without async exception safety -- -- Generally it's better to avoid using this function since we do not -- want to recover from async exceptions, see -- https://github.com/fpco/safe-exceptions#quickstart catchAsync :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a -- | catchDeep specialized to catch all synchronous exception catchAnyDeep :: (MonadCatch m, MonadIO m, NFData a) => m a -> (SomeException -> m a) -> m a -- | Same as catch, but fully force evaluation of the result value -- to find all impure exceptions. catchDeep :: (MonadCatch m, MonadIO m, Exception e, NFData a) => m a -> (e -> m a) -> m a -- | catch specialized to catch all synchronous exception catchAny :: MonadCatch m => m a -> (SomeException -> m a) -> m a -- | Same as upstream catch, but will not catch asynchronous -- exceptions catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a -- | Generate a pure value which, when forced, will synchronously throw the -- given exception -- -- Generally it's better to avoid using this function and instead use -- throw, see -- https://github.com/fpco/safe-exceptions#quickstart impureThrow :: Exception e => e -> a -- | Throw an asynchronous exception to another thread. -- -- Synchronously typed exceptions will be wrapped into an -- AsyncExceptionWrapper, see -- https://github.com/fpco/safe-exceptions#determining-sync-vs-async -- -- It's usually a better idea to use the async package, see -- https://github.com/fpco/safe-exceptions#quickstart throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m () -- | A convenience function for throwing a user error. This is useful for -- cases where it would be too high a burden to define your own exception -- type. -- -- This throws an exception of type StringException. When GHC -- supports it (base 4.9 and GHC 8.0 and onward), it includes a call -- stack. throwString :: (MonadThrow m, HasCallStack) => String -> m a -- | Synonym for throw throwIO :: (MonadThrow m, Exception e) => e -> m a -- | Synchronously throw the given exception throw :: (MonadThrow m, Exception e) => e -> m a -- | Exception type thrown by throwString. -- -- Note that the second field of the data constructor depends on GHC/base -- version. For base 4.9 and GHC 8.0 and later, the second field is a -- call stack. Previous versions of GHC and base do not support call -- stacks, and the field is simply unit (provided to make pattern -- matching across GHC versions easier). data StringException StringException :: String -> CallStack -> StringException -- | Wrap up an asynchronous exception to be treated as a synchronous -- exception -- -- This is intended to be created via toSyncException data SyncExceptionWrapper SyncExceptionWrapper :: e -> SyncExceptionWrapper -- | Wrap up a synchronous exception to be treated as an asynchronous -- exception -- -- This is intended to be created via toAsyncException data AsyncExceptionWrapper AsyncExceptionWrapper :: e -> AsyncExceptionWrapper -- | Asynchronous exceptions. data AsyncException -- | The current thread's stack exceeded its limit. Since an exception has -- been raised, the thread's stack will certainly be below its limit -- again, but the programmer should take remedial action immediately. StackOverflow :: AsyncException -- | The program's heap is reaching its limit, and the program should take -- action to reduce the amount of live data it has. Notes: -- -- HeapOverflow :: AsyncException -- | This exception is raised by another thread calling killThread, -- or by the system if it needs to terminate the thread for some reason. ThreadKilled :: AsyncException -- | This exception is raised by default in the main thread of the program -- when the user requests to terminate the program via the usual -- mechanism(s) (e.g. Control-C in the console). UserInterrupt :: AsyncException -- | Catch exception based on a predicate catchIf :: (MonadCatch m, Exception e) => (e -> Bool) -> m a -> (e -> m a) -> m a -- | Function alias for Control.Exception.evaluate unsafeEvaluate :: a -> IO a -- | Function alias for Control.Exception.throw unsafeThrow :: Exception e => e -> a module Prolude.Foldable -- | List of elements of a structure, from left to right. toList :: Foldable t => t a -> [a] -- | A Map from keys k to values a. -- -- The Semigroup operation for Map is union, which -- prefers values from the left operand. If m1 maps a key -- k to a value a1, and m2 maps the same key -- to a different value a2, then their union m1 <> -- m2 maps k to a1. data Map k a -- | A set of values a. data Set a -- | The fromList function constructs the structure l from -- the given list of Item l fromList :: IsList l => [Item l] -> l module Prolude.Json -- | withText name f value applies f to the -- Text when value is a String and fails -- otherwise. -- --

Error message example

-- --
--   withText "MyType" f Null
--   -- Error: "parsing MyType failed, expected String, but encountered Null"
--   
withText :: String -> (Text -> Parser a) -> Value -> Parser a -- | withObject name f value applies f to the -- Object when value is an Object and fails -- otherwise. -- --

Error message example

-- --
--   withObject "MyType" f (String "oops")
--   -- Error: "parsing MyType failed, expected Object, but encountered String"
--   
withObject :: String -> (Object -> Parser a) -> Value -> Parser a -- | A JSON parser. N.B. This might not fit your usual understanding of -- "parser". Instead you might like to think of Parser as a "parse -- result", i.e. a parser to which the input has already been applied. data Parser a -- | Function alias for Aeson.eitherDecode jsonEitherDecode :: FromJSON a => ByteString -> Either String a -- | Function alias for Aeson.encode jsonEncode :: ToJSON a => a -> ByteString module Prolude.Lens -- | Replace the target of a Lens or all of the targets of a -- Setter or Traversal with a constant value. -- -- This is an infix version of set, provided for consistency with -- (.=). -- --
--   f <$ a ≡ mapped .~ f $ a
--   
-- --
--   >>> (a,b,c,d) & _4 .~ e
--   (a,b,c,e)
--   
-- --
--   >>> (42,"world") & _1 .~ "hello"
--   ("hello","world")
--   
-- --
--   >>> (a,b) & both .~ c
--   (c,c)
--   
-- --
--   (.~) :: Setter s t a b    -> b -> s -> t
--   (.~) :: Iso s t a b       -> b -> s -> t
--   (.~) :: Lens s t a b      -> b -> s -> t
--   (.~) :: Traversal s t a b -> b -> s -> t
--   
(.~) :: ASetter s t a b -> b -> s -> t infixr 4 .~ -- | View the value pointed to by a Getter, Iso or -- Lens or the result of folding over all the results of a -- Fold or Traversal that points at a monoidal value. -- --
--   view . toid
--   
-- --
--   >>> view (to f) a
--   f a
--   
-- --
--   >>> view _2 (1,"hello")
--   "hello"
--   
-- --
--   >>> view (to succ) 5
--   6
--   
-- --
--   >>> view (_2._1) ("hello",("world","!!!"))
--   "world"
--   
-- -- As view is commonly used to access the target of a -- Getter or obtain a monoidal summary of the targets of a -- Fold, It may be useful to think of it as having one of these -- more restricted signatures: -- --
--   view ::             Getter s a     -> s -> a
--   view :: Monoid m => Fold s m       -> s -> m
--   view ::             Iso' s a       -> s -> a
--   view ::             Lens' s a      -> s -> a
--   view :: Monoid m => Traversal' s m -> s -> m
--   
-- -- In a more general setting, such as when working with a Monad -- transformer stack you can use: -- --
--   view :: MonadReader s m             => Getter s a     -> m a
--   view :: (MonadReader s m, Monoid a) => Fold s a       -> m a
--   view :: MonadReader s m             => Iso' s a       -> m a
--   view :: MonadReader s m             => Lens' s a      -> m a
--   view :: (MonadReader s m, Monoid a) => Traversal' s a -> m a
--   
view :: MonadReader s m => Getting a s a -> m a -- | Replace the target of a Lens or all of the targets of a -- Setter or Traversal with a constant value. -- --
--   (<$) ≡ set mapped
--   
-- --
--   >>> set _2 "hello" (1,())
--   (1,"hello")
--   
-- --
--   >>> set mapped () [1,2,3,4]
--   [(),(),(),()]
--   
-- -- Note: Attempting to set a Fold or Getter will -- fail at compile time with an relatively nice error message. -- --
--   set :: Setter s t a b    -> b -> s -> t
--   set :: Iso s t a b       -> b -> s -> t
--   set :: Lens s t a b      -> b -> s -> t
--   set :: Traversal s t a b -> b -> s -> t
--   
set :: ASetter s t a b -> b -> s -> t module Prolude.Maybe -- | 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 -- | 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. -- --

Examples

-- -- Basic usage: -- --
--   >>> 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 -- | The isJust function returns True iff its argument is of -- the form Just _. -- --

Examples

-- -- Basic usage: -- --
--   >>> isJust (Just 3)
--   True
--   
-- --
--   >>> isJust (Just ())
--   True
--   
-- --
--   >>> isJust Nothing
--   False
--   
-- -- Only the outer constructor is taken into consideration: -- --
--   >>> isJust (Just Nothing)
--   True
--   
isJust :: Maybe a -> Bool -- | The isNothing function returns True iff its argument is -- Nothing. -- --

Examples

-- -- Basic usage: -- --
--   >>> isNothing (Just 3)
--   False
--   
-- --
--   >>> isNothing (Just ())
--   False
--   
-- --
--   >>> isNothing Nothing
--   True
--   
-- -- Only the outer constructor is taken into consideration: -- --
--   >>> isNothing (Just Nothing)
--   False
--   
isNothing :: Maybe a -> Bool -- | The fromMaybe function takes a default value and and -- Maybe value. If the Maybe is Nothing, it returns -- the default values; otherwise, it returns the value contained in the -- Maybe. -- --

Examples

-- -- Basic usage: -- --
--   >>> fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   
-- --
--   >>> fromMaybe "" Nothing
--   ""
--   
-- -- Read an integer from a string using readMaybe. If we fail to -- parse an integer, we want to return 0 by default: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> fromMaybe 0 (readMaybe "5")
--   5
--   
--   >>> fromMaybe 0 (readMaybe "")
--   0
--   
fromMaybe :: a -> Maybe a -> a -- | The maybeToList function returns an empty list when given -- Nothing or a singleton list when given Just. -- --

Examples

-- -- Basic usage: -- --
--   >>> maybeToList (Just 7)
--   [7]
--   
-- --
--   >>> maybeToList Nothing
--   []
--   
-- -- One can use maybeToList to avoid pattern matching when combined -- with a function that (safely) works on lists: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> sum $ maybeToList (readMaybe "3")
--   3
--   
--   >>> sum $ maybeToList (readMaybe "")
--   0
--   
maybeToList :: Maybe a -> [a] -- | The listToMaybe function returns Nothing on an empty -- list or Just a where a is the first element -- of the list. -- --

Examples

-- -- Basic usage: -- --
--   >>> listToMaybe []
--   Nothing
--   
-- --
--   >>> listToMaybe [9]
--   Just 9
--   
-- --
--   >>> listToMaybe [1,2,3]
--   Just 1
--   
-- -- Composing maybeToList with listToMaybe should be the -- identity on singleton/empty lists: -- --
--   >>> maybeToList $ listToMaybe [5]
--   [5]
--   
--   >>> maybeToList $ listToMaybe []
--   []
--   
-- -- But not on lists with more than one element: -- --
--   >>> maybeToList $ listToMaybe [1,2,3]
--   [1]
--   
listToMaybe :: [a] -> Maybe a -- | The catMaybes function takes a list of Maybes and -- returns a list of all the Just values. -- --

Examples

-- -- Basic usage: -- --
--   >>> catMaybes [Just 1, Nothing, Just 3]
--   [1,3]
--   
-- -- When constructing a list of Maybe values, catMaybes can -- be used to return all of the "success" results (if the list is the -- result of a map, then mapMaybe would be more -- appropriate): -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [Just 1,Nothing,Just 3]
--   
--   >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [1,3]
--   
catMaybes :: [Maybe a] -> [a] -- | The mapMaybe function is a version of map which can -- throw out elements. In particular, the functional argument returns -- something of type Maybe b. If this is Nothing, -- no element is added on to the result list. If it is Just -- b, then b is included in the result list. -- --

Examples

-- -- Using mapMaybe f x is a shortcut for -- catMaybes $ map f x in most cases: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> let readMaybeInt = readMaybe :: String -> Maybe Int
--   
--   >>> mapMaybe readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
-- -- If we map the Just constructor, the entire list should be -- returned: -- --
--   >>> mapMaybe Just [1,2,3]
--   [1,2,3]
--   
mapMaybe :: (a -> Maybe b) -> [a] -> [b] -- | Tag the Nothing value of a Maybe note :: a -> Maybe b -> Either a b -- | Suppress the Left value of an Either hush :: Either a b -> Maybe b module Prolude.Monad -- | Conditional failure of Alternative computations. Defined by -- --
--   guard True  = pure ()
--   guard False = empty
--   
-- --

Examples

-- -- Common uses of guard include conditionally signaling an error -- in an error monad and conditionally rejecting the current choice in an -- Alternative-based parser. -- -- As an example of signaling an error in the error monad Maybe, -- consider a safe division function safeDiv x y that returns -- Nothing when the denominator y is zero and -- Just (x `div` y) otherwise. For example: -- --
--   >>> safeDiv 4 0
--   Nothing
--   >>> safeDiv 4 2
--   Just 2
--   
-- -- A definition of safeDiv using guards, but not guard: -- --
--   safeDiv :: Int -> Int -> Maybe Int
--   safeDiv x y | y /= 0    = Just (x `div` y)
--               | otherwise = Nothing
--   
-- -- A definition of safeDiv using guard and Monad -- do-notation: -- --
--   safeDiv :: Int -> Int -> Maybe Int
--   safeDiv x y = do
--     guard (y /= 0)
--     return (x `div` y)
--   
guard :: Alternative f => Bool -> f () -- | The join function is the conventional monad join operator. It -- is used to remove one level of monadic structure, projecting its bound -- argument into the outer level. -- -- 'join bss' can be understood as the do -- expression -- --
--   do bs <- bss
--      bs
--   
-- --

Examples

-- -- A common use of join is to run an IO computation -- returned from an STM transaction, since STM transactions -- can't perform IO directly. Recall that -- --
--   atomically :: STM a -> IO a
--   
-- -- is used to run STM transactions atomically. So, by specializing -- the types of atomically and join to -- --
--   atomically :: STM (IO b) -> IO (IO b)
--   join       :: IO (IO b)  -> IO b
--   
-- -- we can compose them as -- --
--   join . atomically :: STM (IO b) -> IO b
--   
-- -- to run an STM transaction and the IO action it returns. join :: Monad m => m (m a) -> m a -- | Conditional execution of Applicative expressions. For example, -- --
--   when debug (putStrLn "Debugging")
--   
-- -- will output the string Debugging if the Boolean value -- debug is True, and otherwise do nothing. when :: Applicative f => Bool -> f () -> f () -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- -- Using ApplicativeDo: 'void as' can be -- understood as the do expression -- --
--   do as
--      pure ()
--   
-- -- with an inferred Functor constraint. -- --

Examples

-- -- Replace the contents of a Maybe Int with unit: -- --
--   >>> void Nothing
--   Nothing
--   
--   >>> void (Just 3)
--   Just ()
--   
-- -- Replace the contents of an Either Int -- Int with unit, resulting in an Either -- Int (): -- --
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   >>> void (Right 8675309)
--   Right ()
--   
-- -- Replace every element of a list with unit: -- --
--   >>> void [1,2,3]
--   [(),(),()]
--   
-- -- Replace the second element of a pair with unit: -- --
--   >>> void (1,2)
--   (1,())
--   
-- -- Discard the result of an IO action: -- --
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => 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 () -- | forM is mapM with its arguments flipped. For a version -- that ignores the results see forM_. forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) -- | Repeat an action indefinitely. -- -- Using ApplicativeDo: 'forever as' can be -- understood as the pseudo-do expression -- --
--   do as
--      as
--      ..
--   
-- -- with as repeating. -- --

Examples

-- -- A common use of forever is to process input from network -- sockets, Handles, and channels (e.g. MVar and -- Chan). -- -- For example, here is how we might implement an echo server, -- using forever both to listen for client connections on a -- network socket and to echo client input on client connection handles: -- --
--   echoServer :: Socket -> IO ()
--   echoServer socket = forever $ do
--     client <- accept socket
--     forkFinally (echo client) (\_ -> hClose client)
--     where
--       echo :: Handle -> IO ()
--       echo client = forever $
--         hGetLine client >>= hPutStrLn client
--   
forever :: Applicative f => f a -> f b -- | The reverse of when. unless :: Applicative f => Bool -> f () -> f () module Prolude.MonadIO -- | Monads in which IO computations may be embedded. Any monad -- built by applying a sequence of monad transformers to the IO -- monad will be an instance of this class. -- -- Instances should satisfy the following laws, which state that -- liftIO is a transformer of monads: -- -- class Monad m => MonadIO (m :: Type -> Type) -- | Lift a computation from the IO monad. liftIO :: MonadIO m => IO a -> m a module Prolude.MongoDB -- | Create a fresh ObjectId genObjectId :: IO ObjectId -- | Apply generic function to typed value fval :: (forall a. Val a => a -> b) -> Value -> b -- | Field with given label and typed value (=:) :: Val v => Label -> v -> Field infix 0 =: -- | A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp -- (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a -- 3-byte counter. Note that the timestamp and counter fields must be -- stored big endian unlike the rest of BSON. This is because they are -- compared byte-by-byte and we want to ensure a mostly increasing order. data ObjectId data UpdateOption -- | If set, the database will update all matching objects in the -- collection. Otherwise only updates first matching doc MultiUpdate :: UpdateOption type MongoAction = Action type MongoCollection = Collection type MongoDatabase = Database type MongoDocument = Document type MongoField = Field type MongoLabel = Label type MongoQuery = Query type MongoValue = Value type MongoVal = Val pattern MongoArray :: [Value] -> MongoValue pattern MongoBin :: Binary -> MongoValue pattern MongoBool :: Bool -> MongoValue pattern MongoDoc :: Document -> MongoValue pattern MongoFloat :: Double -> MongoValue pattern MongoFun :: Function -> MongoValue pattern MongoInt32 :: Int32 -> MongoValue pattern MongoInt64 :: Int64 -> MongoValue pattern MongoJavaScr :: Javascript -> MongoValue pattern MongoMd5 :: MD5 -> MongoValue pattern MongoMinMax :: MinMaxKey -> MongoValue pattern MongoNull :: MongoValue pattern MongoObjId :: ObjectId -> MongoValue pattern MongoRegEx :: Regex -> MongoValue pattern MongoStamp :: MongoStamp -> MongoValue pattern MongoString :: Text -> MongoValue pattern MongoSym :: Symbol -> MongoValue pattern MongoUserDef :: UserDefined -> MongoValue pattern MongoUTC :: UTCTime -> MongoValue pattern MongoUuid :: UUID -> MongoValue mongoFailed :: WriteResult -> Bool mongoInsert_ :: MonadIO m => MongoCollection -> MongoDocument -> MongoAction m () mongoModified :: WriteResult -> Maybe Int mongoSelect :: MongoSelector -> MongoCollection -> MongoQuery mongoUpdateMany :: MonadIO m => MongoCollection -> [(MongoSelector, MongoDocument, [UpdateOption])] -> MongoAction m WriteResult (>=:) :: MongoVal v => MongoLabel -> v -> MongoField (>:) :: MongoVal v => MongoLabel -> v -> MongoField (<=:) :: MongoVal v => MongoLabel -> v -> MongoField (<:) :: MongoVal v => MongoLabel -> v -> MongoField (<-:) :: MongoVal v => MongoLabel -> [v] -> MongoField (!<-:) :: MongoVal v => MongoLabel -> [v] -> MongoField (!=:) :: MongoVal v => MongoLabel -> v -> MongoField module Prolude.Persist -- | A SQL data type. Naming attempts to reflect the underlying Haskell -- datatypes, eg SqlString instead of SqlVarchar. Different SQL databases -- may have different translations for these types. data SqlType SqlString :: SqlType SqlInt32 :: SqlType SqlInt64 :: SqlType SqlReal :: SqlType SqlNumeric :: Word32 -> Word32 -> SqlType SqlBool :: SqlType SqlDay :: SqlType SqlTime :: SqlType -- | Always uses UTC timezone SqlDayTime :: SqlType SqlBlob :: SqlType -- | a backend-specific name SqlOther :: Text -> SqlType -- | Datatype that represents an entity, with both its Key and its -- Haskell record representation. -- -- When using a SQL-based backend (such as SQLite or PostgreSQL), an -- Entity may take any number of columns depending on how many -- fields it has. In order to reconstruct your entity on the Haskell -- side, persistent needs all of your entity columns and in the -- right order. Note that you don't need to worry about this when using -- persistent's API since everything is handled correctly behind -- the scenes. -- -- However, if you want to issue a raw SQL command that returns an -- Entity, then you have to be careful with the column order. -- While you could use SELECT Entity.* WHERE ... and that would -- work most of the time, there are times when the order of the columns -- on your database is different from the order that persistent -- expects (for example, if you add a new field in the middle of you -- entity definition and then use the migration code -- -- persistent will expect the column to be in the middle, but -- your DBMS will put it as the last column). So, instead of using a -- query like the one above, you may use rawSql (from the -- Database.Persist.GenericSql module) with its /entity selection -- placeholder/ (a double question mark ??). Using -- rawSql the query above must be written as SELECT ?? WHERE -- ... Then rawSql will replace ?? with the list -- of all columns that we need from your entity in the right order. If -- your query returns two entities (i.e. (Entity backend a, Entity -- backend b)), then you must you use SELECT ??, ?? WHERE -- ..., and so on. data Entity record Entity :: Key record -> record -> Entity record [entityKey] :: Entity record -> Key record [entityVal] :: Entity record -> record -- | Create a new record in the database, returning an automatically -- created key (in SQL an auto-increment id). -- --

Example usage

-- -- Using schema-1 and dataset-1, let's insert a new user -- John. -- --
--   insertJohn :: MonadIO m => ReaderT SqlBackend m (Key User)
--   insertJohn = insert $ User "John" 30
--   
-- --
--   johnId <- insertJohn
--   
-- -- The above query when applied on dataset-1, will produce this: -- --
--   +-----+------+-----+
--   |id   |name  |age  |
--   +-----+------+-----+
--   |1    |SPJ   |40   |
--   +-----+------+-----+
--   |2    |Simon |41   |
--   +-----+------+-----+
--   |3    |John  |30   |
--   +-----+------+-----+
--   
insert :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Key record) -- | Same as insertMany, but doesn't return any Keys. -- -- The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records -- in one database query. -- --

Example usage

-- -- With schema-1 and dataset-1, -- --
--   insertUsers_ :: MonadIO m => ReaderT SqlBackend m ()
--   insertUsers_ = insertMany_ [User "John" 30, User "Nick" 32, User "Jane" 20]
--   
-- -- The above query when applied on dataset-1, will produce this: -- --
--   +-----+------+-----+
--   |id   |name  |age  |
--   +-----+------+-----+
--   |1    |SPJ   |40   |
--   +-----+------+-----+
--   |2    |Simon |41   |
--   +-----+------+-----+
--   |3    |John  |30   |
--   +-----+------+-----+
--   |4    |Nick  |32   |
--   +-----+------+-----+
--   |5    |Jane  |20   |
--   +-----+------+-----+
--   
insertMany_ :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m () -- | Check if there is at least one record fulfilling the given criterion. exists :: forall (m :: Type -> Type) record. (PersistQueryRead backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m Bool -- | Returns a [Entity record] corresponding to the filters -- and options provided. -- -- Filters are constructed using the operators defined in -- Database.Persist (and re-exported from -- Database.Persist.Sql). Let's look at some examples: -- --
--   usersWithAgeOver40 :: SqlPersistT IO [Entity User]
--   usersWithAgeOver40 =
--       selectList [UserAge >=. 40] []
--   
-- -- If you provide multiple values in the list, the conditions are -- ANDed together. -- --
--   usersWithAgeBetween30And50 :: SqlPersistT IO [Entity User]
--   usersWithAgeBetween30And50 =
--        selectList
--            [ UserAge >=. 30
--            , UserAge <=. 50
--            ]
--            []
--   
-- -- The second list contains the SelectOpt for a record. We can -- select the first ten records with LimitTo -- --
--   firstTenUsers =
--       selectList [] [LimitTo 10]
--   
-- -- And we can select the second ten users with OffsetBy. -- --
--   secondTenUsers =
--       selectList [] [LimitTo 10, OffsetBy 10]
--   
-- -- Warning that LIMIT/OFFSET is bad for pagination! -- -- With Asc and Desc, we can provide the field we want to -- sort on. We can provide multiple sort orders - later ones are used to -- sort records that are equal on the first field. -- --
--   newestUsers =
--       selectList [] [Desc UserCreatedAt, LimitTo 10]
--   
--   oldestUsers =
--       selectList [] [Asc UserCreatedAt, LimitTo 10]
--   
selectList :: forall record backend (m :: Type -> Type). (MonadIO m, PersistQueryRead backend, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m [Entity record] -- | This class teaches Persistent how to take a custom type and marshal it -- to and from a PersistValue, allowing it to be stored in a -- database. -- --

Examples

-- --
Simple Newtype
-- -- You can use newtype to add more type safety/readability to a -- basis type like ByteString. In these cases, just derive -- PersistField and PersistFieldSql: -- --
--   {-# LANGUAGE GeneralizedNewtypeDeriving #-}
--   
--   newtype HashedPassword = HashedPassword ByteString
--     deriving (Eq, Show, PersistField, PersistFieldSql)
--   
-- --
Smart Constructor Newtype
-- -- In this example, we create a PersistField instance for a -- newtype following the "Smart Constructor" pattern. -- --
--   {-# LANGUAGE GeneralizedNewtypeDeriving #-}
--   import qualified Data.Text as T
--   import qualified Data.Char as C
--   
--   -- | An American Social Security Number
--   newtype SSN = SSN Text
--    deriving (Eq, Show, PersistFieldSql)
--   
--   mkSSN :: Text -> Either Text SSN
--   mkSSN t = if (T.length t == 9) && (T.all C.isDigit t)
--    then Right $ SSN t
--    else Left $ "Invalid SSN: " <> t
--   
--   instance PersistField SSN where
--     toPersistValue (SSN t) = PersistText t
--     fromPersistValue (PersistText t) = mkSSN t
--     -- Handle cases where the database does not give us PersistText
--     fromPersistValue x = Left $ "File.hs: When trying to deserialize an SSN: expected PersistText, received: " <> T.pack (show x)
--   
-- -- Tips: -- -- class PersistField a toPersistValue :: PersistField a => a -> PersistValue fromPersistValue :: PersistField a => PersistValue -> Either Text a keyToOid :: ToBackendKey MongoContext record => Key record -> ObjectId oidToKey :: ToBackendKey MongoContext record => ObjectId -> Key record type SqlPersistT = ReaderT SqlBackend -- | Tells Persistent what database column type should be used to store a -- Haskell type. -- --

Examples

-- --
Simple Boolean Alternative
-- --
--   data Switch = On | Off
--     deriving (Show, Eq)
--   
--   instance PersistField Switch where
--     toPersistValue s = case s of
--       On -> PersistBool True
--       Off -> PersistBool False
--     fromPersistValue (PersistBool b) = if b then Right On else Right Off
--     fromPersistValue x = Left $ "File.hs: When trying to deserialize a Switch: expected PersistBool, received: " <> T.pack (show x)
--   
--   instance PersistFieldSql Switch where
--     sqlType _ = SqlBool
--   
-- --
Non-Standard Database Types
-- -- If your database supports non-standard types, such as Postgres' -- uuid, you can use SqlOther to use them: -- --
--   import qualified Data.UUID as UUID
--   instance PersistField UUID where
--     toPersistValue = PersistLiteralEncoded . toASCIIBytes
--     fromPersistValue (PersistLiteralEncoded uuid) =
--       case fromASCIIBytes uuid of
--         Nothing -> Left $ "Model/CustomTypes.hs: Failed to deserialize a UUID; received: " <> T.pack (show uuid)
--         Just uuid' -> Right uuid'
--     fromPersistValue x = Left $ "File.hs: When trying to deserialize a UUID: expected PersistLiteralEncoded, received: "-- >  <> T.pack (show x)
--   
--   instance PersistFieldSql UUID where
--     sqlType _ = SqlOther "uuid"
--   
-- --
User Created Database Types
-- -- Similarly, some databases support creating custom types, e.g. -- Postgres' DOMAIN and ENUM features. You can use -- SqlOther to specify a custom type: -- --
--   CREATE DOMAIN ssn AS text
--         CHECK ( value ~ '^[0-9]{9}$');
--   
-- --
--   instance PersistFieldSQL SSN where
--     sqlType _ = SqlOther "ssn"
--   
-- --
--   CREATE TYPE rainbow_color AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet');
--   
-- --
--   instance PersistFieldSQL RainbowColor where
--     sqlType _ = SqlOther "rainbow_color"
--   
class PersistField a => PersistFieldSql a module Prolude.Prim -- | 8-bit unsigned integer type data Word8 -- | 16-bit unsigned integer type data Word16 -- | 32-bit unsigned integer type data Word32 -- | 64-bit unsigned integer type data Word64 -- | 8-bit signed integer type data Int8 -- | 16-bit signed integer type data Int16 -- | 32-bit signed integer type data Int32 -- | 64-bit signed integer type data Int64 module Prolude.Servant -- | Convert value to HTTP API data. -- -- WARNING: Do not derive this using DeriveAnyClass as -- the generated instance will loop indefinitely. class ToHttpApiData a -- | Parse value from HTTP API data. -- -- WARNING: Do not derive this using DeriveAnyClass as -- the generated instance will loop indefinitely. class FromHttpApiData a -- | Parse URL path piece. parseUrlPiece :: FromHttpApiData a => Text -> Either Text a -- | Parse HTTP header value. parseHeader :: FromHttpApiData a => ByteString -> Either Text a -- | Parse query param value. parseQueryParam :: FromHttpApiData a => Text -> Either Text a -- | GET with 200 status code. type Get = Verb 'GET 200 -- | POST with 200 status code. type Post = Verb 'POST 200 -- | PUT with 200 status code. type Put = Verb 'PUT 200 -- | DELETE with 200 status code. type Delete = Verb 'DELETE 200 -- | GET with 204 status code. type GetNoContent = NoContentVerb 'GET -- | POST with 204 status code. type PostNoContent = NoContentVerb 'POST -- | DELETE with 204 status code. type DeleteNoContent = NoContentVerb 'DELETE -- | PUT with 204 status code. type PutNoContent = NoContentVerb 'PUT -- | The contained API (second argument) can be found under ("/" ++ -- path) (path being the first argument). -- -- Example: -- --
--   >>> -- GET /hello/world
--   
--   >>> -- returning a JSON encoded World value
--   
--   >>> type MyApi = "hello" :> "world" :> Get '[JSON] World
--   
data (path :: k) :> a infixr 4 :> -- | Extract the request body as a value of type a. -- -- Example: -- --
--   >>> -- POST /books
--   
--   >>> type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book
--   
type ReqBody = ReqBody' '[Required, Strict] -- | A type for responses without content-body. data NoContent NoContent :: NoContent -- | Union of two APIs, first takes precedence in case of overlap. -- -- Example: -- --
--   >>> :{
--   type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
--          :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books
--   :}
--   
data a :<|> b (:<|>) :: a -> b -> (:<|>) a b infixr 3 :<|> infixr 3 :<|> type HttpDescription = Description type HttpJson = JSON type HttpSummary = Summary module Prolude.Swagger data SwaggerType (t :: SwaggerKind Type) [SwaggerString] :: forall (t :: SwaggerKind Type). SwaggerType t [SwaggerNumber] :: forall (t :: SwaggerKind Type). SwaggerType t [SwaggerInteger] :: forall (t :: SwaggerKind Type). SwaggerType t [SwaggerBoolean] :: forall (t :: SwaggerKind Type). SwaggerType t [SwaggerArray] :: forall (t :: SwaggerKind Type). SwaggerType t [SwaggerFile] :: SwaggerType ('SwaggerKindParamOtherSchema :: SwaggerKind Type) [SwaggerNull] :: SwaggerType ('SwaggerKindSchema :: SwaggerKind Type) [SwaggerObject] :: SwaggerType ('SwaggerKindSchema :: SwaggerKind Type) type SwaggerToSchema = ToSchema type SwaggerToParamSchema = ToParamSchema -- | This function makes it easy to define a ToSchema instance. Just -- pass in a function that modifies the default empty schema and you're -- good to go. For example: -- --
--   instance ToSchema SomeType where
--     declareNamedSchema = defaultDeclareNamedSchema
--       $ set type_ (Just SwaggerObject)
--       . set title (Just "some type")
--   
defaultDeclareNamedSchema :: (Typeable a, Applicative f) => (Schema -> Schema) -> proxy a -> f NamedSchema -- | Generates a unique name for the given type and adds that name to the -- schema. The generated name will be like ModuleName.TypeName. -- For example it might be Data.Maybe.Maybe. nameSchema :: Typeable a => proxy a -> Schema -> NamedSchema module Prolude.Test -- | Random generation and shrinking of values. -- -- QuickCheck provides Arbitrary instances for most types in -- base, except those which incur extra dependencies. For a -- wider range of Arbitrary instances see the -- quickcheck-instances package. class Arbitrary a -- | A generator for values of the given type. -- -- It is worth spending time thinking about what sort of test data you -- want - good generators are often the difference between finding bugs -- and not finding them. You can use sample, label and -- classify to check the quality of your test data. -- -- There is no generic arbitrary implementation included because -- we don't know how to make a high-quality one. If you want one, -- consider using the testing-feat or generic-random -- packages. -- -- The QuickCheck manual goes into detail on how to write good -- generators. Make sure to look at it, especially if your type is -- recursive! arbitrary :: Arbitrary a => Gen a -- | Generates a random subsequence of the given list. sublistOf :: [a] -> Gen [a] -- | Run a generator. The size passed to the generator is always 30; if you -- want another size then you should explicitly use resize. generate :: Gen a -> IO a -- | Overrides the size parameter. Returns a generator which uses the given -- size instead of the runtime-size parameter. resize :: Int -> Gen a -> Gen a newtype ArbitraryUniform a ArbitraryUniform :: a -> ArbitraryUniform a [unArbitraryUniform] :: ArbitraryUniform a -> a arbitraryIO :: (Arbitrary a, MonadIO m) => m a instance GHC.Generics.Generic a => GHC.Generics.Generic (Prolude.Test.ArbitraryUniform a) instance (Generic.Random.Internal.Generic.GArbitrary Generic.Random.Internal.Generic.UnsizedOpts a, Generic.Random.Internal.Generic.GUniformWeight a) => Test.QuickCheck.Arbitrary.Arbitrary (Prolude.Test.ArbitraryUniform a) module Prolude.Text type LazyText = Text -- | A space efficient, packed, unboxed Unicode text type. data Text lazyTextToString :: LazyText -> String lazyTextToText :: LazyText -> Text stringToLazyText :: String -> LazyText stringToText :: String -> Text textToLazyText :: Text -> LazyText textToString :: Text -> String module Prolude.Time -- | Convert from proleptic Gregorian calendar. First argument is year, -- second month number (1-12), third day (1-31). Invalid values will be -- clipped to the correct range, month first, then day. fromGregorian :: Integer -> Int -> Int -> Day -- | Convert to proleptic Gregorian calendar. First element of result is -- year, second month number (1-12), third day (1-31). toGregorian :: Day -> (Integer, Int, Int) -- | The Modified Julian Day is a standard count of days, with zero being -- the day 1858-11-17. data Day -- | This is the simplest representation of UTC. It consists of the day -- number, and a time offset from midnight. Note that if a day has a leap -- second added to it, it will have 86401 seconds. data UTCTime UTCTime :: Day -> DiffTime -> UTCTime -- | the day [utctDay] :: UTCTime -> Day -- | the time from midnight, 0 <= t < 86401s (because of -- leap-seconds) [utctDayTime] :: UTCTime -> DiffTime -- | addUTCTime a b = a + b addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime -- | This is a length of time, as measured by UTC. It has a precision of -- 10^-12 s. -- -- Conversion functions will treat it as seconds. For example, (0.010 -- :: NominalDiffTime) corresponds to 10 milliseconds. -- -- It ignores leap-seconds, so it's not necessarily a fixed amount of -- clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime = -- 01:00 UTC (+ 1 day), regardless of whether a leap-second intervened. data NominalDiffTime -- | This is a length of time, as measured by a clock. Conversion functions -- will treat it as seconds. It has a precision of 10^-12 s. data DiffTime -- | Get the current POSIX time from the system clock. getPOSIXTime :: IO POSIXTime utcTimeToPOSIXSeconds :: UTCTime -> POSIXTime posixSecondsToUTCTime :: POSIXTime -> UTCTime -- | POSIX time is the nominal time since 1970-01-01 00:00 UTC -- -- To convert from a CTime or System.Posix.EpochTime, use -- realToFrac. type POSIXTime = NominalDiffTime -- | Locale representing American usage. -- -- knownTimeZones contains only the ten time-zones mentioned in -- RFC 822 sec. 5: "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", -- "PST", "PDT". Note that the parsing functions will regardless parse -- "UTC", single-letter military time-zones, and +HHMM format. defaultTimeLocale :: TimeLocale -- | Substitute various time-related information for each %-code in the -- string, as per formatCharacter. -- -- The general form is -- %<modifier><width><alternate><specifier>, -- where <modifier>, <width>, and -- <alternate> are optional. -- --

<modifier>

-- -- glibc-style modifiers can be used before the specifier (here marked as -- z): -- -- -- --

<width>

-- -- Width digits can also be used after any modifiers and before the -- specifier (here marked as z), for example: -- -- -- --

<alternate>

-- -- An optional E character indicates an alternate formatting. -- Currently this only affects %Z and %z. -- -- -- --

<specifier>

-- -- For all types (note these three are done by formatTime, not by -- formatCharacter): -- -- -- --

TimeZone

-- -- For TimeZone (and ZonedTime and UTCTime): -- -- -- --

LocalTime

-- -- For LocalTime (and ZonedTime and UTCTime -- and UniversalTime): -- -- -- --

TimeOfDay

-- -- For TimeOfDay (and LocalTime and ZonedTime -- and UTCTime and UniversalTime): -- -- -- --

UTCTime and ZonedTime

-- -- For UTCTime and ZonedTime: -- -- -- --

DayOfWeek

-- -- For DayOfWeek (and Day and LocalTime and -- ZonedTime and UTCTime and UniversalTime): -- -- -- --

Day

-- -- For Day (and LocalTime and ZonedTime and -- UTCTime and UniversalTime): -- -- -- --

Duration types

-- -- The specifiers for DiffTime, NominalDiffTime, -- CalendarDiffDays, and CalendarDiffTime are -- semantically separate from the other types. Specifiers on negative -- time differences will generally be negative (think rem rather -- than mod). -- --

NominalDiffTime and DiffTime

-- -- Note that a "minute" of DiffTime is simply 60 SI seconds, -- rather than a minute of civil time. Use NominalDiffTime to -- work with civil time, ignoring any leap seconds. -- -- For NominalDiffTime and DiffTime: -- -- -- --

CalendarDiffDays

-- -- For CalendarDiffDays (and CalendarDiffTime): -- -- -- --

CalendarDiffTime

-- -- For CalendarDiffTime: -- -- formatTime :: FormatTime t => TimeLocale -> String -> t -> String -- | Returns now getCurrentTime :: MonadIO m => m UTCTime module Prolude.Uri type Uri = URI stringToUri :: String -> Either String URI textToUri :: Text -> Either String URI uriToString :: URI -> String uriToText :: URI -> Text module Prolude.Uuid type Uuid = UUID -- | Returns a randomUuid randomUuid :: MonadIO m => m Uuid -- | Converts a Text to a Maybe Uuid textToUuid :: Text -> Maybe Uuid -- | Converts a Uuid to Text uuidToText :: Uuid -> Text -- | Creates a Uuid from Words wordsToUuid :: Word32 -> Word32 -> Word32 -> Word32 -> Uuid module Prolude