-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Core data types and functionality for Amazonka libraries. -- -- Core data types and serialisation primitives for Amazonka related -- Amazon Web Service SDKs. -- -- The external interface of this library is stable with respect to the -- downstream Amazonka libraries only, and is not suitable for use in -- non-Amazonka projects. @package amazonka-core @version 2.0 -- | Re-export a number of lens types and combinators for use in service -- bindings. module Amazonka.Core.Lens.Internal -- | Flipped version of <$>. -- --
-- (<&>) = flip fmap ---- --
-- >>> Just 2 <&> (+1) -- Just 3 ---- --
-- >>> [1,2,3] <&> (+1) -- [2,3,4] ---- --
-- >>> Right 3 <&> (+1) -- Right 4 --(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> -- | A variant of throwing that can only be used within the -- IO Monad (or any other MonadCatch instance) to -- throw an Exception described by a ReifiedPrism. -- -- Although throwingM has a type that is a specialization of the -- type of throwing, the two functions are subtly different: -- --
-- throwing l e `seq` x ≡ throwing e -- throwingM l e `seq` x ≡ x ---- -- The first example will cause the Exception e to be -- raised, whereas the second one won't. In fact, throwingM will -- only cause an Exception to be raised when it is used within the -- MonadCatch instance. The throwingM variant should be -- used in preference to throwing to raise an Exception -- within the Monad because it guarantees ordering with respect to -- other monadic operations, whereas throwing does not. -- --
-- throwingM l ≡ reviews l throw ---- --
-- throwingM :: MonadThrow m => Prism' SomeException t -> t -> m r -- throwingM :: MonadThrow m => Iso' SomeException t -> t -> m r --throwingM :: MonadThrow m => AReview SomeException b -> b -> m r -- | A variant of try that takes a ReifiedPrism (or any -- ReifiedFold) to select which exceptions are caught (c.f. -- tryJust, catchJust). If the Exception does not -- match the predicate, it is re-thrown. -- --
-- trying :: MonadCatch m => Prism' SomeException a -> m r -> m (Either a r) -- trying :: MonadCatch m => Lens' SomeException a -> m r -> m (Either a r) -- trying :: MonadCatch m => Traversal' SomeException a -> m r -> m (Either a r) -- trying :: MonadCatch m => Iso' SomeException a -> m r -> m (Either a r) -- trying :: MonadCatch m => ReifiedGetter SomeException a -> m r -> m (Either a r) -- trying :: MonadCatch m => ReifiedFold SomeException a -> m r -> m (Either a r) --trying :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Either a r) -- | Catch exceptions that match a given ReifiedPrism (or any -- ReifiedGetter), discarding the information about the match. -- This is particularly useful when you have a Prism' e -- () where the result of the ReifiedPrism or -- ReifiedFold isn't particularly valuable, just the fact that it -- matches. -- --
-- >>> catching_ _AssertionFailed (assert False (return "uncaught")) $ return "caught" -- "caught" ---- --
-- catching_ :: MonadCatch m => Prism' SomeException a -> m r -> m r -> m r -- catching_ :: MonadCatch m => Lens' SomeException a -> m r -> m r -> m r -- catching_ :: MonadCatch m => Traversal' SomeException a -> m r -> m r -> m r -- catching_ :: MonadCatch m => Iso' SomeException a -> m r -> m r -> m r -- catching_ :: MonadCatch m => ReifiedGetter SomeException a -> m r -> m r -> m r -- catching_ :: MonadCatch m => ReifiedFold SomeException a -> m r -> m r -> m r --catching_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m r -> m r -- | Catch exceptions that match a given ReifiedPrism (or any -- ReifiedFold, really). -- --
-- >>> catching _AssertionFailed (assert False (return "uncaught")) $ \ _ -> return "caught" -- "caught" ---- --
-- catching :: MonadCatch m => Prism' SomeException a -> m r -> (a -> m r) -> m r -- catching :: MonadCatch m => Lens' SomeException a -> m r -> (a -> m r) -> m r -- catching :: MonadCatch m => Traversal' SomeException a -> m r -> (a -> m r) -> m r -- catching :: MonadCatch m => Iso' SomeException a -> m r -> (a -> m r) -> m r -- catching :: MonadCatch m => ReifiedGetter SomeException a -> m r -> (a -> m r) -> m r -- catching :: MonadCatch m => ReifiedFold SomeException a -> m r -> (a -> m r) -> m r --catching :: MonadCatch m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r -- | Traverse the strongly typed Exception contained in -- SomeException where the type of your function matches the -- desired Exception. -- --
-- exception :: (Applicative f, Exception a) -- => (a -> f a) -> SomeException -> f SomeException --exception :: Exception a => Prism' SomeException a -- | Unfortunately the name ioException is taken by base -- for throwing IOExceptions. -- --
-- _IOException :: Prism' IOException IOException -- _IOException :: Prism' SomeException IOException ---- -- Many combinators for working with an IOException are available -- in System.IO.Error.Lens. _IOException :: AsIOException t => Prism' t IOException -- | A Traversal reading and writing to the last element of a -- non-empty container. -- --
-- >>> [a,b,c]^?!_last -- c ---- --
-- >>> []^?_last -- Nothing ---- --
-- >>> [a,b,c] & _last %~ f -- [a,b,f c] ---- --
-- >>> [1,2]^?_last -- Just 2 ---- --
-- >>> [] & _last .~ 1 -- [] ---- --
-- >>> [0] & _last .~ 2 -- [2] ---- --
-- >>> [0,1] & _last .~ 2 -- [0,2] ---- -- This Traversal is not limited to lists, however. We can also -- work with other containers, such as a Vector. -- --
-- >>> Vector.fromList "abcde" ^? _last -- Just 'e' ---- --
-- >>> Vector.empty ^? _last -- Nothing ---- --
-- >>> (Vector.fromList "abcde" & _last .~ 'Q') == Vector.fromList "abcdQ" -- True ---- --
-- _last :: Traversal' [a] a -- _last :: Traversal' (Seq a) a -- _last :: Traversal' (Vector a) a --_last :: Snoc s s a a => Traversal' s a -- | Data types that are representationally equal are isomorphic. -- -- This is only available on GHC 7.8+ coerced :: forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b -- | If v is an element of a type a, and a' is -- a sans the element v, then non v is -- an isomorphism from Maybe a' to a. -- --
-- non ≡ non' . only ---- -- Keep in mind this is only a real isomorphism if you treat the domain -- as being Maybe (a sans v). -- -- This is practically quite useful when you want to have a Map -- where all the entries should have non-zero values. -- --
-- >>> Map.fromList [("hello",1)] & at "hello" . non 0 +~ 2
-- fromList [("hello",3)]
--
--
--
-- >>> Map.fromList [("hello",1)] & at "hello" . non 0 -~ 1
-- fromList []
--
--
--
-- >>> Map.fromList [("hello",1)] ^. at "hello" . non 0
-- 1
--
--
-- -- >>> Map.fromList [] ^. at "hello" . non 0 -- 0 ---- -- This combinator is also particularly useful when working with nested -- maps. -- -- e.g. When you want to create the nested Map when it is -- missing: -- --
-- >>> Map.empty & at "hello" . non Map.empty . at "world" ?~ "!!!"
-- fromList [("hello",fromList [("world","!!!")])]
--
--
-- and when have deleting the last entry from the nested Map mean
-- that we should delete its entry from the surrounding one:
--
--
-- >>> Map.fromList [("hello",Map.fromList [("world","!!!")])] & at "hello" . non Map.empty . at "world" .~ Nothing
-- fromList []
--
--
-- It can also be used in reverse to exclude a given value:
--
-- -- >>> non 0 # rem 10 4 -- Just 2 ---- --
-- >>> non 0 # rem 10 5 -- Nothing --non :: Eq a => a -> Iso' (Maybe a) a -- | This can be used to lift any Iso into an arbitrary -- Functor. mapping :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Functor f, Functor g) => AnIso s t a b -> Iso (f s) (g t) (f a) (g b) -- | Build a simple isomorphism from a pair of inverse functions. -- --
-- view (iso f g) ≡ f -- view (from (iso f g)) ≡ g -- over (iso f g) h ≡ g . h . f -- over (from (iso f g)) h ≡ f . h . g --iso :: (s -> a) -> (b -> t) -> Iso s t a b -- | Traverse any Traversable container. This is an -- IndexedTraversal that is indexed by ordinal position. traversed :: forall (f :: Type -> Type) a b. Traversable f => IndexedTraversal Int (f a) (f b) a b -- | Check to see if this Fold or Traversal matches 1 or more -- entries. -- --
-- >>> has (element 0) [] -- False ---- --
-- >>> has _Left (Left 12) -- True ---- --
-- >>> has _Right (Left 12) -- False ---- -- This will always return True for a Lens or -- Getter. -- --
-- >>> has _1 ("hello","world")
-- True
--
--
-- -- has :: Getter s a -> s -> Bool -- has :: Fold s a -> s -> Bool -- has :: Iso' s a -> s -> Bool -- has :: Lens' s a -> s -> Bool -- has :: Traversal' s a -> s -> Bool --has :: Getting Any s a -> s -> Bool -- | Perform a safe head of a Fold or Traversal or -- retrieve Just the result from a Getter or Lens. -- -- When using a Traversal as a partial Lens, or a -- Fold as a partial Getter this can be a convenient way to -- extract the optional value. -- -- Note: if you get stack overflows due to this, you may want to use -- firstOf instead, which can deal more gracefully with heavily -- left-biased trees. This is because ^? works by using the -- First monoid, which can occasionally cause space leaks. -- --
-- >>> Left 4 ^?_Left -- Just 4 ---- --
-- >>> Right 4 ^?_Left -- Nothing ---- --
-- >>> "world" ^? ix 3 -- Just 'l' ---- --
-- >>> "world" ^? ix 20 -- Nothing ---- -- This operator works as an infix version of preview. -- --
-- (^?) ≡ flip preview ---- -- It may be helpful to think of ^? as having one of the following -- more specialized types: -- --
-- (^?) :: s -> Getter s a -> Maybe a -- (^?) :: s -> Fold s a -> Maybe a -- (^?) :: s -> Lens' s a -> Maybe a -- (^?) :: s -> Iso' s a -> Maybe a -- (^?) :: s -> Traversal' s a -> Maybe a --(^?) :: s -> Getting (First a) s a -> Maybe a infixl 8 ^? -- | Concatenate all of the lists targeted by a Fold into a longer -- list. -- --
-- >>> concatOf both ("pan","ama")
-- "panama"
--
--
-- -- concat ≡ concatOf folded -- concatOf ≡ view ---- --
-- concatOf :: Getter s [r] -> s -> [r] -- concatOf :: Fold s [r] -> s -> [r] -- concatOf :: Iso' s [r] -> s -> [r] -- concatOf :: Lens' s [r] -> s -> [r] -- concatOf :: Traversal' s [r] -> s -> [r] --concatOf :: Getting [r] s [r] -> s -> [r] -- | Returns True if every target of a Fold satisfies a -- predicate. -- --
-- >>> allOf both (>=3) (4,5) -- True -- -- >>> allOf folded (>=2) [1..10] -- False ---- --
-- all ≡ allOf folded ---- --
-- iallOf l = allOf l . Indexed ---- --
-- allOf :: Getter s a -> (a -> Bool) -> s -> Bool -- allOf :: Fold s a -> (a -> Bool) -> s -> Bool -- allOf :: Lens' s a -> (a -> Bool) -> s -> Bool -- allOf :: Iso' s a -> (a -> Bool) -> s -> Bool -- allOf :: Traversal' s a -> (a -> Bool) -> s -> Bool -- allOf :: Prism' s a -> (a -> Bool) -> s -> Bool --allOf :: Getting All s a -> (a -> Bool) -> s -> Bool -- | Returns True if any target of a Fold satisfies a -- predicate. -- --
-- >>> anyOf both (=='x') ('x','y')
-- True
--
-- >>> import Data.Data.Lens
--
-- >>> anyOf biplate (== "world") (((),2::Int),"hello",("world",11::Int))
-- True
--
--
-- -- any ≡ anyOf folded ---- --
-- ianyOf l ≡ anyOf l . Indexed ---- --
-- anyOf :: Getter s a -> (a -> Bool) -> s -> Bool -- anyOf :: Fold s a -> (a -> Bool) -> s -> Bool -- anyOf :: Lens' s a -> (a -> Bool) -> s -> Bool -- anyOf :: Iso' s a -> (a -> Bool) -> s -> Bool -- anyOf :: Traversal' s a -> (a -> Bool) -> s -> Bool -- anyOf :: Prism' s a -> (a -> Bool) -> s -> Bool --anyOf :: Getting Any s a -> (a -> Bool) -> s -> Bool -- | A convenient infix (flipped) version of toListOf. -- --
-- >>> [[1,2],[3]]^..id -- [[[1,2],[3]]] -- -- >>> [[1,2],[3]]^..traverse -- [[1,2],[3]] -- -- >>> [[1,2],[3]]^..traverse.traverse -- [1,2,3] ---- --
-- >>> (1,2)^..both -- [1,2] ---- --
-- toList xs ≡ xs ^.. folded -- (^..) ≡ flip toListOf ---- --
-- (^..) :: s -> Getter s a -> a :: s -> Fold s a -> a :: s -> Lens' s a -> a :: s -> Iso' s a -> a :: s -> Traversal' s a -> a :: s -> Prism' s a -> [a] --(^..) :: s -> Getting (Endo [a]) s a -> [a] infixl 8 ^.. -- | Obtain a Fold that can be composed with to filter another -- Lens, Iso, Getter, Fold (or -- Traversal). -- -- Note: This is not a legal Traversal, unless you are very -- careful not to invalidate the predicate on the target. -- -- Note: This is also not a legal Prism, unless you are -- very careful not to inject a value that fails the predicate. -- -- As a counter example, consider that given evens = filtered -- even the second Traversal law is violated: -- --
-- over evens succ . over evens succ /= over evens (succ . succ) ---- -- So, in order for this to qualify as a legal Traversal you can -- only use it for actions that preserve the result of the predicate! -- --
-- >>> [1..10]^..folded.filtered even -- [2,4,6,8,10] ---- -- This will preserve an index if it is present. filtered :: (Choice p, Applicative f) => (a -> Bool) -> Optic' p f a a -- | Obtain a Fold by lifting an operation that returns a -- Foldable result. -- -- This can be useful to lift operations from Data.List and -- elsewhere into a Fold. -- --
-- >>> [1,2,3,4]^..folding tail -- [2,3,4] --folding :: Foldable f => (s -> f a) -> Fold s a -- | This Prism provides a Traversal for tweaking the target -- of the value of Just in a Maybe. -- --
-- >>> over _Just (+1) (Just 2) -- Just 3 ---- -- Unlike traverse this is a Prism, and so you can use it -- to inject as well: -- --
-- >>> _Just # 5 -- Just 5 ---- --
-- >>> 5^.re _Just -- Just 5 ---- -- Interestingly, -- --
-- m ^? _Just ≡ m ---- --
-- >>> Just x ^? _Just -- Just x ---- --
-- >>> Nothing ^? _Just -- Nothing --_Just :: Prism (Maybe a) (Maybe b) a b -- | Build a Prism. -- -- Either t a is used instead of Maybe a -- to permit the types of s and t to differ. prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b -- | An infix alias for review. -- --
-- unto f # x ≡ f x -- l # x ≡ x ^. re l ---- -- This is commonly used when using a Prism as a smart -- constructor. -- --
-- >>> _Left # 4 -- Left 4 ---- -- But it can be used for any Prism -- --
-- >>> base 16 # 123 -- "7b" ---- --
-- (#) :: Iso' s a -> a -> s -- (#) :: Prism' s a -> a -> s -- (#) :: Review s a -> a -> s -- (#) :: Equality' s a -> a -> s --(#) :: AReview t b -> b -> t infixr 8 # -- | Turn a Getter around to get a Review -- --
-- un = unto . view -- unto = un . to ---- --
-- >>> un (to length) # [1,2,3] -- 3 --un :: (Profunctor p, Bifunctor p, Functor f) => Getting a s a -> Optic' p f a s -- | View the value pointed to by a Getter or Lens or the -- result of folding over all the results of a Fold or -- Traversal that points at a monoidal values. -- -- This is the same operation as view with the arguments flipped. -- -- The fixity and semantics are such that subsequent field accesses can -- be performed with (.). -- --
-- >>> (a,b)^._2 -- b ---- --
-- >>> ("hello","world")^._2
-- "world"
--
--
-- -- >>> import Data.Complex -- -- >>> ((0, 1 :+ 2), 3)^._1._2.to magnitude -- 2.23606797749979 ---- --
-- (^.) :: s -> Getter s a -> a -- (^.) :: Monoid m => s -> Fold s m -> m -- (^.) :: s -> Iso' s a -> a -- (^.) :: s -> Lens' s a -> a -- (^.) :: Monoid m => s -> Traversal' s m -> m --(^.) :: s -> Getting a s a -> a infixl 8 ^. -- | 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 . to ≡ id ---- --
-- >>> 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 -- | Build an (index-preserving) Getter from an arbitrary Haskell -- function. -- --
-- to f . to g ≡ to (g . f) ---- --
-- a ^. to f ≡ f a ---- --
-- >>> a ^.to f -- f a ---- --
-- >>> ("hello","world")^.to snd
-- "world"
--
--
-- -- >>> 5^.to succ -- 6 ---- --
-- >>> (0, -5)^._2.to abs -- 5 ---- --
-- to :: (s -> a) -> IndexPreservingGetter s a --to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a -- | When you see this in a type signature it indicates that you can pass -- the function a Lens, Getter, Traversal, -- Fold, Prism, Iso, or one of the indexed variants, -- and it will just "do the right thing". -- -- Most Getter combinators are able to be used with both a -- Getter or a Fold in limited situations, to do so, they -- need to be monomorphic in what we are going to extract with -- Const. To be compatible with Lens, Traversal and -- Iso we also restricted choices of the irrelevant t and -- b parameters. -- -- If a function accepts a Getting r s a, then when -- r is a Monoid, then you can pass a Fold (or -- Traversal), otherwise you can only pass this a Getter or -- Lens. type Getting r s a = a -> Const r a -> s -> Const r s -- | Access the 1st field of a tuple (and possibly change its type). -- --
-- >>> (1,2)^._1 -- 1 ---- --
-- >>> _1 .~ "hello" $ (1,2)
-- ("hello",2)
--
--
--
-- >>> (1,2) & _1 .~ "hello"
-- ("hello",2)
--
--
--
-- >>> _1 putStrLn ("hello","world")
-- hello
-- ((),"world")
--
--
-- This can also be used on larger tuples as well:
--
-- -- >>> (1,2,3,4,5) & _1 +~ 41 -- (42,2,3,4,5) ---- --
-- _1 :: Lens (a,b) (a',b) a a' -- _1 :: Lens (a,b,c) (a',b,c) a a' -- _1 :: Lens (a,b,c,d) (a',b,c,d) a a' -- ... -- _1 :: Lens (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a' --_1 :: Field1 s t a b => Lens s t a b -- | Access the 2nd field of a tuple. -- --
-- >>> _2 .~ "hello" $ (1,(),3,4) -- (1,"hello",3,4) ---- --
-- >>> (1,2,3,4) & _2 *~ 3 -- (1,6,3,4) ---- --
-- >>> _2 print (1,2) -- 2 -- (1,()) ---- --
-- anyOf _2 :: (s -> Bool) -> (a, s) -> Bool -- traverse . _2 :: (Applicative f, Traversable t) => (a -> f b) -> t (s, a) -> f (t (s, b)) -- foldMapOf (traverse . _2) :: (Traversable t, Monoid m) => (s -> m) -> t (b, s) -> m --_2 :: Field2 s t a b => Lens s t a b -- | Build a Lens from a getter and a setter. -- --
-- lens :: Functor f => (s -> a) -> (s -> b -> t) -> (a -> f b) -> s -> f t ---- --
-- >>> s ^. lens getter setter -- getter s ---- --
-- >>> s & lens getter setter .~ b -- setter s b ---- --
-- >>> s & lens getter setter %~ f -- setter s (f (getter s)) ---- --
-- lens :: (s -> a) -> (s -> a -> s) -> Lens' s a --lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b -- | Modify the target of a Semigroup value by using -- (<>). -- --
-- >>> (Sum a,b) & _1 <>~ Sum c
-- (Sum {getSum = a + c},b)
--
--
--
-- >>> (Sum a,Sum b) & both <>~ Sum c
-- (Sum {getSum = a + c},Sum {getSum = b + c})
--
--
--
-- >>> both <>~ "!!!" $ ("hello","world")
-- ("hello!!!","world!!!")
--
--
-- -- (<>~) :: Semigroup a => Setter s t a a -> a -> s -> t -- (<>~) :: Semigroup a => Iso s t a a -> a -> s -> t -- (<>~) :: Semigroup a => Lens s t a a -> a -> s -> t -- (<>~) :: Semigroup a => Traversal s t a a -> a -> s -> t --(<>~) :: Semigroup a => ASetter s t a a -> a -> s -> t infixr 4 <>~ -- | Set the target of a Lens, Traversal or Setter to -- Just a value. -- --
-- l ?~ t ≡ set l (Just t) ---- --
-- >>> Nothing & id ?~ a -- Just a ---- --
-- >>> Map.empty & at 3 ?~ x -- fromList [(3,x)] ---- -- ?~ can be used type-changily: -- --
-- >>> ('a', ('b', 'c')) & _2.both ?~ 'x'
-- ('a',(Just 'x',Just 'x'))
--
--
-- -- (?~) :: Setter s t a (Maybe b) -> b -> s -> t -- (?~) :: Iso s t a (Maybe b) -> b -> s -> t -- (?~) :: Lens s t a (Maybe b) -> b -> s -> t -- (?~) :: Traversal s t a (Maybe b) -> b -> s -> t --(?~) :: ASetter s t a (Maybe b) -> b -> s -> t infixr 4 ?~ -- | 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 .~ -- | Modifies the target of a Lens or all of the targets of a -- Setter or Traversal with a user supplied function. -- -- This is an infix version of over. -- --
-- fmap f ≡ mapped %~ f -- fmapDefault f ≡ traverse %~ f ---- --
-- >>> (a,b,c) & _3 %~ f -- (a,b,f c) ---- --
-- >>> (a,b) & both %~ f -- (f a,f b) ---- --
-- >>> _2 %~ length $ (1,"hello") -- (1,5) ---- --
-- >>> traverse %~ f $ [a,b,c] -- [f a,f b,f c] ---- --
-- >>> traverse %~ even $ [1,2,3] -- [False,True,False] ---- --
-- >>> traverse.traverse %~ length $ [["hello","world"],["!!!"]] -- [[5,5],[3]] ---- --
-- (%~) :: Setter s t a b -> (a -> b) -> s -> t -- (%~) :: Iso s t a b -> (a -> b) -> s -> t -- (%~) :: Lens s t a b -> (a -> b) -> s -> t -- (%~) :: Traversal s t a b -> (a -> b) -> s -> t --(%~) :: ASetter s t a b -> (a -> b) -> s -> t infixr 4 %~ -- | Build a Setter, IndexedSetter or -- IndexPreservingSetter depending on your choice of -- Profunctor. -- --
-- sets :: ((a -> b) -> s -> t) -> Setter s t a b --sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Optical p q f s t a b -- | A Lens is actually a lens family as described in -- http://comonad.com/reader/2012/mirrored-lenses/. -- -- With great power comes great responsibility and a Lens is -- subject to the three common sense Lens laws: -- -- 1) You get back what you put in: -- --
-- view l (set l v s) ≡ v ---- -- 2) Putting back what you got doesn't change anything: -- --
-- set l (view l s) s ≡ s ---- -- 3) Setting twice is the same as setting once: -- --
-- set l v' (set l v s) ≡ set l v' s ---- -- These laws are strong enough that the 4 type parameters of a -- Lens cannot vary fully independently. For more on how they -- interact, read the "Why is it a Lens Family?" section of -- http://comonad.com/reader/2012/mirrored-lenses/. -- -- There are some emergent properties of these laws: -- -- 1) set l s must be injective for every s This -- is a consequence of law #1 -- -- 2) set l must be surjective, because of law #2, which -- indicates that it is possible to obtain any v from some -- s such that set s v = s -- -- 3) Given just the first two laws you can prove a weaker form of law #3 -- where the values v that you are setting match: -- --
-- set l v (set l v s) ≡ set l v s ---- -- Every Lens can be used directly as a Setter or -- Traversal. -- -- You can also use a Lens for Getting as if it were a -- Fold or Getter. -- -- Since every Lens is a valid Traversal, the -- Traversal laws are required of any Lens you create: -- --
-- l pure ≡ pure -- fmap (l f) . l g ≡ getCompose . l (Compose . fmap f . g) ---- --
-- type Lens s t a b = forall f. Functor f => LensLike f s t a b --type Lens s t a b = forall (f :: Type -> Type). Functor f => a -> f b -> s -> f t -- |
-- type Lens' = Simple Lens --type Lens' s a = Lens s s a a -- |
-- type Traversal' = Simple Traversal --type Traversal' s a = Traversal s s a a -- |
-- type IndexedTraversal' i = Simple (IndexedTraversal i) --type IndexedTraversal' i s a = IndexedTraversal i s s a a -- | A Setter' is just a Setter that doesn't change the -- types. -- -- These are particularly common when talking about monomorphic -- containers. e.g. -- --
-- sets Data.Text.map :: Setter' Text Char ---- --
-- type Setter' = Simple Setter --type Setter' s a = Setter s s a a -- |
-- type Iso' = Simple Iso --type Iso' s a = Iso s s a a -- | If you see this in a signature for a function, the function is -- expecting a Review (in practice, this usually means a -- Prism). type AReview t b = Optic' Tagged :: Type -> Type -> Type Identity t b -- | A Simple Prism. type Prism' s a = Prism s s a a -- | A Getter describes how to retrieve a single value in a way that -- can be composed with other LensLike constructions. -- -- Unlike a Lens a Getter is read-only. Since a -- Getter cannot be used to write back there are no Lens -- laws that can be applied to it. In fact, it is isomorphic to an -- arbitrary function from (s -> a). -- -- Moreover, a Getter can be used directly as a Fold, since -- it just ignores the Applicative. type Getter s a = forall (f :: Type -> Type). (Contravariant f, Functor f) => a -> f a -> s -> f s -- | A Fold describes how to retrieve multiple values in a way that -- can be composed with other LensLike constructions. -- -- A Fold s a provides a structure with operations very -- similar to those of the Foldable typeclass, see -- foldMapOf and the other Fold combinators. -- -- By convention, if there exists a foo method that expects a -- Foldable (f a), then there should be a fooOf -- method that takes a Fold s a and a value of type -- s. -- -- A Getter is a legal Fold that just ignores the supplied -- Monoid. -- -- Unlike a Traversal a Fold is read-only. Since a -- Fold cannot be used to write back there are no Lens laws -- that apply. type Fold s a = forall (f :: Type -> Type). (Contravariant f, Applicative f) => a -> f a -> s -> f s -- |
-- type Optic' p f s a = Simple (Optic p f) s a --type Optic' (p :: k -> k1 -> Type) (f :: k -> k1) (s :: k) (a :: k) = Optic p f s s a a -- | The generalization of Costar of Functor that is strong -- with respect to Either. -- -- Note: This is also a notion of strength, except with regards to -- another monoidal structure that we can choose to equip Hask with: the -- cocartesian coproduct. class Profunctor p => Choice (p :: Type -> Type -> Type) -- | An intentionally limited set of prelude exports to control backward -- compatibility and simplify code generation. -- -- Please consider long and hard before adding any addtional types -- exports to this module - they should either be in pervasive use -- throughout the project or have zero ambiguity. If you ever are forced -- to disambiguate at any point, it's a bad export. -- -- Try and avoid any value, operator, or symbol exports, if possible. -- Most of the ones here exist to ease legacy code-migration. module Amazonka.Prelude -- | Append two lists, i.e., -- --
-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] -- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] ---- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] infixr 5 ++ -- | The value of seq a b is bottom if a is bottom, and -- otherwise equal to b. In other words, it evaluates the first -- argument a to weak head normal form (WHNF). seq is -- usually introduced to improve performance by avoiding unneeded -- laziness. -- -- A note on evaluation order: the expression seq a b does -- not guarantee that a will be evaluated before -- b. The only guarantee given by seq is that the both -- a and b will be evaluated before seq -- returns a value. In particular, this means that b may be -- evaluated before a. If you need to guarantee a specific order -- of evaluation, you must use the function pseq from the -- "parallel" package. seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 `seq` -- | <math>. filter, applied to a predicate and a list, -- returns the list of those elements that satisfy the predicate; i.e., -- --
-- filter p xs = [ x | x <- xs, p x] ---- --
-- >>> filter odd [1, 2, 3] -- [1,3] --filter :: (a -> Bool) -> [a] -> [a] -- | <math>. zip takes two lists and returns a list of -- corresponding pairs. -- --
-- >>> zip [1, 2] ['a', 'b'] -- [(1,'a'),(2,'b')] ---- -- If one input list is shorter than the other, excess elements of the -- longer list are discarded, even if one of the lists is infinite: -- --
-- >>> zip [1] ['a', 'b'] -- [(1,'a')] -- -- >>> zip [1, 2] ['a'] -- [(1,'a')] -- -- >>> zip [] [1..] -- [] -- -- >>> zip [1..] [] -- [] ---- -- zip is right-lazy: -- --
-- >>> zip [] undefined -- [] -- -- >>> zip undefined [] -- *** Exception: Prelude.undefined -- ... ---- -- zip is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zip :: [a] -> [b] -> [(a, b)] -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- --
-- main = print ([(n, 2^n) | n <- [0..19]]) --print :: Show a => a -> IO () -- | Extract the first component of a pair. fst :: (a, b) -> a -- | Extract the second component of a pair. snd :: (a, b) -> b -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
-- f x | x < 0 = ... -- | otherwise = ... --otherwise :: Bool -- | <math>. map f xs is the list obtained by -- applying f to each element of xs, i.e., -- --
-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] -- map f [x1, x2, ...] == [f x1, f x2, ...] ---- --
-- >>> map (+1) [1, 2, 3] -- [2,3,4] --map :: (a -> b) -> [a] -> [b] -- | 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 $ -- | The function coerce allows you to safely convert between -- values of types that have the same representation with no run-time -- overhead. In the simplest case you can use it instead of a newtype -- constructor, to go from the newtype's concrete type to the abstract -- type. But it also works in more complicated settings, e.g. converting -- a list of newtypes to a list of concrete types. -- -- This function is runtime-representation polymorphic, but the -- RuntimeRep type argument is marked as Inferred, -- meaning that it is not available for visible type application. This -- means the typechecker will accept coerce @Int @Age 42. coerce :: forall {k :: RuntimeRep} (a :: TYPE k) (b :: TYPE k). Coercible a b => a -> b -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | Conditional failure of Alternative computations. Defined by -- --
-- guard True = pure () -- guard False = empty ---- --
-- >>> 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 IsList class and its methods are intended to be used in -- conjunction with the OverloadedLists extension. class IsList l where { -- | The Item type function returns the type of items of the -- structure l. type family Item l; } -- | The fromList function constructs the structure l from -- the given list of Item l fromList :: IsList l => [Item l] -> l -- | The fromListN function takes the input list's length and -- potentially uses it to construct the structure l more -- efficiently compared to fromList. If the given number does not -- equal to the input list's length the behaviour of fromListN is -- not specified. -- --
-- fromListN (length xs) xs == fromList xs --fromListN :: IsList l => Int -> [Item l] -> l -- | The toList function extracts a list of Item l from the -- structure l. It should satisfy fromList . toList = id. toList :: IsList l => l -> [Item l] -- | 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 ---- --
-- 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 -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- --
-- enumFrom x = enumFromTo x maxBound -- enumFromThen x y = enumFromThenTo x y bound -- where -- bound | fromEnum y >= fromEnum x = maxBound -- | otherwise = minBound --class Enum a -- | the successor of a value. For numeric types, succ adds 1. succ :: Enum a => a -> a -- | the predecessor of a value. For numeric types, pred subtracts -- 1. pred :: Enum a => a -> a -- | Convert from an Int. toEnum :: Enum a => Int -> a -- | Convert to an Int. It is implementation-dependent what -- fromEnum returns when applied to a value that is too large to -- fit in an Int. fromEnum :: Enum a => a -> Int -- | Used in Haskell's translation of [n..] with [n..] = -- enumFrom n, a possible implementation being enumFrom n = n : -- enumFrom (succ n). For example: -- --
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: -- Int]
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: -- Int]
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo 4 2 -6 :: [Integer] = -- [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
-- (x `quot` y)*y + (x `rem` y) == x --rem :: Integral a => a -> a -> a -- | integer division truncated toward negative infinity div :: Integral a => a -> a -> a -- | integer modulus, satisfying -- --
-- (x `div` y)*y + (x `mod` y) == x --mod :: Integral a => a -> a -> a -- | simultaneous quot and rem quotRem :: Integral a => a -> a -> (a, a) -- | simultaneous div and mod divMod :: Integral a => a -> a -> (a, a) -- | conversion to Integer toInteger :: Integral a => a -> Integer infixl 7 `rem` infixl 7 `quot` infixl 7 `mod` infixl 7 `div` -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following: -- --
-- do a <- as -- bs a --(>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. -- -- 'as >> bs' can be understood as the do -- expression -- --
-- do as -- bs --(>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a infixl 1 >>= infixl 1 >> -- | A type f is a Functor if it provides a function fmap -- which, given any types a and b lets you apply any -- function from (a -> b) to turn an f a into an -- f b, preserving the structure of f. Furthermore -- f needs to adhere to the following: -- -- -- -- Note, that the second law follows from the free theorem of the type -- fmap and the first law, so you need only check that the former -- condition holds. class Functor (f :: Type -> Type) -- | fmap is used to apply a function of type (a -> b) -- to a value of type f a, where f is a functor, to produce a -- value of type f b. Note that for any type constructor with -- more than one parameter (e.g., Either), only the last type -- parameter can be modified with fmap (e.g., b in -- `Either a b`). -- -- Some type constructors with two parameters or more have a -- Bifunctor instance that allows both the last and the -- penultimate parameters to be mapped over. -- --
-- >>> fmap show Nothing -- Nothing -- -- >>> fmap show (Just 3) -- Just "3" ---- -- Convert from an Either Int Int to an Either Int -- String using show: -- --
-- >>> fmap show (Left 17) -- Left 17 -- -- >>> fmap show (Right 17) -- Right "17" ---- -- Double each element of a list: -- --
-- >>> fmap (*2) [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> fmap even (2,2) -- (2,True) ---- -- It may seem surprising that the function is only applied to the last -- element of the tuple compared to the list example above which applies -- it to every element in the list. To understand, remember that tuples -- are type constructors with multiple type parameters: a tuple of 3 -- elements (a,b,c) can also be written (,,) a b c and -- its Functor instance is defined for Functor ((,,) a -- b) (i.e., only the third parameter is free to be mapped over with -- fmap). -- -- It explains why fmap can be used with tuples containing -- values of different types as in the following example: -- --
-- >>> fmap even ("hello", 1.0, 4)
-- ("hello",1.0,True)
--
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.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$
-- | Basic numeric class.
--
-- The Haskell Report defines no laws for Num. However,
-- (+) and (*) are customarily expected
-- to define a ring and have the following properties:
--
-- -- abs x * signum x == x ---- -- For real numbers, the signum is either -1 (negative), -- 0 (zero) or 1 (positive). signum :: Num a => a -> a -- | Conversion from an Integer. An integer literal represents the -- application of the function fromInteger to the appropriate -- value of type Integer, so such literals have type -- (Num a) => a. fromInteger :: Num a => Integer -> a infixl 7 * infixl 6 + infixl 6 - -- | 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. -- -- Ord, as defined by the Haskell report, implements a total order -- and has the following properties: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Read in Haskell 2010 is equivalent to -- --
-- instance (Read a) => Read (Tree a) where
--
-- readsPrec d r = readParen (d > app_prec)
-- (\r -> [(Leaf m,t) |
-- ("Leaf",s) <- lex r,
-- (m,t) <- readsPrec (app_prec+1) s]) r
--
-- ++ readParen (d > up_prec)
-- (\r -> [(u:^:v,w) |
-- (u,s) <- readsPrec (up_prec+1) r,
-- (":^:",t) <- lex s,
-- (v,w) <- readsPrec (up_prec+1) t]) r
--
-- where app_prec = 10
-- up_prec = 5
--
--
-- Note that right-associativity of :^: is unused.
--
-- The derived instance in GHC is equivalent to
--
-- -- instance (Read a) => Read (Tree a) where -- -- readPrec = parens $ (prec app_prec $ do -- Ident "Leaf" <- lexP -- m <- step readPrec -- return (Leaf m)) -- -- +++ (prec up_prec $ do -- u <- step readPrec -- Symbol ":^:" <- lexP -- v <- step readPrec -- return (u :^: v)) -- -- where app_prec = 10 -- up_prec = 5 -- -- readListPrec = readListPrecDefault ---- -- Why do both readsPrec and readPrec exist, and why does -- GHC opt to implement readPrec in derived Read instances -- instead of readsPrec? The reason is that readsPrec is -- based on the ReadS type, and although ReadS is mentioned -- in the Haskell 2010 Report, it is not a very efficient parser data -- structure. -- -- readPrec, on the other hand, is based on a much more efficient -- ReadPrec datatype (a.k.a "new-style parsers"), but its -- definition relies on the use of the RankNTypes language -- extension. Therefore, readPrec (and its cousin, -- readListPrec) are marked as GHC-only. Nevertheless, it is -- recommended to use readPrec instead of readsPrec -- whenever possible for the efficiency improvements it brings. -- -- As mentioned above, derived Read instances in GHC will -- implement readPrec instead of readsPrec. The default -- implementations of readsPrec (and its cousin, readList) -- will simply use readPrec under the hood. If you are writing a -- Read instance by hand, it is recommended to write it like so: -- --
-- instance Read T where -- readPrec = ... -- readListPrec = readListPrecDefault --class Read a -- | attempts to parse a value from the front of the string, returning a -- list of (parsed value, remaining string) pairs. If there is no -- successful parse, the returned list is empty. -- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. readsPrec :: Read a => Int -> ReadS a -- | The method readList is provided to allow the programmer to give -- a specialised way of parsing lists of values. For example, this is -- used by the predefined Read instance of the Char type, -- where values of type String should be are expected to use -- double quotes, rather than square brackets. readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a -- | a constant function, returning the radix of the representation (often -- 2) floatRadix :: RealFloat a => a -> Integer -- | a constant function, returning the number of digits of -- floatRadix in the significand floatDigits :: RealFloat a => a -> Int -- | a constant function, returning the lowest and highest values the -- exponent may assume floatRange :: RealFloat a => a -> (Int, Int) -- | The function decodeFloat applied to a real floating-point -- number returns the significand expressed as an Integer and an -- appropriately scaled exponent (an Int). If -- decodeFloat x yields (m,n), then x -- is equal in value to m*b^^n, where b is the -- floating-point radix, and furthermore, either m and -- n are both zero or else b^(d-1) <= abs m < -- b^d, where d is the value of floatDigits -- x. In particular, decodeFloat 0 = (0,0). If the -- type contains a negative zero, also decodeFloat (-0.0) = -- (0,0). The result of decodeFloat x is -- unspecified if either of isNaN x or -- isInfinite x is True. decodeFloat :: RealFloat a => a -> (Integer, Int) -- | encodeFloat performs the inverse of decodeFloat in the -- sense that for finite x with the exception of -0.0, -- uncurry encodeFloat (decodeFloat x) = x. -- encodeFloat m n is one of the two closest -- representable floating-point numbers to m*b^^n (or -- ±Infinity if overflow occurs); usually the closer, but if -- m contains too many bits, the result may be rounded in the -- wrong direction. encodeFloat :: RealFloat a => Integer -> Int -> a -- | exponent corresponds to the second component of -- decodeFloat. exponent 0 = 0 and for finite -- nonzero x, exponent x = snd (decodeFloat x) -- + floatDigits x. If x is a finite floating-point -- number, it is equal in value to significand x * b ^^ -- exponent x, where b is the floating-point radix. -- The behaviour is unspecified on infinite or NaN values. exponent :: RealFloat a => a -> Int -- | The first component of decodeFloat, scaled to lie in the open -- interval (-1,1), either 0.0 or of absolute -- value >= 1/b, where b is the floating-point -- radix. The behaviour is unspecified on infinite or NaN -- values. significand :: RealFloat a => a -> a -- | multiplies a floating-point number by an integer power of the radix scaleFloat :: RealFloat a => Int -> a -> a -- | True if the argument is an IEEE "not-a-number" (NaN) value isNaN :: RealFloat a => a -> Bool -- | True if the argument is an IEEE infinity or negative infinity isInfinite :: RealFloat a => a -> Bool -- | True if the argument is too small to be represented in -- normalized format isDenormalized :: RealFloat a => a -> Bool -- | True if the argument is an IEEE negative zero isNegativeZero :: RealFloat a => a -> Bool -- | True if the argument is an IEEE floating point number isIEEE :: RealFloat a => a -> Bool -- | a version of arctangent taking two real floating-point arguments. For -- real floating x and y, atan2 y x -- computes the angle (from the positive x-axis) of the vector from the -- origin to the point (x,y). atan2 y x returns -- a value in the range [-pi, pi]. It follows the -- Common Lisp semantics for the origin when signed zeroes are supported. -- atan2 y 1, with y in a type that is -- RealFloat, should return the same value as atan -- y. A default definition of atan2 is provided, but -- implementors can provide a more accurate implementation. atan2 :: RealFloat a => a -> a -> a -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | The function properFraction takes a real fractional number -- x and returns a pair (n,f) such that x = -- n+f, and: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Show is equivalent to -- --
-- instance (Show a) => Show (Tree a) where -- -- showsPrec d (Leaf m) = showParen (d > app_prec) $ -- showString "Leaf " . showsPrec (app_prec+1) m -- where app_prec = 10 -- -- showsPrec d (u :^: v) = showParen (d > up_prec) $ -- showsPrec (up_prec+1) u . -- showString " :^: " . -- showsPrec (up_prec+1) v -- where up_prec = 5 ---- -- Note that right-associativity of :^: is ignored. For example, -- --
-- showsPrec d x r ++ s == showsPrec d x (r ++ s) ---- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. showsPrec :: Show a => Int -> a -> ShowS -- | A specialised variant of showsPrec, using precedence context -- zero, and returning an ordinary String. show :: Show a => a -> String -- | The method showList is provided to allow the programmer to give -- a specialised way of showing lists of values. For example, this is -- used by the predefined Show instance of the Char type, -- where values of type String should be shown in double quotes, -- rather than between square brackets. showList :: Show a => [a] -> ShowS -- | When a value is bound in do-notation, the pattern on the left -- hand side of <- might not match. In this case, this class -- provides a function to recover. -- -- A Monad without a MonadFail instance may only be used in -- conjunction with pattern that always match, such as newtypes, tuples, -- data types with only a single data constructor, and irrefutable -- patterns (~pat). -- -- Instances of MonadFail should satisfy the following law: -- fail s should be a left zero for >>=, -- --
-- fail s >>= f = fail s ---- -- If your Monad is also MonadPlus, a popular definition is -- --
-- fail _ = mzero --class Monad m => MonadFail (m :: Type -> Type) fail :: MonadFail m => String -> m a -- | Class for string-like datastructures; used by the overloaded string -- extension (-XOverloadedStrings in GHC). class IsString a fromString :: IsString a => String -> a -- | A functor with application, providing operations to -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- --
-- >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--
--
-- -- >>> produceFoo :: Applicative f => f Foo ---- --
-- >>> produceBar :: Applicative f => f Bar -- -- >>> produceBaz :: Applicative f => f Baz ---- --
-- >>> mkState :: Applicative f => f MyState -- -- >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Sequence actions, discarding the value of the first argument. -- --
-- >>> Just 2 *> Just 3 -- Just 3 ---- --
-- >>> Nothing *> Just 3 -- Nothing ---- -- Of course a more interesting use case would be to have effectful -- computations instead of just returning pure values. -- --
-- >>> import Data.Char
--
-- >>> import Text.ParserCombinators.ReadP
--
-- >>> let p = string "my name is " *> munch1 isAlpha <* eof
--
-- >>> readP_to_S p "my name is Simon"
-- [("Simon","")]
--
(*>) :: Applicative f => f a -> f b -> f b
-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*
infixl 4 *>
infixl 4 <*>
-- | The Foldable class represents data structures that can be reduced to a
-- summary value one element at a time. Strict left-associative folds are
-- a good fit for space-efficient reduction, while lazy right-associative
-- folds are a good fit for corecursive iteration, or for folds that
-- short-circuit after processing an initial subsequence of the
-- structure's elements.
--
-- Instances can be derived automatically by enabling the
-- DeriveFoldable extension. For example, a derived instance for
-- a binary tree might be:
--
--
-- {-# LANGUAGE DeriveFoldable #-}
-- data Tree a = Empty
-- | Leaf a
-- | Node (Tree a) a (Tree a)
-- deriving Foldable
--
--
-- A more detailed description can be found in the Overview
-- section of Data.Foldable#overview.
--
-- For the class laws see the Laws section of
-- Data.Foldable#laws.
class Foldable (t :: TYPE LiftedRep -> Type)
-- | Map each element of the structure into a monoid, and combine the
-- results with (<>). This fold is
-- right-associative and lazy in the accumulator. For strict
-- left-associative folds consider foldMap' instead.
--
--
-- >>> foldMap Sum [1, 3, 5]
-- Sum {getSum = 9}
--
--
--
-- >>> foldMap Product [1, 3, 5]
-- Product {getProduct = 15}
--
--
-- -- >>> foldMap (replicate 3) [1, 2, 3] -- [1,1,1,2,2,2,3,3,3] ---- -- When a Monoid's (<>) is lazy in its second -- argument, foldMap can return a result even from an unbounded -- structure. For example, lazy accumulation enables -- Data.ByteString.Builder to efficiently serialise large data -- structures and produce the output incrementally: -- --
-- >>> import qualified Data.ByteString.Lazy as L -- -- >>> import qualified Data.ByteString.Builder as B -- -- >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20 -- -- >>> let lbs = B.toLazyByteString $ foldMap bld [0..] -- -- >>> L.take 64 lbs -- "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" --foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | Right-associative fold of a structure, lazy in the accumulator. -- -- 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, given an -- operator lazy in its right argument, foldr can produce a -- terminating expression from an unbounded list. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldr f z = foldr f z . toList ---- --
-- >>> foldr (||) False [False, True, False] -- True ---- --
-- >>> foldr (||) False [] -- False ---- --
-- >>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd'] -- "foodcba" ---- --
-- >>> foldr (||) False (True : repeat False) -- True ---- -- But the following doesn't terminate: -- --
-- >>> foldr (||) False (repeat False ++ [True]) -- * Hangs forever * ---- --
-- >>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1) -- [1,4,7,10,13] --foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b -- | Left-associative fold of a structure, lazy in the accumulator. This is -- rarely what you want, but can work well for structures with efficient -- right-to-left sequencing and an operator that is lazy in its left -- argument. -- -- In the case of lists, foldl, when applied to a binary operator, -- a starting value (typically the left-identity of the operator), and a -- list, reduces the list using the binary operator, from left to right: -- --
-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn ---- -- Note that to produce the outermost application of the operator the -- entire input list must be traversed. Like all left-associative folds, -- foldl will diverge if given an infinite list. -- -- If you want an efficient strict left-fold, you probably want to use -- foldl' instead of foldl. The reason for this is that the -- latter does not force the inner results (e.g. z `f` x1 -- in the above example) before applying them to the operator (e.g. to -- (`f` x2)). This results in a thunk chain <math> -- elements long, which then must be evaluated from the outside-in. -- -- For a general Foldable structure this should be semantically -- identical to: -- --
-- foldl f z = foldl f z . toList ---- --
-- >>> foldl (+) 42 [1,2,3,4] -- 52 ---- -- Though the result below is lazy, the input is reversed before -- prepending it to the initial accumulator, so corecursion begins only -- after traversing the entire input string. -- --
-- >>> foldl (\acc c -> c : acc) "abcd" "efgh" -- "hgfeabcd" ---- -- A left fold of a structure that is infinite on the right cannot -- terminate, even when for any finite input the fold just returns the -- initial accumulator: -- --
-- >>> foldl (\a _ -> a) 0 $ repeat 1 -- * Hangs forever * ---- -- WARNING: When it comes to lists, you always want to use either -- foldl' or foldr instead. foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | A variant of foldr that has no base case, and thus may only be -- applied to non-empty structures. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. -- --
-- >>> foldr1 (+) [1..4] -- 10 ---- --
-- >>> foldr1 (+) [] -- Exception: Prelude.foldr1: empty list ---- --
-- >>> foldr1 (+) Nothing -- *** Exception: foldr1: empty structure ---- --
-- >>> foldr1 (-) [1..4] -- -2 ---- --
-- >>> foldr1 (&&) [True, False, True, True] -- False ---- --
-- >>> foldr1 (||) [False, False, True, True] -- True ---- --
-- >>> foldr1 (+) [1..] -- * Hangs forever * --foldr1 :: Foldable t => (a -> a -> a) -> t a -> a -- | A variant of foldl that has no base case, and thus may only be -- applied to non-empty structures. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. -- --
-- foldl1 f = foldl1 f . toList ---- --
-- >>> foldl1 (+) [1..4] -- 10 ---- --
-- >>> foldl1 (+) [] -- *** Exception: Prelude.foldl1: empty list ---- --
-- >>> foldl1 (+) Nothing -- *** Exception: foldl1: empty structure ---- --
-- >>> foldl1 (-) [1..4] -- -8 ---- --
-- >>> foldl1 (&&) [True, False, True, True] -- False ---- --
-- >>> foldl1 (||) [False, False, True, True] -- True ---- --
-- >>> foldl1 (+) [1..] -- * Hangs forever * --foldl1 :: Foldable t => (a -> a -> a) -> t a -> a -- | Test whether the structure is empty. The default implementation is -- Left-associative and lazy in both the initial element and the -- accumulator. Thus optimised for structures where the first element can -- be accessed in constant time. Structures where this is not the case -- should have a non-default implementation. -- --
-- >>> null [] -- True ---- --
-- >>> null [1] -- False ---- -- null is expected to terminate even for infinite structures. The -- default implementation terminates provided the structure is bounded on -- the left (there is a leftmost element). -- --
-- >>> null [1..] -- False --null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation just counts elements starting with the -- leftmost. Instances for structures that can compute the element count -- faster than via element-by-element counting, should provide a -- specialised implementation. -- --
-- >>> length [] -- 0 ---- --
-- >>> length ['a', 'b', 'c'] -- 3 -- -- >>> length [1..] -- * Hangs forever * --length :: Foldable t => t a -> Int -- | Does the element occur in the structure? -- -- Note: elem is often used in infix form. -- --
-- >>> 3 `elem` [] -- False ---- --
-- >>> 3 `elem` [1,2] -- False ---- --
-- >>> 3 `elem` [1,2,3,4,5] -- True ---- -- For infinite structures, the default implementation of elem -- terminates if the sought-after value exists at a finite distance from -- the left side of the structure: -- --
-- >>> 3 `elem` [1..] -- True ---- --
-- >>> 3 `elem` ([4..] ++ [3]) -- * Hangs forever * --elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The largest element of a non-empty structure. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. A structure that supports random access -- and maintains its elements in order should provide a specialised -- implementation to return the maximum in faster than linear time. -- --
-- >>> maximum [1..10] -- 10 ---- --
-- >>> maximum [] -- *** Exception: Prelude.maximum: empty list ---- --
-- >>> maximum Nothing -- *** Exception: maximum: empty structure ---- -- WARNING: This function is partial for possibly-empty structures like -- lists. maximum :: (Foldable t, Ord a) => t a -> a -- | The least element of a non-empty structure. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. A structure that supports random access -- and maintains its elements in order should provide a specialised -- implementation to return the minimum in faster than linear time. -- --
-- >>> minimum [1..10] -- 1 ---- --
-- >>> minimum [] -- *** Exception: Prelude.minimum: empty list ---- --
-- >>> minimum Nothing -- *** Exception: minimum: empty structure ---- -- WARNING: This function is partial for possibly-empty structures like -- lists. minimum :: (Foldable t, Ord a) => t a -> a -- | The sum function computes the sum of the numbers of a -- structure. -- --
-- >>> sum [] -- 0 ---- --
-- >>> sum [42] -- 42 ---- --
-- >>> sum [1..10] -- 55 ---- --
-- >>> sum [4.1, 2.0, 1.7] -- 7.8 ---- --
-- >>> sum [1..] -- * Hangs forever * --sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. -- --
-- >>> product [] -- 1 ---- --
-- >>> product [42] -- 42 ---- --
-- >>> product [1..10] -- 3628800 ---- --
-- >>> product [4.1, 2.0, 1.7] -- 13.939999999999998 ---- --
-- >>> product [1..] -- * Hangs forever * --product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | Functors representing data structures that can be transformed to -- structures of the same shape by performing an -- Applicative (or, therefore, Monad) action on each -- element from left to right. -- -- A more detailed description of what same shape means, the -- various methods, how traversals are constructed, and example advanced -- use-cases can be found in the Overview section of -- Data.Traversable#overview. -- -- For the class laws see the Laws section of -- Data.Traversable#laws. 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 Just [1,2,3,4] -- Just [1,2,3,4] ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4] -- Right [1,2,3,4] ---- -- In the next examples, we show that Nothing and Left -- values short circuit the created structure. -- --
-- >>> traverse (const Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0] -- Left 0 --traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) -- | Evaluate each action in the structure from left to right, and collect -- the results. For a version that ignores the results see -- sequenceA_. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3] -- Just [1,2,3] ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3] -- Right [1,2,3] ---- -- The next two example show Nothing and Just will short -- circuit the resulting structure if present in the input. For more -- context, check the Traversable instances for Either and -- Maybe. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3, Nothing] -- Nothing ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3, Left 4] -- Left 4 --sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) -- | 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_. -- --
-- >>> sequence $ Right [1,2,3,4] -- [Right 1,Right 2,Right 3,Right 4] ---- --
-- >>> sequence $ [Right 1,Right 2,Right 3,Right 4] -- Right [1,2,3,4] ---- -- The following examples demonstrate short circuit behavior for -- sequence. -- --
-- >>> sequence $ Left [1,2,3,4] -- Left [1,2,3,4] ---- --
-- >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4] -- Left 0 --sequence :: (Traversable t, Monad m) => t (m a) -> m (t 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 . to ≡ id -- to . from ≡ id --class Generic a -- | This class gives the integer associated with a type-level natural. -- There are instances of the class for every concrete literal: 0, 1, 2, -- etc. class KnownNat (n :: Nat) -- | This class gives the string associated with a type-level symbol. There -- are instances of the class for every concrete literal: "hello", etc. class KnownSymbol (n :: Symbol) -- | 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 <> -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following: -- --
-- >>> "Hello world" <> mempty -- "Hello world" --mempty :: Monoid a => a -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a -- | Fold a list using the monoid. -- -- For most types, the default definition for mconcat will be -- used, but the function is included in the class definition so that an -- optimized version can be provided for specific types. -- --
-- >>> mconcat ["Hello", " ", "Haskell", "!"] -- "Hello Haskell!" --mconcat :: Monoid a => [a] -> a data Bool False :: Bool True :: Bool -- | 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] -- | The character type Char is an enumeration whose values -- represent Unicode (or equivalently ISO/IEC 10646) code points (i.e. -- characters, see http://www.unicode.org/ for details). This set -- extends the ISO 8859-1 (Latin-1) character set (the first 256 -- characters), which is itself an extension of the ASCII character set -- (the first 128 characters). A character literal in Haskell has type -- Char. -- -- To convert a Char to or from the corresponding Int value -- defined by Unicode, use toEnum and fromEnum from the -- Enum class respectively (or equivalently ord and -- chr). data Char -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double -- | Single-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- single-precision type. data Float -- | A fixed-precision integer type with at least the range [-2^29 .. -- 2^29-1]. The exact range for a given implementation can be -- determined by using minBound and maxBound from the -- Bounded class. data Int -- | 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 -- | Arbitrary precision integers. In contrast with fixed-size integral -- types such as Int, the Integer type represents the -- entire infinite range of integers. -- -- Integers are stored in a kind of sign-magnitude form, hence do not -- expect two's complement form when using bit operations. -- -- If the value is small (fit into an Int), IS constructor -- is used. Otherwise Integer and IN constructors are used -- to store a BigNat representing respectively the positive or the -- negative value magnitude. -- -- Invariant: Integer and IN are used iff value doesn't fit -- in IS data Integer -- | Natural number -- -- Invariant: numbers <= 0xffffffffffffffff use the NS -- constructor data Natural -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). Using Maybe is a good way to deal with -- errors or exceptional cases without resorting to drastic measures such -- as error. -- -- The Maybe type is also a monad. It is a simple kind of error -- monad, where all errors are represented by Nothing. A richer -- error monad can be built using the Either type. data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Arbitrary-precision rational numbers, represented as a ratio of two -- Integer values. A rational number may be constructed using the -- % operator. type Rational = Ratio Integer -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= -- operations from the Monad class. data IO a -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | 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 -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> s -- Left "foo" -- -- >>> let n = Right 3 :: Either String Int -- -- >>> n -- Right 3 -- -- >>> :type s -- s :: Either String Int -- -- >>> :type n -- n :: Either String Int ---- -- The fmap from our Functor instance will ignore -- Left values, but will apply the supplied function to values -- contained in a Right: -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> fmap (*2) s -- Left "foo" -- -- >>> fmap (*2) n -- Right 6 ---- -- The Monad instance for Either allows us to chain -- together multiple actions which may fail, and fail overall if any of -- the individual steps failed. First we'll write a function that can -- either parse an Int from a Char, or fail. -- --
-- >>> import Data.Char ( digitToInt, isDigit )
--
-- >>> :{
-- let parseEither :: Char -> Either String Int
-- parseEither c
-- | isDigit c = Right (digitToInt c)
-- | otherwise = Left "parse error"
--
-- >>> :}
--
--
-- The following should work, since both '1' and '2'
-- can be parsed as Ints.
--
--
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither '1'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Right 3 ---- -- But the following should fail overall, since the first operation where -- we attempt to parse 'm' as an Int will fail: -- --
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither 'm'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Left "parse error" --data Either a b Left :: a -> Either a b Right :: b -> Either a b -- | Non-empty (and non-strict) list type. data NonEmpty a (:|) :: a -> [a] -> NonEmpty a infixr 5 :| -- | The kind of types with lifted values. For example Int :: -- Type. type Type = TYPE LiftedRep -- | Coercible is a two-parameter class that has instances for -- types a and b if the compiler can infer that they -- have the same representation. This class does not have regular -- instances; instead they are created on-the-fly during type-checking. -- Trying to manually declare an instance of Coercible is an -- error. -- -- Nevertheless one can pretend that the following three kinds of -- instances exist. First, as a trivial base-case: -- --
-- instance Coercible a a ---- -- Furthermore, for every type constructor there is an instance that -- allows to coerce under the type constructor. For example, let -- D be a prototypical type constructor (data or -- newtype) with three type arguments, which have roles -- nominal, representational resp. phantom. -- Then there is an instance of the form -- --
-- instance Coercible b b' => Coercible (D a b c) (D a b' c') ---- -- Note that the nominal type arguments are equal, the -- representational type arguments can differ, but need to have -- a Coercible instance themself, and the phantom type -- arguments can be changed arbitrarily. -- -- The third kind of instance exists for every newtype NT = MkNT -- T and comes in two variants, namely -- --
-- instance Coercible a T => Coercible a NT ---- --
-- instance Coercible T b => Coercible NT b ---- -- This instance is only usable if the constructor MkNT is in -- scope. -- -- If, as a library author of a type constructor like Set a, you -- want to prevent a user of your module to write coerce :: Set T -- -> Set NT, you need to set the role of Set's type -- parameter to nominal, by writing -- --
-- type role Set nominal ---- -- For more details about this feature, please refer to Safe -- Coercions by Joachim Breitner, Richard A. Eisenberg, Simon Peyton -- Jones and Stephanie Weirich. class a ~R# b => Coercible (a :: k) (b :: k) -- | (Kind) This is the kind of type-level symbols. Declared here because -- class IP needs it data Symbol -- | Promote a function to a monad. liftM :: Monad m => (a1 -> r) -> m a1 -> m r -- | Identity function. -- --
-- id x = x --id :: a -> a -- | Case analysis for the Either type. If the value is -- Left a, apply the first function to a; if it -- is Right b, apply the second function to b. -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> either length (*2) s -- 3 -- -- >>> either length (*2) n -- 6 --either :: (a -> c) -> (b -> c) -> Either a b -> c -- | An arbitrary-precision number represented using scientific -- notation. -- -- This type describes the set of all Reals which have a -- finite decimal expansion. -- -- A scientific number with coefficient c and -- base10Exponent e corresponds to the Fractional -- number: fromInteger c * 10 ^^ e data Scientific -- | The class of types that can be converted to a hash value. -- -- Minimal implementation: hashWithSalt. -- -- Note: the hash is not guaranteed to be stable across library -- versions, operating systems or architectures. For stable hashing use -- named hashes: SHA256, CRC32 etc. -- -- If you are looking for Hashable instance in time -- package, check time-compat class Eq a => Hashable a -- | Return a hash value for the argument, using the given salt. -- -- The general contract of hashWithSalt is: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | 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 . -- | 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 -- | 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 -- | A space efficient, packed, unboxed Unicode text type. data Text -- | A map from keys to values. A map cannot contain duplicate keys; each -- key can map to at most one value. data HashMap k v -- | 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 id ≡ id ---- -- If you supply first and second, ensure: -- --
-- first id ≡ id -- second id ≡ id ---- -- 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 ---- --
-- >>> 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 ---- --
-- >>> 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. -- --
-- second ≡ bimap id ---- --
-- >>> second (+1) ('j', 3)
-- ('j',4)
--
--
-- -- >>> second (+1) (Right 3) -- Right 4 --second :: Bifunctor p => (b -> c) -> p a b -> p a c -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore the results see forM. -- -- forM_ is just like for_, but specialised to monadic -- actions. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- mapM_ is just like traverse_, but specialised to monadic -- actions. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | 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 -- | A monoid on applicative functors. -- -- If defined, some and many should be the least solutions -- of the equations: -- -- class Applicative f => Alternative (f :: Type -> Type) -- | An associative binary operation (<|>) :: Alternative f => f a -> f a -> f a infixl 3 <|> -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) -- | The identity of mplus. It should also satisfy the equations -- --
-- mzero >>= f = mzero -- v >> mzero = mzero ---- -- The default definition is -- --
-- mzero = empty --mzero :: MonadPlus m => m a -- | An associative operation. The default definition is -- --
-- mplus = (<|>) --mplus :: MonadPlus m => m a -> m a -> m a -- | Uninhabited data type data Void -- | The Item type function returns the type of items of the -- structure l. type family Item l -- | Bitraversable identifies bifunctorial data structures whose -- elements can be traversed in order, performing Applicative or -- Monad actions at each element, and collecting a result -- structure with the same shape. -- -- As opposed to Traversable data structures, which have one -- variety of element on which an action can be performed, -- Bitraversable data structures have two such varieties of -- elements. -- -- A definition of bitraverse must satisfy the following laws: -- --
-- t :: (Applicative f, Applicative g) => f a -> g a ---- -- preserving the Applicative operations: -- --
-- 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. -- -- Some simple examples are Either and (,): -- --
-- instance Bitraversable Either where -- bitraverse f _ (Left x) = Left <$> f x -- bitraverse _ g (Right y) = Right <$> g y -- -- instance Bitraversable (,) where -- bitraverse f g (x, y) = (,) <$> f x <*> g y ---- -- Bitraversable relates to its superclasses in the following -- ways: -- --
-- bimap f g ≡ runIdentity . bitraverse (Identity . f) (Identity . g) -- bifoldMap f g = getConst . bitraverse (Const . f) (Const . g) ---- -- These are available as bimapDefault and bifoldMapDefault -- respectively. class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type) -- | Evaluates the relevant functions at each element in the structure, -- running the action, and builds a new structure with the same shape, -- using the results produced from sequencing the actions. -- --
-- bitraverse f g ≡ bisequenceA . bimap f g ---- -- For a version that ignores the results, see bitraverse_. -- --
-- >>> bitraverse listToMaybe (find odd) (Left []) -- Nothing ---- --
-- >>> bitraverse listToMaybe (find odd) (Left [1, 2, 3]) -- Just (Left 1) ---- --
-- >>> bitraverse listToMaybe (find odd) (Right [4, 5]) -- Just (Right 5) ---- --
-- >>> bitraverse listToMaybe (find odd) ([1, 2, 3], [4, 5]) -- Just (1,5) ---- --
-- >>> bitraverse listToMaybe (find odd) ([], [4, 5]) -- Nothing --bitraverse :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d) -- | Alias for bisequence. bisequenceA :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) -- | Sequences all the actions in a structure, building a new structure -- with the same shape using the results of the actions. For a version -- that ignores the results, see bisequence_. -- --
-- bisequence ≡ bitraverse id id ---- --
-- >>> bisequence (Just 4, Nothing) -- Nothing ---- --
-- >>> bisequence (Just 4, Just 5) -- Just (4,5) ---- --
-- >>> bisequence ([1, 2, 3], [4, 5]) -- [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)] --bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) -- | Alias for bitraverse. bimapM :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d) -- | A default definition of bimap in terms of the -- Bitraversable operations. -- --
-- bimapDefault f g ≡ -- runIdentity . bitraverse (Identity . f) (Identity . g) --bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d -- | The bimapAccumR function behaves like a combination of -- bimap and bifoldr; it traverses a structure from right -- to left, threading a state of type a and using the given -- actions to compute new elements for the structure. -- --
-- >>> bimapAccumR (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
-- (7,("True","oof"))
--
bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
-- | The bimapAccumL function behaves like a combination of
-- bimap and bifoldl; it traverses a structure from left to
-- right, threading a state of type a and using the given
-- actions to compute new elements for the structure.
--
--
-- >>> bimapAccumL (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
-- (8,("True","oof"))
--
bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
-- | Alias for bifor.
biforM :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)
-- | bifor is bitraverse with the structure as the first
-- argument. For a version that ignores the results, see bifor_.
--
-- -- >>> bifor (Left []) listToMaybe (find even) -- Nothing ---- --
-- >>> bifor (Left [1, 2, 3]) listToMaybe (find even) -- Just (Left 1) ---- --
-- >>> bifor (Right [4, 5]) listToMaybe (find even) -- Just (Right 4) ---- --
-- >>> bifor ([1, 2, 3], [4, 5]) listToMaybe (find even) -- Just (1,4) ---- --
-- >>> bifor ([], [4, 5]) listToMaybe (find even) -- Nothing --bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d) -- | A default definition of bifoldMap in terms of the -- Bitraversable operations. -- --
-- bifoldMapDefault f g ≡ -- getConst . bitraverse (Const . f) (Const . g) --bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m -- | Bifoldable identifies foldable structures with two different -- varieties of elements (as opposed to Foldable, which has one -- variety of element). Common examples are Either and -- (,): -- --
-- instance Bifoldable Either where -- bifoldMap f _ (Left a) = f a -- bifoldMap _ g (Right b) = g b -- -- instance Bifoldable (,) where -- bifoldr f g z (a, b) = f a (g b z) ---- -- Some examples below also use the following BiList to showcase empty -- Bifoldable behaviors when relevant (Either and (,) -- containing always exactly resp. 1 and 2 elements): -- --
-- data BiList a b = BiList [a] [b] -- -- instance Bifoldable BiList where -- bifoldr f g z (BiList as bs) = foldr f (foldr g z bs) as ---- -- A minimal Bifoldable definition consists of either -- bifoldMap or bifoldr. When defining more than this -- minimal set, one should ensure that the following identities hold: -- --
-- bifold ≡ bifoldMap id id -- bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty -- bifoldr f g z t ≡ appEndo (bifoldMap (Endo . f) (Endo . g) t) z ---- -- If the type is also a Bifunctor instance, it should satisfy: -- --
-- bifoldMap f g ≡ bifold . bimap f g ---- -- which implies that -- --
-- bifoldMap f g . bimap h i ≡ bifoldMap (f . h) (g . i) --class Bifoldable (p :: TYPE LiftedRep -> TYPE LiftedRep -> Type) -- | Combines the elements of a structure using a monoid. -- --
-- bifold ≡ bifoldMap id id ---- --
-- >>> bifold (Right [1, 2, 3]) -- [1,2,3] ---- --
-- >>> bifold (Left [5, 6]) -- [5,6] ---- --
-- >>> bifold ([1, 2, 3], [4, 5]) -- [1,2,3,4,5] ---- --
-- >>> bifold (Product 6, Product 7)
-- Product {getProduct = 42}
--
--
--
-- >>> bifold (Sum 6, Sum 7)
-- Sum {getSum = 13}
--
bifold :: (Bifoldable p, Monoid m) => p m m -> m
-- | Combines the elements of a structure, given ways of mapping them to a
-- common monoid.
--
-- -- bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) ([1..], "89") -- [1,2,3,8,9] ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) (Left [1..]) -- [1,2,3] ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) (Right "89") -- [8,9] --bifoldMap :: (Bifoldable p, Monoid m) => (a -> m) -> (b -> m) -> p a b -> m -- | Combines the elements of a structure in a right associative manner. -- Given a hypothetical function toEitherList :: p a b -> [Either -- a b] yielding a list of all elements of a structure in order, the -- following would hold: -- --
-- bifoldr f g z ≡ foldr (either f g) z . toEitherList ---- --
-- > bifoldr (+) (*) 3 (5, 7) -- 26 -- 5 + (7 * 3) -- -- > bifoldr (+) (*) 3 (7, 5) -- 22 -- 7 + (5 * 3) -- -- > bifoldr (+) (*) 3 (Right 5) -- 15 -- 5 * 3 -- -- > bifoldr (+) (*) 3 (Left 5) -- 8 -- 5 + 3 --bifoldr :: Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c -- | Combines the elements of a structure in a left associative manner. -- Given a hypothetical function toEitherList :: p a b -> [Either -- a b] yielding a list of all elements of a structure in order, the -- following would hold: -- --
-- bifoldl f g z -- ≡ foldl (acc -> either (f acc) (g acc)) z . toEitherList ---- -- Note that if you want an efficient left-fold, you probably want to use -- bifoldl' instead of bifoldl. The reason is that the -- latter does not force the "inner" results, resulting in a thunk chain -- which then must be evaluated from the outside-in. -- --
-- > bifoldl (+) (*) 3 (5, 7) -- 56 -- (5 + 3) * 7 -- -- > bifoldl (+) (*) 3 (7, 5) -- 50 -- (7 + 3) * 5 -- -- > bifoldl (+) (*) 3 (Right 5) -- 15 -- 5 * 3 -- -- > bifoldl (+) (*) 3 (Left 5) -- 8 -- 5 + 3 --bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c -- | Map each element of a structure using one of two actions, evaluate -- these actions from left to right, and ignore the results. For a -- version that doesn't ignore the results, see bitraverse. -- --
-- >>> bitraverse_ print (print . show) ("Hello", True)
-- "Hello"
-- "True"
--
--
-- -- >>> bitraverse_ print (print . show) (Right True) -- "True" ---- --
-- >>> bitraverse_ print (print . show) (Left "Hello") -- "Hello" --bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () -- | The bisum function computes the sum of the numbers of a -- structure. -- --
-- >>> bisum (42, 17) -- 59 ---- --
-- >>> bisum (Right 42) -- 42 ---- --
-- >>> bisum (BiList [13, 29, 4] [18, 1, 7]) -- 72 ---- --
-- >>> bisum (BiList [13, 29, 4] []) -- 46 ---- --
-- >>> bisum (BiList [] []) -- 0 --bisum :: (Bifoldable t, Num a) => t a a -> a -- | Evaluate each action in the structure from left to right, and ignore -- the results. For a version that doesn't ignore the results, see -- bisequence. -- --
-- >>> bisequence_ (print "Hello", print "World") -- "Hello" -- "World" ---- --
-- >>> bisequence_ (Left (print "Hello")) -- "Hello" ---- --
-- >>> bisequence_ (Right (print "World")) -- "World" --bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () -- | Alias for bisequence_. bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () -- | The biproduct function computes the product of the numbers of a -- structure. -- --
-- >>> biproduct (42, 17) -- 714 ---- --
-- >>> biproduct (Right 42) -- 42 ---- --
-- >>> biproduct (BiList [13, 29, 4] [18, 1, 7]) -- 190008 ---- --
-- >>> biproduct (BiList [13, 29, 4] []) -- 1508 ---- --
-- >>> biproduct (BiList [] []) -- 1 --biproduct :: (Bifoldable t, Num a) => t a a -> a -- | bior 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. -- --
-- >>> bior (True, False) -- True ---- --
-- >>> bior (False, False) -- False ---- --
-- >>> bior (Left True) -- True ---- -- Empty structures yield False: -- --
-- >>> bior (BiList [] []) -- False ---- -- A True value finitely far from the left end yields True -- (short circuit): -- --
-- >>> bior (BiList [False, False, True, False] (repeat False)) -- True ---- -- A True value infinitely far from the left end hangs: -- --
-- > bior (BiList (repeat False) [True]) -- * Hangs forever * ---- -- An infinitely False value hangs: -- --
-- > bior (BiList (repeat False) []) -- * Hangs forever * --bior :: Bifoldable t => t Bool Bool -> Bool -- | Test whether the structure is empty. -- --
-- >>> binull (18, 42) -- False ---- --
-- >>> binull (Right 42) -- False ---- --
-- >>> binull (BiList [] []) -- True --binull :: Bifoldable t => t a b -> Bool -- | binotElem is the negation of bielem. -- --
-- >>> binotElem 42 (17, 42) -- False ---- --
-- >>> binotElem 42 (17, 43) -- True ---- --
-- >>> binotElem 42 (Left 42) -- False ---- --
-- >>> binotElem 42 (Right 13) -- True ---- --
-- >>> binotElem 42 (BiList [1..5] [1..100]) -- False ---- --
-- >>> binotElem 42 (BiList [1..5] [1..41]) -- True --binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool -- | Alias for biasum. bimsum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a -- | The least element of a non-empty structure with respect to the given -- comparison function. -- --
-- >>> biminimumBy compare (42, 17) -- 17 ---- --
-- >>> biminimumBy compare (Left 17) -- 17 ---- --
-- >>> biminimumBy compare (BiList [42, 17, 23] [-5, 18]) -- -5 ---- -- On empty structures, this function throws an exception: -- --
-- >>> biminimumBy compare (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a -- | The least element of a non-empty structure. -- --
-- >>> biminimum (42, 17) -- 17 ---- --
-- >>> biminimum (Right 42) -- 42 ---- --
-- >>> biminimum (BiList [13, 29, 4] [18, 1, 7]) -- 1 ---- --
-- >>> biminimum (BiList [13, 29, 4] []) -- 4 ---- -- On empty structures, this function throws an exception: -- --
-- >>> biminimum (BiList [] []) -- *** Exception: biminimum: empty structure -- ... --biminimum :: (Bifoldable t, Ord a) => t a a -> a -- | The largest element of a non-empty structure with respect to the given -- comparison function. -- --
-- >>> bimaximumBy compare (42, 17) -- 42 ---- --
-- >>> bimaximumBy compare (Left 17) -- 17 ---- --
-- >>> bimaximumBy compare (BiList [42, 17, 23] [-5, 18]) -- 42 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bimaximumBy compare (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a -- | The largest element of a non-empty structure. -- --
-- >>> bimaximum (42, 17) -- 42 ---- --
-- >>> bimaximum (Right 42) -- 42 ---- --
-- >>> bimaximum (BiList [13, 29, 4] [18, 1, 7]) -- 29 ---- --
-- >>> bimaximum (BiList [13, 29, 4] []) -- 29 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bimaximum (BiList [] []) -- *** Exception: bimaximum: empty structure -- ... --bimaximum :: (Bifoldable t, Ord a) => t a a -> a -- | Alias for bitraverse_. bimapM_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () -- | Returns the size/length of a finite structure as an Int. -- --
-- >>> bilength (True, 42) -- 2 ---- --
-- >>> bilength (Right 42) -- 1 ---- --
-- >>> bilength (BiList [1,2,3] [4,5]) -- 5 ---- --
-- >>> bilength (BiList [] []) -- 0 ---- -- On infinite structures, this function hangs: -- --
-- > bilength (BiList [1..] []) -- * Hangs forever * --bilength :: Bifoldable t => t a b -> Int -- | As bitraverse_, but with the structure as the primary argument. -- For a version that doesn't ignore the results, see bifor. -- --
-- >>> bifor_ ("Hello", True) print (print . show)
-- "Hello"
-- "True"
--
--
-- -- >>> bifor_ (Right True) print (print . show) -- "True" ---- --
-- >>> bifor_ (Left "Hello") print (print . show) -- "Hello" --bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () -- | Alias for bifor_. biforM_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () -- | Right associative monadic bifold over a structure. bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c -- | A variant of bifoldr that has no base case, and thus may only -- be applied to non-empty structures. -- --
-- >>> bifoldr1 (+) (5, 7) -- 12 ---- --
-- >>> bifoldr1 (+) (Right 7) -- 7 ---- --
-- >>> bifoldr1 (+) (Left 5) -- 5 ---- --
-- > bifoldr1 (+) (BiList [1, 2] [3, 4]) -- 10 -- 1 + (2 + (3 + 4)) ---- --
-- >>> bifoldr1 (+) (BiList [1, 2] []) -- 3 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bifoldr1 (+) (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a -- | As bifoldr, but strict in the result of the reduction functions -- at each step. bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c -- | Left associative monadic bifold over a structure. -- --
-- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 ("Hello", True)
-- "Hello"
-- "True"
-- 42
--
--
-- -- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Right True) -- "True" -- 42 ---- --
-- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Left "Hello") -- "Hello" -- 42 --bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a -- | A variant of bifoldl that has no base case, and thus may only -- be applied to non-empty structures. -- --
-- >>> bifoldl1 (+) (5, 7) -- 12 ---- --
-- >>> bifoldl1 (+) (Right 7) -- 7 ---- --
-- >>> bifoldl1 (+) (Left 5) -- 5 ---- --
-- > bifoldl1 (+) (BiList [1, 2] [3, 4]) -- 10 -- ((1 + 2) + 3) + 4 ---- --
-- >>> bifoldl1 (+) (BiList [1, 2] []) -- 3 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bifoldl1 (+) (BiList [] []) -- *** Exception: bifoldl1: empty structure -- ... --bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> a -- | As bifoldl, but strict in the result of the reduction functions -- at each step. -- -- This ensures that each step of the bifold is forced to weak head -- normal form before being applied, avoiding the collection of thunks -- that would otherwise occur. This is often what you want to strictly -- reduce a finite structure to a single, monolithic result (e.g., -- bilength). bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a -- | The bifind function takes a predicate and a structure and -- returns the leftmost element of the structure matching the predicate, -- or Nothing if there is no such element. -- --
-- >>> bifind even (27, 53) -- Nothing ---- --
-- >>> bifind even (27, 52) -- Just 52 ---- --
-- >>> bifind even (26, 52) -- Just 26 ---- -- Empty structures always yield Nothing: -- --
-- >>> bifind even (BiList [] []) -- Nothing --bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a -- | Does the element occur in the structure? -- --
-- >>> bielem 42 (17, 42) -- True ---- --
-- >>> bielem 42 (17, 43) -- False ---- --
-- >>> bielem 42 (Left 42) -- True ---- --
-- >>> bielem 42 (Right 13) -- False ---- --
-- >>> bielem 42 (BiList [1..5] [1..100]) -- True ---- --
-- >>> bielem 42 (BiList [1..5] [1..41]) -- False --bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool -- | Given a means of mapping the elements of a structure to lists, -- computes the concatenation of all such lists in order. -- --
-- >>> biconcatMap (take 3) (fmap digitToInt) ([1..], "89") -- [1,2,3,8,9] ---- --
-- >>> biconcatMap (take 3) (fmap digitToInt) (Left [1..]) -- [1,2,3] ---- --
-- >>> biconcatMap (take 3) (fmap digitToInt) (Right "89") -- [8,9] --biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c] -- | Reduces a structure of lists to the concatenation of those lists. -- --
-- >>> biconcat ([1, 2, 3], [4, 5]) -- [1,2,3,4,5] ---- --
-- >>> biconcat (Left [1, 2, 3]) -- [1,2,3] ---- --
-- >>> biconcat (BiList [[1, 2, 3, 4, 5], [6, 7, 8]] [[9]]) -- [1,2,3,4,5,6,7,8,9] --biconcat :: Bifoldable t => t [a] [a] -> [a] -- | The sum of a collection of actions, generalizing biconcat. -- --
-- >>> biasum (Nothing, Nothing) -- Nothing ---- --
-- >>> biasum (Nothing, Just 42) -- Just 42 ---- --
-- >>> biasum (Just 18, Nothing) -- Just 18 ---- --
-- >>> biasum (Just 18, Just 42) -- Just 18 --biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a -- | Determines whether any element of the structure satisfies its -- appropriate predicate argument. Empty structures yield False. -- --
-- >>> biany even isDigit (27, 't') -- False ---- --
-- >>> biany even isDigit (27, '8') -- True ---- --
-- >>> biany even isDigit (26, 't') -- True ---- --
-- >>> biany even isDigit (Left 27) -- False ---- --
-- >>> biany even isDigit (Left 26) -- True ---- --
-- >>> biany even isDigit (BiList [27, 53] ['t', '8']) -- True ---- -- Empty structures yield False: -- --
-- >>> biany even isDigit (BiList [] []) -- False --biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool -- | biand 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. -- --
-- >>> biand (True, False) -- False ---- --
-- >>> biand (True, True) -- True ---- --
-- >>> biand (Left True) -- True ---- -- Empty structures yield True: -- --
-- >>> biand (BiList [] []) -- True ---- -- A False value finitely far from the left end yields -- False (short circuit): -- --
-- >>> biand (BiList [True, True, False, True] (repeat True)) -- False ---- -- A False value infinitely far from the left end hangs: -- --
-- > biand (BiList (repeat True) [False]) -- * Hangs forever * ---- -- An infinitely True value hangs: -- --
-- > biand (BiList (repeat True) []) -- * Hangs forever * --biand :: Bifoldable t => t Bool Bool -> Bool -- | Determines whether all elements of the structure satisfy their -- appropriate predicate argument. Empty structures yield True. -- --
-- >>> biall even isDigit (27, 't') -- False ---- --
-- >>> biall even isDigit (26, '8') -- True ---- --
-- >>> biall even isDigit (Left 27) -- False ---- --
-- >>> biall even isDigit (Left 26) -- True ---- --
-- >>> biall even isDigit (BiList [26, 52] ['3', '8']) -- True ---- -- Empty structures yield True: -- --
-- >>> biall even isDigit (BiList [] []) -- True --biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool -- | Collects the list of elements of a structure, from left to right. -- --
-- >>> biList (18, 42) -- [18,42] ---- --
-- >>> biList (Left 18) -- [18] --biList :: Bifoldable t => t a a -> [a] -- | 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. This allows us to run IO -- computations in any monadic stack, so long as it supports these kinds -- of operations (i.e. IO is the base monad for the stack). -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a -- | zipWithM_ is the extension of zipWithM which ignores the -- final result. zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m () -- | The zipWithM function generalizes zipWith to arbitrary -- applicative functors. zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c] -- | The reverse of when. unless :: Applicative f => Bool -> f () -> f () -- | Like replicateM, but discards the result. -- --
-- >>> replicateM_ 3 (putStrLn "a") -- a -- a -- a --replicateM_ :: Applicative m => Int -> m a -> m () -- | replicateM n act performs the action act -- n times, and then returns the list of results: -- --
-- >>> import Control.Monad.State -- -- >>> runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1 -- ([1,2,3],4) --replicateM :: Applicative m => Int -> m a -> m [a] -- | Direct MonadPlus equivalent of filter. -- --
-- filter = ( mfilter :: (a -> Bool) -> [a] -> [a] ) ---- -- An example using mfilter with the Maybe monad: -- --
-- >>> mfilter odd (Just 1) -- Just 1 -- -- >>> mfilter odd (Just 2) -- Nothing --mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a -- | The mapAndUnzipM function maps its first argument over a list, -- returning the result as a pair of lists. This function is mainly used -- with complicated data structures or a state monad. mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) -- | Repeat an action indefinitely. -- --
-- 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 ---- -- Note that "forever" isn't necessarily non-terminating. If the action -- is in a MonadPlus and short-circuits after some number -- of iterations. then forever actually returns -- mzero, effectively short-circuiting its caller. forever :: Applicative f => f a -> f b -- | Like foldM, but discards the result. foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () -- | The foldM function is analogous to foldl, except that -- its result is encapsulated in a monad. Note that foldM works -- from left-to-right over the list arguments. This could be an issue -- where (>>) and the `folded function' are not -- commutative. -- --
-- foldM f a1 [x1, x2, ..., xm] -- -- == -- -- do -- a2 <- f a1 x1 -- a3 <- f a2 x2 -- ... -- f am xm ---- -- If right-to-left evaluation is required, the input list should be -- reversed. -- -- Note: foldM is the same as foldlM foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b -- | This generalizes the list-based filter function. filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] -- | Left-to-right composition of Kleisli arrows. -- -- '(bs >=> cs) a' can be understood as the -- do expression -- --
-- do b <- bs a -- cs b --(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 >=> -- | Right-to-left composition of Kleisli arrows. -- (>=>), with the arguments flipped. -- -- Note how this operator resembles function composition -- (.): -- --
-- (.) :: (b -> c) -> (a -> b) -> a -> c -- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c --(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 <=< -- | Strict version of <$>. (<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 <$!> -- | 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) -- | Identity functor and monad. (a non-strict monad) newtype Identity a Identity :: a -> Identity a [runIdentity] :: Identity a -> a -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () -- | The readLn function combines getLine and readIO. readLn :: Read a => IO a -- | The readIO function is similar to read except that it -- signals parse failure to the IO monad instead of terminating -- the program. readIO :: Read a => String -> IO a -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | Write a string to the standard output device (same as hPutStr -- stdout). putStr :: String -> IO () -- | Write a character to the standard output device (same as -- hPutChar stdout). putChar :: Char -> IO () -- | The interact function takes a function of type -- String->String as its argument. The entire input from the -- standard input device is passed to this function as its argument, and -- the resulting string is output on the standard output device. interact :: (String -> String) -> IO () -- | Read a line from the standard input device (same as hGetLine -- stdin). getLine :: IO String -- | The getContents operation returns all user input as a single -- string, which is read lazily as it is needed (same as -- hGetContents stdin). getContents :: IO String -- | Read a character from the standard input device (same as -- hGetChar stdin). getChar :: IO Char -- | The computation appendFile file str function appends -- the string str, to the file file. -- -- Note that writeFile and appendFile write a literal -- string to a file. To write a value of any printable type, as with -- print, use the show function to convert the value to a -- string first. -- --
-- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) --appendFile :: FilePath -> String -> IO () -- | Raise an IOException in the IO monad. ioError :: IOError -> IO a -- | File and directory names are values of type String, whose -- precise meaning is operating system dependent. Files can be opened, -- yielding a handle which can then be used to operate on the contents of -- that file. type FilePath = String -- | The Haskell 2010 type for exceptions in the IO monad. Any I/O -- operation may raise an IOException 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 -- | Construct an IOException 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 -- | 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
-- | Evaluate each monadic action in the structure from left to right, and
-- ignore the results. For a version that doesn't ignore the results see
-- sequence.
--
-- sequence_ is just like sequenceA_, but specialised to
-- monadic actions.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
-- | 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 [] -- False ---- --
-- >>> or [True] -- True ---- --
-- >>> or [False] -- False ---- --
-- >>> or [True, True, False] -- True ---- --
-- >>> or (True : repeat False) -- Infinite list [True,False,False,False,... -- True ---- --
-- >>> or (repeat False) -- * Hangs forever * --or :: Foldable t => t Bool -> Bool -- | notElem is the negation of elem. -- --
-- >>> 3 `notElem` [] -- True ---- --
-- >>> 3 `notElem` [1,2] -- True ---- --
-- >>> 3 `notElem` [1,2,3,4,5] -- False ---- -- For infinite structures, notElem terminates if the value exists -- at a finite distance from the left side of the structure: -- --
-- >>> 3 `notElem` [1..] -- False ---- --
-- >>> 3 `notElem` ([4..] ++ [3]) -- * Hangs forever * --notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | The sum of a collection of actions, generalizing concat. -- -- msum is just like asum, but specialised to -- MonadPlus. msum :: (Foldable t, MonadPlus m) => t (m a) -> m a -- | Map a function over all the elements of a container and concatenate -- the resulting lists. -- --
-- >>> concatMap (take 3) [[1..], [10..], [100..], [1000..]] -- [1,2,3,10,11,12,100,101,102,1000,1001,1002] ---- --
-- >>> concatMap (take 3) (Just [1..]) -- [1,2,3] --concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | The concatenation of all the elements of a container of lists. -- --
-- >>> concat (Just [1, 2, 3]) -- [1,2,3] ---- --
-- >>> concat (Left 42) -- [] ---- --
-- >>> concat [[1, 2, 3], [4, 5], [6], []] -- [1,2,3,4,5,6] --concat :: Foldable t => t [a] -> [a] -- | Determines whether any element of the structure satisfies the -- predicate. -- --
-- >>> any (> 3) [] -- False ---- --
-- >>> any (> 3) [1,2] -- False ---- --
-- >>> any (> 3) [1,2,3,4,5] -- True ---- --
-- >>> any (> 3) [1..] -- True ---- --
-- >>> any (> 3) [0, -1..] -- * Hangs forever * --any :: Foldable t => (a -> Bool) -> t a -> 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 [] -- True ---- --
-- >>> and [True] -- True ---- --
-- >>> and [False] -- False ---- --
-- >>> and [True, True, False] -- False ---- --
-- >>> and (False : repeat True) -- Infinite list [False,True,True,True,... -- False ---- --
-- >>> and (repeat True) -- * Hangs forever * --and :: Foldable t => t Bool -> Bool -- | Determines whether all elements of the structure satisfy the -- predicate. -- --
-- >>> all (> 3) [] -- True ---- --
-- >>> all (> 3) [1,2] -- False ---- --
-- >>> all (> 3) [1,2,3,4,5] -- False ---- --
-- >>> all (> 3) [1..] -- False ---- --
-- >>> all (> 3) [4..] -- * Hangs forever * --all :: Foldable t => (a -> Bool) -> t a -> Bool -- | 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] -- | unwords is an inverse operation to words. It joins words -- with separating spaces. -- --
-- >>> unwords ["Lorem", "ipsum", "dolor"] -- "Lorem ipsum dolor" --unwords :: [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] -- | Maybe monoid returning the leftmost non-Nothing value. -- -- First a is isomorphic to Alt Maybe -- a, but precedes it historically. -- --
-- >>> getFirst (First (Just "hello") <> First Nothing <> First (Just "world")) -- Just "hello" --data First a -- | A type synonym for Natural. -- -- Prevously, this was an opaque data type, but it was changed to a type -- synonym. type Nat = Natural -- | equivalent to readsPrec with a precedence of 0. reads :: Read a => ReadS a -- | 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) -- | readParen True p parses what p parses, -- but surrounded with parentheses. -- -- readParen False p parses what p -- parses, but optionally surrounded with parentheses. readParen :: Bool -> ReadS a -> ReadS a -- | The lex function reads a single lexeme from the input, -- discarding initial white space, and returning the characters that -- constitute the lexeme. If the input string contains only white space, -- lex returns a single successful `lexeme' consisting of the -- empty string. (Thus lex "" = [("","")].) If there is -- no legal lexeme at the beginning of the input string, lex fails -- (i.e. returns []). -- -- This lexer is not completely faithful to the Haskell lexical syntax in -- the following respects: -- --
-- zipWith3 (,,) xs ys zs == zip3 xs ys zs -- zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..] --zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] -- | <math>. zipWith generalises zip by zipping with -- the function given as the first argument, instead of a tupling -- function. -- --
-- zipWith (,) xs ys == zip xs ys -- zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..] ---- -- 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: -- --
-- >>> let f = undefined -- -- >>> zipWith f [] undefined -- [] ---- -- zipWith is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] -- | zip3 takes three lists and returns a list of triples, analogous -- to zip. It is capable of list fusion, but it is restricted to -- its first list argument and its resulting list. zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] -- | The unzip3 function takes a list of triples and returns three -- lists, analogous to unzip. -- --
-- >>> unzip3 [] -- ([],[],[]) -- -- >>> unzip3 [(1, 'a', True), (2, 'b', False)] -- ([1,2],"ab",[True,False]) --unzip3 :: [(a, b, c)] -> ([a], [b], [c]) -- | unzip transforms a list of pairs into a list of first -- components and a list of second components. -- --
-- >>> unzip [] -- ([],[]) -- -- >>> unzip [(1, 'a'), (2, 'b')] -- ([1,2],"ab") --unzip :: [(a, b)] -> ([a], [b]) -- | 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] -- | 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] -- | <math>. Extract the elements after the head of a list, which -- must be non-empty. -- --
-- >>> tail [1, 2, 3] -- [2,3] -- -- >>> tail [1] -- [] -- -- >>> tail [] -- *** Exception: Prelude.tail: empty list --tail :: [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])
-- | 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]) -- | <math>. scanr1 is a variant of scanr that has no -- starting value argument. -- --
-- >>> scanr1 (+) [1..4] -- [10,9,7,4] -- -- >>> scanr1 (+) [] -- [] -- -- >>> scanr1 (-) [1..4] -- [-2,3,-1,4] -- -- >>> scanr1 (&&) [True, False, True, True] -- [False,False,True,True] -- -- >>> scanr1 (||) [True, True, False, False] -- [True,True,False,False] -- -- >>> force $ scanr1 (+) [1..] -- *** Exception: stack overflow --scanr1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanr is the right-to-left dual of scanl. -- Note that the order of parameters on the accumulating function are -- reversed compared to scanl. Also note that -- --
-- head (scanr f z xs) == foldr f z xs. ---- --
-- >>> scanr (+) 0 [1..4] -- [10,9,7,4,0] -- -- >>> scanr (+) 42 [] -- [42] -- -- >>> scanr (-) 100 [1..4] -- [98,-97,99,-96,100] -- -- >>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] -- ["abcdfoo","bcdfoo","cdfoo","dfoo","foo"] -- -- >>> force $ scanr (+) 0 [1..] -- *** Exception: stack overflow --scanr :: (a -> b -> b) -> b -> [a] -> [b] -- | <math>. scanl1 is a variant of scanl that has no -- starting value argument: -- --
-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...] ---- --
-- >>> scanl1 (+) [1..4] -- [1,3,6,10] -- -- >>> scanl1 (+) [] -- [] -- -- >>> scanl1 (-) [1..4] -- [1,-1,-4,-8] -- -- >>> scanl1 (&&) [True, False, True, True] -- [True,False,False,False] -- -- >>> scanl1 (||) [False, False, True, True] -- [False,False,True,True] -- -- >>> scanl1 (+) [1..] -- * Hangs forever * --scanl1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanl is similar to foldl, but returns a -- list of successive reduced values from the left: -- --
-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...] ---- -- Note that -- --
-- last (scanl f z xs) == foldl f z xs ---- --
-- >>> scanl (+) 0 [1..4] -- [0,1,3,6,10] -- -- >>> scanl (+) 42 [] -- [42] -- -- >>> scanl (-) 100 [1..4] -- [100,99,97,94,90] -- -- >>> scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] -- ["foo","afoo","bafoo","cbafoo","dcbafoo"] -- -- >>> scanl (+) 0 [1..] -- * Hangs forever * --scanl :: (b -> a -> b) -> b -> [a] -> [b] -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. -- --
-- >>> reverse [] -- [] -- -- >>> reverse [42] -- [42] -- -- >>> reverse [2,5,7] -- [7,5,2] -- -- >>> reverse [1..] -- * Hangs forever * --reverse :: [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 0 True -- [] -- -- >>> replicate (-1) True -- [] -- -- >>> replicate 4 True -- [True,True,True,True] --replicate :: Int -> a -> [a] -- | repeat x is an infinite list, with x the -- value of every element. -- --
-- >>> take 20 $ repeat 17 -- [17,17,17,17,17,17,17,17,17... --repeat :: a -> [a] -- | <math>. lookup key assocs looks up a key in an -- association list. -- --
-- >>> lookup 2 [] -- Nothing -- -- >>> lookup 2 [(1, "first")] -- Nothing -- -- >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] -- Just "second" --lookup :: Eq a => a -> [(a, b)] -> Maybe b -- | <math>. Extract the last element of a list, which must be finite -- and non-empty. -- --
-- >>> last [1, 2, 3] -- 3 -- -- >>> last [1..] -- * Hangs forever * -- -- >>> last [] -- *** Exception: Prelude.last: empty list --last :: [a] -> a -- | iterate f x returns an infinite list of repeated -- applications of f to x: -- --
-- iterate f x == [x, f x, f (f x), ...] ---- -- Note that iterate is lazy, potentially leading to thunk -- build-up if the consumer doesn't force each iterate. See -- iterate' for a strict variant of this function. -- --
-- >>> take 10 $ iterate not True -- [True,False,True,False... -- -- >>> take 10 $ iterate (+3) 42 -- [42,45,48,51,54,57,60,63... --iterate :: (a -> a) -> a -> [a] -- | <math>. Return all the elements of a list except the last one. -- The list must be non-empty. -- --
-- >>> init [1, 2, 3] -- [1,2] -- -- >>> init [1] -- [] -- -- >>> init [] -- *** Exception: Prelude.init: empty list --init :: [a] -> [a] -- | <math>. Extract the first element of a list, which must be -- non-empty. -- --
-- >>> head [1, 2, 3] -- 1 -- -- >>> head [1..] -- 1 -- -- >>> head [] -- *** Exception: Prelude.head: empty list --head :: [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] -- | 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] -- | cycle ties a finite list into a circular one, or equivalently, -- the infinite repetition of the original list. It is the identity on -- infinite lists. -- --
-- >>> cycle [] -- *** Exception: Prelude.cycle: empty list -- -- >>> take 20 $ cycle [42] -- [42,42,42,42,42,42,42,42,42,42... -- -- >>> take 20 $ cycle [2, 5, 7] -- [2,5,7,2,5,7,2,5,7,2,5,7... --cycle :: [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]) -- | List index (subscript) operator, starting from 0. It is an instance of -- the more general genericIndex, which takes an index of any -- integral type. -- --
-- >>> ['a', 'b', 'c'] !! 0 -- 'a' -- -- >>> ['a', 'b', 'c'] !! 2 -- 'c' -- -- >>> ['a', 'b', 'c'] !! 3 -- *** Exception: Prelude.!!: index too large -- -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index --(!!) :: [a] -> Int -> a infixl 9 !! -- | The maybeToList function returns an empty list when given -- Nothing or a singleton list when given Just. -- --
-- >>> 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 maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. -- --
-- >>> maybe False odd (Just 3) -- True ---- --
-- >>> maybe False odd Nothing -- False ---- -- Read an integer from a string using readMaybe. If we succeed, -- return twice the integer; that is, apply (*2) to it. If -- instead we fail to parse an integer, return 0 by default: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> maybe 0 (*2) (readMaybe "5") -- 10 -- -- >>> maybe 0 (*2) (readMaybe "") -- 0 ---- -- Apply show to a Maybe Int. If we have Just n, -- we want to show the underlying Int n. But if we have -- Nothing, we return the empty string instead of (for example) -- "Nothing": -- --
-- >>> maybe "" show (Just 5) -- "5" -- -- >>> maybe "" show Nothing -- "" --maybe :: b -> (a -> b) -> Maybe a -> b -- | 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. -- --
-- >>> 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] -- | The listToMaybe function returns Nothing on an empty -- list or Just a where a is the first element -- of the list. -- --
-- >>> 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 isNothing function returns True iff its argument is -- Nothing. -- --
-- >>> 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 isJust function returns True iff its argument is of -- the form Just _. -- --
-- >>> 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 fromMaybe function takes a default value and a Maybe -- value. If the Maybe is Nothing, it returns the default -- value; otherwise, it returns the value contained in the Maybe. -- --
-- >>> 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 fromJust function extracts the element out of a Just -- and throws an error if its argument is Nothing. -- --
-- >>> fromJust (Just 1) -- 1 ---- --
-- >>> 2 * (fromJust (Just 10)) -- 20 ---- --
-- >>> 2 * (fromJust Nothing) -- *** Exception: Maybe.fromJust: Nothing -- ... --fromJust :: HasCallStack => Maybe a -> a -- | The catMaybes function takes a list of Maybes and -- returns a list of all the Just values. -- --
-- >>> 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] -- | & 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 & -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- --
-- >>> 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 () -- | Flipped version of <$>. -- --
-- (<&>) = flip fmap ---- --
-- >>> Just 2 <&> (+1) -- Just 3 ---- --
-- >>> [1,2,3] <&> (+1) -- [2,3,4] ---- --
-- >>> Right 3 <&> (+1) -- Right 4 --(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> -- | uncurry converts a curried function to a function on pairs. -- --
-- >>> uncurry (+) (1,2) -- 3 ---- --
-- >>> uncurry ($) (show, 1) -- "1" ---- --
-- >>> map (uncurry max) [(1,2), (3,4), (6,8)] -- [2,4,8] --uncurry :: (a -> b -> c) -> (a, b) -> c -- | curry converts an uncurried function to a curried function. -- --
-- >>> curry fst 1 2 -- 1 --curry :: ((a, b) -> c) -> a -> b -> c -- | the same as flip (-). -- -- Because - is treated specially in the Haskell grammar, -- (- e) is not a section, but an application of -- prefix negation. However, (subtract -- exp) is equivalent to the disallowed section. subtract :: Num a => a -> a -> a -- | 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 () -- | until p f yields the result of applying f -- until p holds. until :: (a -> Bool) -> (a -> a) -> a -> a -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right. For example, -- --
-- liftM2 (+) [0,1] [0,2] = [0,2,1,3] -- liftM2 (+) (Just 1) Nothing = Nothing --liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
-- >>> flip (++) "hello" "world" -- "worldhello" --flip :: (a -> b -> c) -> b -> a -> c -- | 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 -- | In many situations, the liftM operations can be replaced by -- uses of ap, which promotes function application. -- --
-- return f `ap` x1 `ap` ... `ap` xn ---- -- is equivalent to -- --
-- liftMn f x1 x2 ... xn --ap :: Monad m => m (a -> b) -> m a -> m b -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | Strict (call-by-value) application operator. It takes a function and -- an argument, evaluates the argument to weak head normal form (WHNF), -- then calls the function with that value. ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $! -- | A special case of error. It is expected that compilers will -- recognize this and insert error messages which are more appropriate to -- the context in which undefined appears. undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a -- | A variant of error that does not produce a stack trace. errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a -- | error stops execution and displays an error message. error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a -- | 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 -- | Boolean "and", lazy in the second argument (&&) :: Bool -> Bool -> Bool infixr 3 && -- | Boolean "not" not :: Bool -> Bool -- | Boolean "or", lazy in the second argument (||) :: Bool -> Bool -> Bool infixr 2 || -- | A CI s provides Case Insensitive comparison for -- the string-like type s (for example: String, -- Text, ByteString, etc.). -- -- Note that CI s has an instance for IsString which -- together with the OverloadedStrings language extension allows -- you to write case insensitive string literals as in: -- --
-- > ("Content-Type" :: CI Text) == ("CONTENT-TYPE" :: CI Text)
-- True
--
data CI s
-- | A Monad which allows for safe resource allocation. In theory,
-- any monad transformer stack which includes a ResourceT can be
-- an instance of MonadResource.
--
-- Note: runResourceT has a requirement for a MonadUnliftIO
-- m monad, which allows control operations to be lifted. A
-- MonadResource does not have this requirement. This means that
-- transformers such as ContT can be an instance of
-- MonadResource. However, the ContT wrapper will need
-- to be unwrapped before calling runResourceT.
--
-- Since 0.3.0
class MonadIO m => MonadResource (m :: Type -> Type)
-- | The class of monad transformers. Instances should satisfy the
-- following laws, which state that lift is a monad
-- transformation:
--
--
class MonadTrans (t :: Type -> Type -> Type -> Type)
-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a
-- | This is a length of time, as measured by a clock. Conversion functions
-- such as fromInteger and realToFrac will treat it as
-- seconds. For example, (0.010 :: DiffTime) corresponds to 10
-- milliseconds.
--
-- It has a precision of one picosecond (= 10^-12 s). Enumeration
-- functions will treat it as picoseconds.
data DiffTime
-- | A class of types that can be fully evaluated.
class NFData a
-- | rnf should reduce its argument to normal form (that is, fully
-- evaluate all sub-components), and then return ().
--
--
-- {-# LANGUAGE DeriveGeneric #-}
--
-- import GHC.Generics (Generic, Generic1)
-- import Control.DeepSeq
--
-- data Foo a = Foo a String
-- deriving (Eq, Generic, Generic1)
--
-- instance NFData a => NFData (Foo a)
-- instance NFData1 Foo
--
-- data Colour = Red | Green | Blue
-- deriving Generic
--
-- instance NFData Colour
--
--
-- Starting with GHC 7.10, the example above can be written more
-- concisely by enabling the new DeriveAnyClass extension:
--
--
-- {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
--
-- import GHC.Generics (Generic)
-- import Control.DeepSeq
--
-- data Foo a = Foo a String
-- deriving (Eq, Generic, Generic1, NFData, NFData1)
--
-- data Colour = Red | Green | Blue
-- deriving (Generic, NFData)
--
--
-- -- rnf a = seq a () ---- -- However, starting with deepseq-1.4.0.0, the default -- implementation is based on DefaultSignatures allowing for -- more accurate auto-derived NFData instances. If you need the -- previously used exact default rnf method implementation -- semantics, use -- --
-- instance NFData Colour where rnf x = seq x () ---- -- or alternatively -- --
-- instance NFData Colour where rnf = rwhnf ---- -- or -- --
-- {-# LANGUAGE BangPatterns #-}
-- instance NFData Colour where rnf !_ = ()
--
rnf :: NFData a => a -> ()
-- | A set of values. A set cannot contain duplicate values.
data HashSet a
-- | -- type Lens' = Simple Lens --type Lens' s a = Lens s s a a -- |
-- type Traversal' = Simple Traversal --type Traversal' s a = Traversal s s a a -- | A Setter' is just a Setter that doesn't change the -- types. -- -- These are particularly common when talking about monomorphic -- containers. e.g. -- --
-- sets Data.Text.map :: Setter' Text Char ---- --
-- type Setter' = Simple Setter --type Setter' s a = Setter s s a a -- |
-- type Iso' = Simple Iso --type Iso' s a = Iso s s a a -- | A Simple Prism. type Prism' s a = Prism s s a a -- | This is a length of time, as measured by UTC. It has a precision of -- 10^-12 s. -- -- Conversion functions such as fromInteger and realToFrac -- will treat it as seconds. For example, (0.010 :: -- NominalDiffTime) corresponds to 10 milliseconds. -- -- It has a precision of one picosecond (= 10^-12 s). Enumeration -- functions will treat it as picoseconds. -- -- 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 -- | The Modified Julian Day is a standard count of days, with zero being -- the day 1858-11-17. data Day type TextLazy = Text type TextBuilder = Builder type ByteStringLazy = ByteString type ByteStringBuilder = Builder module Amazonka.Crypto type Key = ByteString hmacSHA1 :: ByteArrayAccess a => Key -> a -> HMAC SHA1 hmacSHA256 :: ByteArrayAccess a => Key -> a -> HMAC SHA256 hashSHA1 :: ByteArrayAccess a => a -> Digest SHA1 hashSHA256 :: ByteArrayAccess a => a -> Digest SHA256 hashMD5 :: ByteArrayAccess a => a -> Digest MD5 -- | Hash a strict bytestring into a digest. hash :: (ByteArrayAccess ba, HashAlgorithm a) => ba -> Digest a -- | Incrementally calculate a SHA256 Digest. sinkSHA256 :: Monad m => ConduitM ByteString o m (Digest SHA256) -- | Incrementally calculate a MD5 Digest. sinkMD5 :: Monad m => ConduitM ByteString o m (Digest MD5) -- | Class representing hashing algorithms. -- -- The interface presented here is update in place and lowlevel. the Hash -- module takes care of hidding the mutable interface properly. class HashAlgorithm a -- | Represent a digest for a given hash algorithm. -- -- This type is an instance of ByteArrayAccess from package -- memory. Module Data.ByteArray provides many primitives -- to work with those values including conversion to other types. -- -- Creating a digest from a bytearray is also possible with function -- digestFromByteString. data Digest a -- | SHA256 cryptographic hash algorithm data SHA256 -- | MD5 cryptographic hash algorithm data MD5 module Amazonka.Bytes -- | Convert a bytearray to another type of bytearray convert :: (ByteArrayAccess bin, ByteArray bout) => bin -> bout encodeBase16 :: ByteArrayAccess a => a -> ByteString decodeBase16 :: ByteArrayAccess a => a -> Either String ByteString encodeBase64 :: ByteArrayAccess a => a -> ByteString decodeBase64 :: ByteArrayAccess a => a -> Either String ByteString module Amazonka.Data.Text -- | A space efficient, packed, unboxed Unicode text type. data Text class FromText a fromText :: FromText a => Text -> Either String a class ToText a toText :: ToText a => a -> Text toTextCI :: ToText a => a -> CI Text showText :: ToText a => a -> String instance Amazonka.Data.Text.ToText a => Amazonka.Data.Text.ToText (Data.CaseInsensitive.Internal.CI a) instance Amazonka.Data.Text.ToText Data.Text.Internal.Text instance Amazonka.Data.Text.ToText Data.ByteString.Internal.ByteString instance Amazonka.Data.Text.ToText GHC.Types.Char instance Amazonka.Data.Text.ToText GHC.Base.String instance Amazonka.Data.Text.ToText GHC.Types.Int instance Amazonka.Data.Text.ToText GHC.Int.Int64 instance Amazonka.Data.Text.ToText GHC.Num.Integer.Integer instance Amazonka.Data.Text.ToText GHC.Num.Natural.Natural instance Amazonka.Data.Text.ToText Data.Scientific.Scientific instance Amazonka.Data.Text.ToText GHC.Types.Double instance Amazonka.Data.Text.ToText Network.HTTP.Types.Method.StdMethod instance Amazonka.Data.Text.ToText (Crypto.Hash.Types.Digest a) instance Amazonka.Data.Text.ToText GHC.Types.Bool instance Amazonka.Data.Text.FromText Data.Text.Internal.Text instance Amazonka.Data.Text.FromText GHC.Base.String instance Amazonka.Data.Text.FromText Data.ByteString.Internal.ByteString instance (Data.CaseInsensitive.Internal.FoldCase a, Amazonka.Data.Text.FromText a) => Amazonka.Data.Text.FromText (Data.CaseInsensitive.Internal.CI a) instance Amazonka.Data.Text.FromText GHC.Types.Char instance Amazonka.Data.Text.FromText GHC.Types.Int instance Amazonka.Data.Text.FromText GHC.Int.Int64 instance Amazonka.Data.Text.FromText GHC.Num.Integer.Integer instance Amazonka.Data.Text.FromText Data.Scientific.Scientific instance Amazonka.Data.Text.FromText GHC.Num.Natural.Natural instance Amazonka.Data.Text.FromText GHC.Types.Double instance Amazonka.Data.Text.FromText GHC.Types.Bool instance Amazonka.Data.Text.FromText Network.HTTP.Types.Method.StdMethod module Amazonka.Data.JSON -- | 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: -- --
-- -- 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: -- --
-- {-# LANGUAGE DeriveGeneric #-}
--
-- import GHC.Generics
--
-- data Coord = Coord { x :: Double, y :: Double } deriving Generic
--
-- instance FromJSON Coord
--
--
-- or using the DerivingVia extension
--
-- -- deriving via Generically Coord 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
parseJSONList :: FromJSON a => Value -> Parser [a]
-- | Read the docs for ToJSONKey first. This class is a conversion
-- in the opposite direction. If you have a newtype wrapper around
-- Text, the recommended way to define instances is with
-- generalized newtype deriving:
--
--
-- newtype SomeId = SomeId { getSomeId :: Text }
-- deriving (Eq,Ord,Hashable,FromJSONKey)
--
--
-- If you have a sum of nullary constructors, you may use the generic
-- implementation:
--
-- -- data Color = Red | Green | Blue -- deriving Generic -- -- instance FromJSONKey Color where -- fromJSONKey = genericFromJSONKey defaultJSONKeyOptions --class FromJSONKey a -- | Strategy for parsing the key of a map-like container. fromJSONKey :: FromJSONKey a => FromJSONKeyFunction a -- | This is similar in spirit to the readList method of -- Read. It makes it possible to give Value keys special -- treatment without using OverlappingInstances. End users -- should always be able to use the default implementation of this -- method. fromJSONKeyList :: FromJSONKey a => FromJSONKeyFunction [a] parseJSONText :: FromText a => String -> Value -> Parser a -- | Like decode but returns an error message when decoding fails. eitherDecode :: FromJSON a => ByteString -> Either String a -- | Like decode' but returns an error message when decoding fails. eitherDecode' :: FromJSON a => ByteString -> Either String a -- | withObject name f value applies f to the -- Object when value is an Object and fails -- otherwise. -- --
-- withObject "MyType" f (String "oops") -- -- Error: "parsing MyType failed, expected Object, but encountered String" --withObject :: String -> (Object -> Parser a) -> Value -> Parser 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 -> Key -> 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 -> Key -> Parser (Maybe a) -- | 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 eitherParseJSON :: FromJSON a => Object -> Either String a (.:>) :: FromJSON a => Object -> Key -> Either String a (.?>) :: FromJSON a => Object -> Key -> Either String (Maybe a) -- | 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:
--
--
-- {-# LANGUAGE DeriveGeneric #-}
--
-- import GHC.Generics
--
-- data Coord = Coord { x :: Double, y :: Double } deriving Generic
--
-- instance ToJSON Coord where
-- toEncoding = genericToEncoding defaultOptions
--
--
-- or more conveniently using the DerivingVia extension
--
-- -- deriving via Generically Coord instance ToJSON Coord ---- -- 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:
--
-- -- instance ToJSON Coord where -- toEncoding = genericToEncoding defaultOptions --toEncoding :: ToJSON a => a -> Encoding toJSONList :: ToJSON a => [a] -> Value toEncodingList :: ToJSON a => [a] -> Encoding -- | Typeclass for types that can be used as the key of a map-like -- container (like Map or HashMap). For example, since -- Text has a ToJSONKey instance and Char has a -- ToJSON instance, we can encode a value of type Map -- Text Char: -- --
-- >>> LBC8.putStrLn $ encode $ Map.fromList [("foo" :: Text, 'a')]
-- {"foo":"a"}
--
--
-- Since Int also has a ToJSONKey instance, we can
-- similarly write:
--
--
-- >>> LBC8.putStrLn $ encode $ Map.fromList [(5 :: Int, 'a')]
-- {"5":"a"}
--
--
-- JSON documents only accept strings as object keys. For any type from
-- base that has a natural textual representation, it can be
-- expected that its ToJSONKey instance will choose that
-- representation.
--
-- For data types that lack a natural textual representation, an
-- alternative is provided. The map-like container is represented as a
-- JSON array instead of a JSON object. Each value in the array is an
-- array with exactly two values. The first is the key and the second is
-- the value.
--
-- For example, values of type '[Text]' cannot be encoded to a string, so
-- a Map with keys of type '[Text]' is encoded as follows:
--
-- -- >>> LBC8.putStrLn $ encode $ Map.fromList [(["foo","bar","baz" :: Text], 'a')] -- [[["foo","bar","baz"],"a"]] ---- -- The default implementation of ToJSONKey chooses this method of -- encoding a key, using the ToJSON instance of the type. -- -- To use your own data type as the key in a map, all that is needed is -- to write a ToJSONKey (and possibly a FromJSONKey) -- instance for it. If the type cannot be trivially converted to and from -- Text, it is recommended that ToJSONKeyValue is used. -- Since the default implementations of the typeclass methods can build -- this from a ToJSON instance, there is nothing that needs to be -- written: -- --
-- data Foo = Foo { fooAge :: Int, fooName :: Text }
-- deriving (Eq,Ord,Generic)
-- instance ToJSON Foo
-- instance ToJSONKey Foo
--
--
-- That's it. We can now write:
--
--
-- >>> let m = Map.fromList [(Foo 4 "bar",'a'),(Foo 6 "arg",'b')]
--
-- >>> LBC8.putStrLn $ encode m
-- [[{"fooName":"bar","fooAge":4},"a"],[{"fooName":"arg","fooAge":6},"b"]]
--
--
-- The next case to consider is if we have a type that is a newtype
-- wrapper around Text. The recommended approach is to use
-- generalized newtype deriving:
--
--
-- newtype RecordId = RecordId { getRecordId :: Text }
-- deriving (Eq,Ord,ToJSONKey)
--
--
-- Then we may write:
--
--
-- >>> LBC8.putStrLn $ encode $ Map.fromList [(RecordId "abc",'a')]
-- {"abc":"a"}
--
--
-- Simple sum types are a final case worth considering. Suppose we have:
--
-- -- data Color = Red | Green | Blue -- deriving (Show,Read,Eq,Ord) ---- -- It is possible to get the ToJSONKey instance for free as we did -- with Foo. However, in this case, we have a natural way to go -- to and from Text that does not require any escape sequences. So -- ToJSONKeyText can be used instead of ToJSONKeyValue to -- encode maps as objects instead of arrays of pairs. This instance may -- be implemented using generics as follows: -- --
-- instance ToJSONKey Color where -- toJSONKey = genericToJSONKey defaultJSONKeyOptions ---- --
-- instance ToJSONKey Color where -- toJSONKey = ToJSONKeyText f g -- where f = Text.pack . show -- g = text . Text.pack . show -- -- text function is from Data.Aeson.Encoding ---- -- The situation of needing to turning function a -> Text -- into a ToJSONKeyFunction is common enough that a special -- combinator is provided for it. The above instance can be rewritten as: -- --
-- instance ToJSONKey Color where -- toJSONKey = toJSONKeyText (Text.pack . show) ---- -- The performance of the above instance can be improved by not using -- Value as an intermediate step when converting to Text. -- One option for improving performance would be to use template haskell -- machinery from the text-show package. However, even with the -- approach, the Encoding (a wrapper around a bytestring builder) -- is generated by encoding the Text to a ByteString, an -- intermediate step that could be avoided. The fastest possible -- implementation would be: -- --
-- -- Assuming that OverloadedStrings is enabled
-- instance ToJSONKey Color where
-- toJSONKey = ToJSONKeyText f g
-- where f x = case x of {Red -> "Red";Green ->"Green";Blue -> "Blue"}
-- g x = case x of {Red -> text "Red";Green -> text "Green";Blue -> text "Blue"}
-- -- text function is from Data.Aeson.Encoding
--
--
-- This works because GHC can lift the encoded values out of the case
-- statements, which means that they are only evaluated once. This
-- approach should only be used when there is a serious need to maximize
-- performance.
class ToJSONKey a
-- | Strategy for rendering the key for a map-like container.
toJSONKey :: ToJSONKey a => ToJSONKeyFunction a
-- | This is similar in spirit to the showsList method of
-- Show. It makes it possible to give Value keys special
-- treatment without using OverlappingInstances. End users
-- should always be able to use the default implementation of this
-- method.
toJSONKeyList :: ToJSONKey a => ToJSONKeyFunction [a]
toJSONText :: ToText a => a -> Value
-- | A JSON value represented as a Haskell value.
data Value
Object :: !Object -> Value
-- | Create a Value from a list of name/value Pairs. If
-- duplicate keys arise, later keys and their associated values win.
object :: [Pair] -> Value
(.=) :: (KeyValue kv, ToJSON v) => Key -> v -> kv
infixr 8 .=
module Amazonka.Data.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
type ByteStringLazy = ByteString
class ToByteString a
toBS :: ToByteString a => a -> ByteString
toBS :: (ToByteString a, ToText a) => a -> ByteString
showBS :: ToByteString a => a -> String
stripBS :: ByteString -> ByteString
instance Amazonka.Data.ByteString.ToByteString Data.ByteString.Internal.ByteString
instance Amazonka.Data.ByteString.ToByteString Amazonka.Prelude.ByteStringBuilder
instance Amazonka.Data.ByteString.ToByteString Amazonka.Prelude.ByteStringLazy
instance Amazonka.Data.ByteString.ToByteString Data.Text.Internal.Text
instance Amazonka.Data.ByteString.ToByteString GHC.Base.String
instance Amazonka.Data.ByteString.ToByteString GHC.Types.Int
instance Amazonka.Data.ByteString.ToByteString GHC.Num.Integer.Integer
instance Amazonka.Data.ByteString.ToByteString GHC.Num.Natural.Natural
instance Amazonka.Data.ByteString.ToByteString GHC.Types.Double
instance Amazonka.Data.ByteString.ToByteString Network.HTTP.Types.Method.StdMethod
instance Amazonka.Data.ByteString.ToByteString Data.Time.Clock.Internal.UTCTime.UTCTime
instance Amazonka.Data.ByteString.ToByteString a => Amazonka.Data.ByteString.ToByteString (Data.CaseInsensitive.Internal.CI a)
module Amazonka.Data.XML
(.@) :: FromXML a => [Node] -> Text -> Either String a
infixl 7 .@
(.@?) :: FromXML a => [Node] -> Text -> Either String (Maybe a)
infixl 7 .@?
(@=) :: ToXML a => Name -> a -> XML
infixr 7 @=
(@@=) :: ToText a => Name -> a -> XML
infixr 7 @@=
decodeXML :: FromXML a => ByteStringLazy -> Either String a
encodeXML :: ToElement a => a -> ByteStringLazy
class FromXML a
parseXML :: FromXML a => [Node] -> Either String a
class ToElement a
toElement :: ToElement a => a -> Element
-- | Convert to an Element, only if the resulting element contains
-- > 0 nodes.
maybeElement :: ToElement a => a -> Maybe Element
-- | Provides a way to make the operators for ToXML instance declaration be
-- consistent WRT to single nodes or lists of nodes.
data XML
XNull :: XML
XAttr :: Name -> Text -> XML
XOne :: Node -> XML
XMany :: [(Name, Text)] -> [Node] -> XML
listXMLNodes :: XML -> [Node]
listXMLAttributes :: XML -> [(Name, Text)]
class ToXML a
toXML :: ToXML a => a -> XML
parseXMLMap :: (Eq k, Hashable k, FromText k, FromXML v) => Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
parseXMLList1 :: FromXML a => Text -> [Node] -> Either String (NonEmpty a)
parseXMLList :: FromXML a => Text -> [Node] -> Either String [a]
parseXMLText :: FromText a => String -> [Node] -> Either String a
toXMLList :: (IsList a, ToXML (Item a)) => Name -> a -> XML
toXMLText :: ToText a => a -> XML
mkElement :: ToXML a => Name -> a -> Element
withContent :: String -> [Node] -> Either String (Maybe Text)
-- | Find a specific named NodeElement, at the current depth in the node
-- tree.
--
-- Fails if absent.
findElement :: Text -> [Node] -> Either String [Node]
-- | Find the first specific named NodeElement, at any depth in the node
-- tree.
--
-- Fails if absent.
firstElement :: Text -> [Node] -> Either String [Node]
childNodesOf :: Text -> Node -> Maybe [Node]
childrenOf :: Element -> [Node]
localName :: Node -> Maybe Text
-- | An inefficient mechanism for retreiving the root element name of an
-- XML document.
rootElementName :: ByteStringLazy -> Maybe Text
missingElement :: Text -> [Node] -> Maybe a -> Either String a
instance GHC.Show.Show Amazonka.Data.XML.XML
instance Amazonka.Data.XML.ToXML Amazonka.Data.XML.XML
instance Amazonka.Data.XML.ToXML a => Amazonka.Data.XML.ToXML (GHC.Maybe.Maybe a)
instance Amazonka.Data.XML.ToXML Data.Text.Internal.Text
instance Amazonka.Data.XML.ToXML Data.ByteString.Internal.ByteString
instance Amazonka.Data.XML.ToXML GHC.Types.Int
instance Amazonka.Data.XML.ToXML GHC.Num.Integer.Integer
instance Amazonka.Data.XML.ToXML GHC.Num.Natural.Natural
instance Amazonka.Data.XML.ToXML GHC.Types.Double
instance Amazonka.Data.XML.ToXML GHC.Types.Bool
instance GHC.Base.Semigroup Amazonka.Data.XML.XML
instance GHC.Base.Monoid Amazonka.Data.XML.XML
instance Amazonka.Data.XML.ToElement Text.XML.Element
instance Amazonka.Data.XML.FromXML [Text.XML.Node]
instance Amazonka.Data.XML.FromXML a => Amazonka.Data.XML.FromXML (GHC.Maybe.Maybe a)
instance Amazonka.Data.XML.FromXML Data.Text.Internal.Text
instance Amazonka.Data.XML.FromXML GHC.Types.Char
instance Amazonka.Data.XML.FromXML Data.ByteString.Internal.ByteString
instance Amazonka.Data.XML.FromXML GHC.Types.Int
instance Amazonka.Data.XML.FromXML GHC.Num.Integer.Integer
instance Amazonka.Data.XML.FromXML GHC.Num.Natural.Natural
instance Amazonka.Data.XML.FromXML GHC.Types.Double
instance Amazonka.Data.XML.FromXML GHC.Types.Bool
module Amazonka.Data.Query
-- | Structured representation of a query string.
--
-- Some operations (e.g., sqs:CreateQueue) use query parameters to
-- pass structured data like lists and maps, which is why this type is
-- more complicatated than the [(ByteString, Maybe ByteString)]
-- from http-types that you may have expected here.
data QueryString
QList :: [QueryString] -> QueryString
QPair :: ByteString -> QueryString -> QueryString
QValue :: Maybe ByteString -> QueryString
parseQueryString :: ByteString -> QueryString
pair :: ToQuery a => ByteString -> a -> QueryString -> QueryString
(=:) :: ToQuery a => ByteString -> a -> QueryString
infixr 7 =:
toQueryList :: (IsList a, ToQuery (Item a)) => ByteString -> a -> QueryString
toQueryMap :: (ToQuery k, ToQuery v) => ByteString -> ByteString -> ByteString -> HashMap k v -> QueryString
class ToQuery a
toQuery :: ToQuery a => a -> QueryString
toQuery :: (ToQuery a, ToText a) => a -> QueryString
instance GHC.Show.Show Amazonka.Data.Query.QueryString
instance GHC.Classes.Eq Amazonka.Data.Query.QueryString
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Query.QueryString
instance (Amazonka.Data.ByteString.ToByteString k, Amazonka.Data.Query.ToQuery v) => Amazonka.Data.Query.ToQuery (k, v)
instance Amazonka.Data.Query.ToQuery GHC.Types.Char
instance Amazonka.Data.Query.ToQuery Data.ByteString.Internal.ByteString
instance Amazonka.Data.Query.ToQuery Data.Text.Internal.Text
instance Amazonka.Data.Query.ToQuery GHC.Types.Int
instance Amazonka.Data.Query.ToQuery GHC.Num.Integer.Integer
instance Amazonka.Data.Query.ToQuery GHC.Types.Double
instance Amazonka.Data.Query.ToQuery GHC.Num.Natural.Natural
instance Amazonka.Data.Query.ToQuery a => Amazonka.Data.Query.ToQuery (GHC.Maybe.Maybe a)
instance Amazonka.Data.Query.ToQuery GHC.Types.Bool
instance GHC.Base.Semigroup Amazonka.Data.Query.QueryString
instance GHC.Base.Monoid Amazonka.Data.Query.QueryString
instance Data.String.IsString Amazonka.Data.Query.QueryString
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Query.QueryString
module Amazonka.Data.Time
data Format
RFC822Format :: Format
ISO8601Format :: Format
BasicFormat :: Format
AWSFormat :: Format
POSIXFormat :: Format
newtype Time (a :: Format)
Time :: UTCTime -> Time (a :: Format)
[$sel:fromTime:Time] :: Time (a :: Format) -> UTCTime
_Time :: Iso' (Time a) UTCTime
-- | 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
type RFC822 = Time 'RFC822Format
type ISO8601 = Time 'ISO8601Format
type BasicTime = Time 'BasicFormat
type AWSTime = Time 'AWSFormat
type POSIX = Time 'POSIXFormat
instance GHC.Generics.Generic Amazonka.Data.Time.Format
instance GHC.Show.Show Amazonka.Data.Time.Format
instance GHC.Read.Read Amazonka.Data.Time.Format
instance GHC.Classes.Eq Amazonka.Data.Time.Format
instance Control.DeepSeq.NFData (Amazonka.Data.Time.Time a)
instance GHC.Generics.Generic (Amazonka.Data.Time.Time a)
instance GHC.Classes.Ord (Amazonka.Data.Time.Time a)
instance GHC.Classes.Eq (Amazonka.Data.Time.Time a)
instance GHC.Read.Read (Amazonka.Data.Time.Time a)
instance GHC.Show.Show (Amazonka.Data.Time.Time a)
instance Amazonka.Data.Time.TimeFormat Amazonka.Data.Time.RFC822
instance Amazonka.Data.Time.TimeFormat Amazonka.Data.Time.ISO8601
instance Amazonka.Data.Time.TimeFormat Amazonka.Data.Time.BasicTime
instance Amazonka.Data.Time.TimeFormat Amazonka.Data.Time.AWSTime
instance Amazonka.Data.Text.ToText Amazonka.Data.Time.POSIX
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Time.POSIX
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Time.POSIX
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Time.POSIX
instance Amazonka.Data.Text.ToText Amazonka.Data.Time.AWSTime
instance Amazonka.Data.XML.FromXML Amazonka.Data.Time.AWSTime
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Time.AWSTime
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Time.AWSTime
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Time.AWSTime
instance Amazonka.Data.XML.ToXML Amazonka.Data.Time.AWSTime
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Time.AWSTime
instance Amazonka.Data.Text.ToText Amazonka.Data.Time.BasicTime
instance Amazonka.Data.XML.FromXML Amazonka.Data.Time.BasicTime
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Time.BasicTime
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Time.BasicTime
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Time.BasicTime
instance Amazonka.Data.XML.ToXML Amazonka.Data.Time.BasicTime
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Time.BasicTime
instance Amazonka.Data.Text.ToText Amazonka.Data.Time.ISO8601
instance Amazonka.Data.XML.FromXML Amazonka.Data.Time.ISO8601
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Time.ISO8601
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Time.ISO8601
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Time.ISO8601
instance Amazonka.Data.XML.ToXML Amazonka.Data.Time.ISO8601
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Time.ISO8601
instance Amazonka.Data.Text.ToText Amazonka.Data.Time.RFC822
instance Amazonka.Data.XML.FromXML Amazonka.Data.Time.RFC822
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Time.RFC822
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Time.RFC822
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Time.RFC822
instance Amazonka.Data.XML.ToXML Amazonka.Data.Time.RFC822
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Time.RFC822
instance Data.Hashable.Class.Hashable (Amazonka.Data.Time.Time a)
instance Amazonka.Data.Text.FromText (Amazonka.Data.Time.Time fmt)
module Amazonka.Data.Path
data Path :: Encoding -> Type
[Raw] :: [ByteString] -> Path 'NoEncoding
[Encoded] :: [ByteString] -> Path 'Percent
type RawPath = Path 'NoEncoding
type EscapedPath = Path 'Percent
-- | Used in SigV4
data TwiceEscapedPath
class ToPath a
toPath :: ToPath a => a -> ByteString
rawPath :: ToPath a => a -> Path 'NoEncoding
escapePath :: Path a -> EscapedPath
-- | Escape a path twice. Used when computing the SigV4 canonical path.
escapePathTwice :: Path a -> TwiceEscapedPath
collapsePath :: Path a -> Path a
instance GHC.Show.Show Amazonka.Data.Path.Encoding
instance GHC.Classes.Eq Amazonka.Data.Path.Encoding
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Path.TwiceEscapedPath
instance GHC.Show.Show Amazonka.Data.Path.TwiceEscapedPath
instance GHC.Classes.Eq Amazonka.Data.Path.TwiceEscapedPath
instance GHC.Show.Show (Amazonka.Data.Path.Path a)
instance GHC.Classes.Eq (Amazonka.Data.Path.Path a)
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Path.EscapedPath
instance GHC.Base.Semigroup Amazonka.Data.Path.RawPath
instance GHC.Base.Monoid Amazonka.Data.Path.RawPath
instance Amazonka.Data.Path.ToPath Data.ByteString.Internal.ByteString
instance Amazonka.Data.Path.ToPath Data.Text.Internal.Text
module Amazonka.Data.Headers
class ToHeader a
toHeader :: ToHeader a => HeaderName -> a -> [Header]
toHeader :: (ToHeader a, ToText a) => HeaderName -> a -> [Header]
class ToHeaders a
toHeaders :: ToHeaders a => a -> [Header]
(.#) :: FromText a => ResponseHeaders -> HeaderName -> Either String a
infixl 7 .#
(.#?) :: FromText a => ResponseHeaders -> HeaderName -> Either String (Maybe a)
infixl 7 .#?
(=#) :: ToHeader a => HeaderName -> a -> [Header]
infixr 7 =#
hdr :: HeaderName -> ByteString -> [Header] -> [Header]
parseHeadersMap :: FromText a => ByteString -> ResponseHeaders -> Either String (HashMap Text a)
hHost :: HeaderName
hExpect :: HeaderName
hAMZToken :: HeaderName
hAMZTarget :: HeaderName
hAMZAlgorithm :: HeaderName
hAMZCredential :: HeaderName
hAMZExpires :: HeaderName
hAMZSignedHeaders :: HeaderName
hAMZContentSHA256 :: HeaderName
hAMZDate :: HeaderName
hMetaPrefix :: HeaderName
hAMZRequestId :: HeaderName
hAMZNRequestId :: HeaderName
hAMZNErrorType :: HeaderName
hAMZNAuth :: HeaderName
hAMZDecodedContentLength :: HeaderName
hTransferEncoding :: HeaderName
hFormEncoded :: ByteString
-- | Header name
type HeaderName = CI ByteString
-- | Header
type Header = (HeaderName, ByteString)
-- | HTTP Header names according to
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hContentType :: HeaderName
instance Amazonka.Data.Headers.ToHeader GHC.Types.Int
instance Amazonka.Data.Headers.ToHeader GHC.Num.Integer.Integer
instance Amazonka.Data.Headers.ToHeader GHC.Num.Natural.Natural
instance Amazonka.Data.Headers.ToHeader Data.Text.Internal.Text
instance Amazonka.Data.Headers.ToHeader Data.ByteString.Internal.ByteString
instance Amazonka.Data.Text.ToText a => Amazonka.Data.Headers.ToHeader (GHC.Maybe.Maybe a)
instance Amazonka.Data.Text.ToText a => Amazonka.Data.Headers.ToHeader [a]
instance (Amazonka.Data.ByteString.ToByteString k, Amazonka.Data.ByteString.ToByteString v) => Amazonka.Data.Headers.ToHeader (Data.HashMap.Internal.HashMap k v)
instance (Amazonka.Data.ByteString.ToByteString k, Amazonka.Data.ByteString.ToByteString v) => Amazonka.Data.Headers.ToHeaders (Data.HashMap.Internal.HashMap k v)
module Amazonka.Data.Log
class ToLog a
-- | Convert a value to a loggable builder.
build :: ToLog a => a -> ByteStringBuilder
-- | Intercalate a list of ByteStringBuilders with newlines.
buildLines :: [ByteStringBuilder] -> ByteStringBuilder
instance Amazonka.Data.Log.ToLog Amazonka.Prelude.ByteStringBuilder
instance Amazonka.Data.Log.ToLog Amazonka.Prelude.ByteStringLazy
instance Amazonka.Data.Log.ToLog Data.ByteString.Internal.ByteString
instance Amazonka.Data.Log.ToLog GHC.Types.Int
instance Amazonka.Data.Log.ToLog GHC.Int.Int8
instance Amazonka.Data.Log.ToLog GHC.Int.Int16
instance Amazonka.Data.Log.ToLog GHC.Int.Int32
instance Amazonka.Data.Log.ToLog GHC.Int.Int64
instance Amazonka.Data.Log.ToLog GHC.Num.Integer.Integer
instance Amazonka.Data.Log.ToLog GHC.Types.Word
instance Amazonka.Data.Log.ToLog GHC.Word.Word8
instance Amazonka.Data.Log.ToLog GHC.Word.Word16
instance Amazonka.Data.Log.ToLog GHC.Word.Word32
instance Amazonka.Data.Log.ToLog GHC.Word.Word64
instance Amazonka.Data.Log.ToLog Data.Time.Clock.Internal.UTCTime.UTCTime
instance Amazonka.Data.Log.ToLog GHC.Types.Float
instance Amazonka.Data.Log.ToLog GHC.Types.Double
instance Amazonka.Data.Log.ToLog Data.Text.Internal.Text
instance Amazonka.Data.Log.ToLog Amazonka.Prelude.TextLazy
instance Amazonka.Data.Log.ToLog GHC.Types.Char
instance Amazonka.Data.Log.ToLog [GHC.Types.Char]
instance Amazonka.Data.Log.ToLog Network.HTTP.Types.Method.StdMethod
instance Amazonka.Data.Log.ToLog Amazonka.Data.Query.QueryString
instance Amazonka.Data.Log.ToLog Amazonka.Data.Path.EscapedPath
instance Amazonka.Data.Log.ToLog a => Amazonka.Data.Log.ToLog (Data.CaseInsensitive.Internal.CI a)
instance Amazonka.Data.Log.ToLog a => Amazonka.Data.Log.ToLog (GHC.Maybe.Maybe a)
instance Amazonka.Data.Log.ToLog GHC.Types.Bool
instance Amazonka.Data.Log.ToLog Network.HTTP.Types.Status.Status
instance Amazonka.Data.Log.ToLog [Network.HTTP.Types.Header.Header]
instance Amazonka.Data.Log.ToLog Network.HTTP.Types.Version.HttpVersion
instance Amazonka.Data.Log.ToLog Network.HTTP.Client.Types.RequestBody
instance Amazonka.Data.Log.ToLog Network.HTTP.Client.Types.HttpException
instance Amazonka.Data.Log.ToLog Network.HTTP.Client.Types.HttpExceptionContent
instance Amazonka.Data.Log.ToLog Network.HTTP.Client.Types.Request
instance Amazonka.Data.Log.ToLog (Network.HTTP.Client.Types.Response a)
module Amazonka.Data.Body
-- | Convenience function for obtaining the size of a file.
getFileSize :: MonadIO m => FilePath -> m Integer
-- | A streaming, exception safe response body.
--
-- newtype for show/orhpan instance purposes.
newtype ResponseBody
ResponseBody :: ConduitM () ByteString (ResourceT IO) () -> ResponseBody
[$sel:body:ResponseBody] :: ResponseBody -> ConduitM () ByteString (ResourceT IO) ()
_ResponseBody :: Iso' ResponseBody (ConduitM () ByteString (ResourceT IO) ())
fuseStream :: ResponseBody -> ConduitM ByteString ByteString (ResourceT IO) () -> ResponseBody
-- | Connect a Sink to a response stream.
sinkBody :: MonadIO m => ResponseBody -> ConduitM ByteString Void (ResourceT IO) a -> m a
-- | Specifies the transmitted size of the 'Transfer-Encoding' chunks.
--
-- See: defaultChunk.
newtype ChunkSize
ChunkSize :: Int -> ChunkSize
_ChunkSize :: Iso' ChunkSize Int
-- | The default chunk size of 128 KB. The minimum chunk size accepted by
-- AWS is 8 KB, unless the entirety of the request is below this
-- threshold.
--
-- A chunk size of 64 KB or higher is recommended for performance
-- reasons.
defaultChunkSize :: ChunkSize
-- | An opaque request body which will be transmitted via
-- Transfer-Encoding: chunked.
--
-- Invariant: Only services that support chunked encoding can
-- accept a ChunkedBody. (Currently S3.) This is enforced by the
-- type signatures emitted by the generator.
data ChunkedBody
ChunkedBody :: ChunkSize -> Integer -> ConduitM () ByteString (ResourceT IO) () -> ChunkedBody
[$sel:size:ChunkedBody] :: ChunkedBody -> ChunkSize
[$sel:length:ChunkedBody] :: ChunkedBody -> Integer
[$sel:body:ChunkedBody] :: ChunkedBody -> ConduitM () ByteString (ResourceT IO) ()
chunkedBody_size :: Lens' ChunkedBody ChunkSize
chunkedBody_length :: Lens' ChunkedBody Integer
chunkedBody_body :: Lens' ChunkedBody (ConduitM () ByteString (ResourceT IO) ())
fuseChunks :: ChunkedBody -> ConduitM ByteString ByteString (ResourceT IO) () -> ChunkedBody
fullChunks :: ChunkedBody -> Integer
remainderBytes :: ChunkedBody -> Maybe Integer
-- | Construct a ChunkedBody from a FilePath, where the
-- contents will be read and signed incrementally in chunks if the target
-- service supports it.
--
-- Will intelligently revert to HashedBody if the file is smaller
-- than the specified ChunkSize.
--
-- See: ToBody.
chunkedFile :: MonadIO m => ChunkSize -> FilePath -> m RequestBody
-- | Construct a ChunkedBody from a FilePath, specifying the
-- range of bytes to read. This can be useful for constructing multiple
-- requests from a single file, say for S3 multipart uploads.
--
-- See: chunkedFile.
chunkedFileRange :: MonadIO m => ChunkSize -> FilePath -> Integer -> Integer -> m RequestBody
-- | Unsafely construct a ChunkedBody.
--
-- This function is marked unsafe because it does nothing to enforce the
-- chunk size. Typically for conduit IO functions, it's whatever
-- ByteString's defaultBufferSize is, around 32 KB. If the chunk
-- size is less than 8 KB, the request will error. 64 KB or higher chunk
-- size is recommended for performance reasons.
--
-- Note that it will always create a chunked body even if the request is
-- too small.
--
-- See: ToBody.
unsafeChunkedBody :: ChunkSize -> Integer -> ConduitM () ByteString (ResourceT IO) () -> RequestBody
sourceFileChunks :: MonadResource m => ChunkSize -> FilePath -> ConduitM () ByteString m ()
sourceFileRangeChunks :: MonadResource m => ChunkSize -> FilePath -> Integer -> Integer -> ConduitM () ByteString m ()
-- | An opaque request body containing a SHA256 hash.
data HashedBody
HashedStream :: Digest SHA256 -> !Integer -> ConduitM () ByteString (ResourceT IO) () -> HashedBody
HashedBytes :: Digest SHA256 -> ByteString -> HashedBody
sha256Base16 :: HashedBody -> ByteString
-- | Construct a HashedBody from a FilePath, calculating the
-- SHA256 hash and file size.
--
-- Note: While this function will perform in constant space, it
-- will enumerate the entirety of the file contents twice. Firstly
-- to calculate the SHA256 and lastly to stream the contents to the
-- socket during sending.
--
-- See: ToHashedBody.
hashedFile :: MonadIO m => FilePath -> m HashedBody
-- | Construct a HashedBody from a FilePath, specifying the
-- range of bytes to read. This can be useful for constructing multiple
-- requests from a single file, say for S3 multipart uploads.
--
-- See: hashedFile, sourceFileRange.
hashedFileRange :: MonadIO m => FilePath -> Integer -> Integer -> m HashedBody
-- | Construct a HashedBody from a Source, manually
-- specifying the SHA256 hash and file size. It's left up to the
-- caller to calculate these correctly, otherwise AWS will return signing
-- errors.
--
-- See: ToHashedBody.
hashedBody :: Digest SHA256 -> Integer -> ConduitM () ByteString (ResourceT IO) () -> HashedBody
-- | Invariant: only services that support both standard and chunked
-- signing expose RequestBody as a parameter.
data RequestBody
-- | Currently S3 only, see ChunkedBody for details.
Chunked :: ChunkedBody -> RequestBody
Hashed :: HashedBody -> RequestBody
md5Base64 :: RequestBody -> Maybe ByteString
isStreaming :: RequestBody -> Bool
toRequestBody :: RequestBody -> RequestBody
contentLength :: RequestBody -> Integer
-- | Anything that can be safely converted to a HashedBody.
class ToHashedBody a
-- | Convert a value to a hashed request body.
toHashed :: ToHashedBody a => a -> HashedBody
-- | Anything that can be converted to a streaming request Body.
class ToBody a
-- | Convert a value to a request body.
toBody :: ToBody a => a -> RequestBody
-- | Convert a value to a request body.
toBody :: (ToBody a, ToHashedBody a) => a -> RequestBody
instance GHC.Generics.Generic Amazonka.Data.Body.ResponseBody
instance GHC.Real.Integral Amazonka.Data.Body.ChunkSize
instance GHC.Real.Real Amazonka.Data.Body.ChunkSize
instance GHC.Num.Num Amazonka.Data.Body.ChunkSize
instance GHC.Enum.Enum Amazonka.Data.Body.ChunkSize
instance GHC.Show.Show Amazonka.Data.Body.ChunkSize
instance GHC.Classes.Ord Amazonka.Data.Body.ChunkSize
instance GHC.Classes.Eq Amazonka.Data.Body.ChunkSize
instance GHC.Show.Show Amazonka.Data.Body.RequestBody
instance Amazonka.Data.Body.ToBody Amazonka.Data.Body.RequestBody
instance Amazonka.Data.Body.ToBody Amazonka.Data.Body.HashedBody
instance Amazonka.Data.Body.ToBody Amazonka.Data.Body.ChunkedBody
instance Amazonka.Data.Body.ToHashedBody a => Amazonka.Data.Body.ToBody (GHC.Maybe.Maybe a)
instance Amazonka.Data.Body.ToBody GHC.Base.String
instance Amazonka.Data.Body.ToBody Amazonka.Prelude.ByteStringLazy
instance Amazonka.Data.Body.ToBody Data.ByteString.Internal.ByteString
instance Amazonka.Data.Body.ToBody Data.Text.Internal.Text
instance Amazonka.Data.Body.ToBody Amazonka.Prelude.TextLazy
instance Amazonka.Data.Body.ToBody (Data.Aeson.KeyMap.KeyMap Data.Aeson.Types.Internal.Value)
instance Amazonka.Data.Body.ToBody Data.Aeson.Types.Internal.Value
instance Amazonka.Data.Body.ToBody Text.XML.Element
instance Amazonka.Data.Body.ToBody Amazonka.Data.Query.QueryString
instance Data.String.IsString Amazonka.Data.Body.HashedBody
instance Amazonka.Data.Body.ToHashedBody Data.ByteString.Internal.ByteString
instance Amazonka.Data.Body.ToHashedBody Amazonka.Data.Body.HashedBody
instance Amazonka.Data.Body.ToHashedBody GHC.Base.String
instance Amazonka.Data.Body.ToHashedBody Amazonka.Prelude.ByteStringLazy
instance Amazonka.Data.Body.ToHashedBody Data.Text.Internal.Text
instance Amazonka.Data.Body.ToHashedBody Amazonka.Prelude.TextLazy
instance Amazonka.Data.Body.ToHashedBody Data.Aeson.Types.Internal.Value
instance Amazonka.Data.Body.ToHashedBody Text.XML.Element
instance Amazonka.Data.Body.ToHashedBody Amazonka.Data.Query.QueryString
instance Amazonka.Data.Body.ToHashedBody (Data.Aeson.KeyMap.KeyMap Data.Aeson.Types.Internal.Value)
instance Data.String.IsString Amazonka.Data.Body.RequestBody
instance GHC.Show.Show Amazonka.Data.Body.HashedBody
instance GHC.Show.Show Amazonka.Data.Body.ChunkedBody
instance Amazonka.Data.Log.ToLog Amazonka.Data.Body.ChunkSize
instance GHC.Show.Show Amazonka.Data.Body.ResponseBody
module Amazonka.Data.Sensitive
-- | Note: read . show /= isomorphic
newtype Sensitive a
Sensitive :: a -> Sensitive a
[$sel:fromSensitive:Sensitive] :: Sensitive a -> a
_Sensitive :: Iso' (Sensitive a) a
instance GHC.Exts.IsList a => GHC.Exts.IsList (Amazonka.Data.Sensitive.Sensitive a)
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Amazonka.Data.Sensitive.Sensitive a)
instance Data.Hashable.Class.Hashable a => Data.Hashable.Class.Hashable (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Body.ToBody a => Amazonka.Data.Body.ToBody (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Headers.ToHeader a => Amazonka.Data.Headers.ToHeader (Amazonka.Data.Sensitive.Sensitive a)
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Amazonka.Data.Sensitive.Sensitive a)
instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Query.ToQuery a => Amazonka.Data.Query.ToQuery (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.XML.ToXML a => Amazonka.Data.XML.ToXML (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.XML.FromXML a => Amazonka.Data.XML.FromXML (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Text.ToText a => Amazonka.Data.Text.ToText (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Text.FromText a => Amazonka.Data.Text.FromText (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.ByteString.ToByteString a => Amazonka.Data.ByteString.ToByteString (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Amazonka.Data.Sensitive.Sensitive a)
instance Data.String.IsString a => Data.String.IsString (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Base.Functor Amazonka.Data.Sensitive.Sensitive
instance GHC.Generics.Generic (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Amazonka.Data.Sensitive.Sensitive a)
instance GHC.Show.Show (Amazonka.Data.Sensitive.Sensitive a)
instance Amazonka.Data.Log.ToLog (Amazonka.Data.Sensitive.Sensitive a)
module Amazonka.Data.Base64
-- | Base64 encoded binary data.
--
-- Encoding/decoding is automatically deferred to serialisation and
-- deserialisation respectively.
newtype Base64
Base64 :: ByteString -> Base64
[$sel:unBase64:Base64] :: Base64 -> ByteString
_Base64 :: Iso' Base64 ByteString
instance GHC.Generics.Generic Amazonka.Data.Base64.Base64
instance GHC.Classes.Ord Amazonka.Data.Base64.Base64
instance GHC.Read.Read Amazonka.Data.Base64.Base64
instance GHC.Classes.Eq Amazonka.Data.Base64.Base64
instance Data.Hashable.Class.Hashable Amazonka.Data.Base64.Base64
instance Control.DeepSeq.NFData Amazonka.Data.Base64.Base64
instance Amazonka.Data.Text.FromText Amazonka.Data.Base64.Base64
instance Amazonka.Data.ByteString.ToByteString Amazonka.Data.Base64.Base64
instance GHC.Show.Show Amazonka.Data.Base64.Base64
instance Amazonka.Data.Text.ToText Amazonka.Data.Base64.Base64
instance Amazonka.Data.Query.ToQuery Amazonka.Data.Base64.Base64
instance Amazonka.Data.XML.FromXML Amazonka.Data.Base64.Base64
instance Amazonka.Data.XML.ToXML Amazonka.Data.Base64.Base64
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Data.Base64.Base64
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Data.Base64.Base64
instance Amazonka.Data.Body.ToHashedBody Amazonka.Data.Base64.Base64
instance Amazonka.Data.Body.ToBody Amazonka.Data.Base64.Base64
module Amazonka.Data
module Amazonka.Types
-- | An access key ID.
--
-- For example: AKIAIOSFODNN7EXAMPLE
--
-- See: Understanding and Getting Your Security
-- Credentials.
newtype AccessKey
AccessKey :: ByteString -> AccessKey
-- | Secret access key credential.
--
-- For example: wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKE
--
-- See: Understanding and Getting Your Security
-- Credentials.
newtype SecretKey
SecretKey :: ByteString -> SecretKey
-- | A session token used by STS to temporarily authorise access to an AWS
-- resource.
--
-- See: Temporary Security Credentials.
newtype SessionToken
SessionToken :: ByteString -> SessionToken
_AccessKey :: Iso' AccessKey ByteString
_SecretKey :: Iso' SecretKey ByteString
_SessionToken :: Iso' SessionToken ByteString
-- | An authorisation environment containing AWS credentials, and
-- potentially a reference which can be refreshed out-of-band as
-- temporary credentials expire.
data Auth
Ref :: ThreadId -> IORef AuthEnv -> Auth
Auth :: AuthEnv -> Auth
withAuth :: MonadIO m => Auth -> (AuthEnv -> m a) -> m a
-- | The AuthN/AuthZ credential environment.
data AuthEnv
AuthEnv :: AccessKey -> Sensitive SecretKey -> Maybe (Sensitive SessionToken) -> Maybe ISO8601 -> AuthEnv
[$sel:accessKeyId:AuthEnv] :: AuthEnv -> AccessKey
[$sel:secretAccessKey:AuthEnv] :: AuthEnv -> Sensitive SecretKey
[$sel:sessionToken:AuthEnv] :: AuthEnv -> Maybe (Sensitive SessionToken)
[$sel:expiration:AuthEnv] :: AuthEnv -> Maybe ISO8601
authEnv_accessKeyId :: Lens' AuthEnv AccessKey
authEnv_secretAccessKey :: Lens' AuthEnv (Sensitive SecretKey)
authEnv_sessionToken :: Lens' AuthEnv (Maybe (Sensitive SessionToken))
authEnv_expiration :: Lens' AuthEnv (Maybe ISO8601)
type Algorithm a = Request a -> AuthEnv -> Region -> UTCTime -> Signed a
-- | Signing algorithm specific metadata.
data Meta
[Meta] :: ToLog a => a -> Meta
data Signer
Signer :: (forall a. Algorithm a) -> (forall a. Seconds -> Algorithm a) -> Signer
[$sel:sign:Signer] :: Signer -> forall a. Algorithm a
[$sel:presign:Signer] :: Signer -> forall a. Seconds -> Algorithm a
-- | A signed ClientRequest and associated metadata specific to the
-- signing algorithm, tagged with the initial request type to be able to
-- obtain the associated response, AWSResponse a.
data Signed a
Signed :: Meta -> ClientRequest -> Signed a
[$sel:signedMeta:Signed] :: Signed a -> Meta
[$sel:signedRequest:Signed] :: Signed a -> ClientRequest
signed_signedMeta :: Lens' (Signed a) Meta
signed_signedRequest :: Lens' (Signed a) ClientRequest
-- | Abbreviated service name.
data Abbrev
-- | Attributes and functions specific to an AWS service.
data Service
Service :: Abbrev -> Signer -> ByteString -> ByteString -> S3AddressingStyle -> ByteString -> (Region -> Endpoint) -> Maybe Seconds -> (Status -> Bool) -> (Status -> [Header] -> ByteStringLazy -> Error) -> Retry -> Service
[$sel:abbrev:Service] :: Service -> Abbrev
[$sel:signer:Service] :: Service -> Signer
[$sel:signingName:Service] :: Service -> ByteString
[$sel:version:Service] :: Service -> ByteString
-- | Only service bindings using the s3vhost request plugin (configured in
-- the generator) will care about this field. It is ignored otherwise.
[$sel:s3AddressingStyle:Service] :: Service -> S3AddressingStyle
[$sel:endpointPrefix:Service] :: Service -> ByteString
[$sel:endpoint:Service] :: Service -> Region -> Endpoint
[$sel:timeout:Service] :: Service -> Maybe Seconds
[$sel:check:Service] :: Service -> Status -> Bool
[$sel:error:Service] :: Service -> Status -> [Header] -> ByteStringLazy -> Error
[$sel:retry:Service] :: Service -> Retry
-- | When to rewrite S3 requests into virtual-hosted style.
--
-- Requests to S3 can be rewritten to access buckets by setting the
-- Host: header, which allows you to point a CNAME
-- record at an Amazon S3 Bucket.
--
-- Non-S3 object stores usually do not support this, which is usually the
-- only time you'll need to change this.
--
-- See: Virtual hosting of buckets in the Amazon S3 User
-- Guide.
--
-- See: Changing the Addressing Style for the corresponding
-- option in Boto 3.
data S3AddressingStyle
-- | Rewrite S3 request paths only if they can be expressed as a DNS label.
-- This is the default.
S3AddressingStyleAuto :: S3AddressingStyle
-- | Do not ever rewrite S3 request paths.
S3AddressingStylePath :: S3AddressingStyle
-- | Force virtual hosted style rewrites without checking the bucket name.
S3AddressingStyleVirtual :: S3AddressingStyle
_Abbrev :: Iso' Abbrev Text
service_abbrev :: Lens' Service Abbrev
service_signer :: Lens' Service Signer
service_signingName :: Lens' Service ByteString
service_version :: Lens' Service ByteString
service_s3AddressingStyle :: Lens' Service S3AddressingStyle
service_endpointPrefix :: Lens' Service ByteString
service_endpoint :: Lens' Service (Region -> Endpoint)
service_timeout :: Lens' Service (Maybe Seconds)
service_check :: Lens' Service (Status -> Bool)
service_error :: Lens' Service (Status -> [Header] -> ByteStringLazy -> Error)
service_retry :: Lens' Service Retry
-- | Specify how a request can be de/serialised.
class AWSRequest a where {
-- | The successful, expected response associated with a request.
type AWSResponse a :: Type;
}
request :: AWSRequest a => (Service -> Service) -> a -> Request a
response :: (AWSRequest a, MonadResource m) => (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
-- | An unsigned request.
data Request a
Request :: Service -> StdMethod -> RawPath -> QueryString -> [Header] -> RequestBody -> Request a
[$sel:service:Request] :: Request a -> Service
[$sel:method:Request] :: Request a -> StdMethod
[$sel:path:Request] :: Request a -> RawPath
[$sel:query:Request] :: Request a -> QueryString
[$sel:headers:Request] :: Request a -> [Header]
[$sel:body:Request] :: Request a -> RequestBody
requestSign :: Algorithm a
requestPresign :: Seconds -> Algorithm a
-- | Create an unsigned ClientRequest. You will almost never need to
-- do this.
requestUnsigned :: Request a -> Region -> ClientRequest
request_service :: Lens' (Request a) Service
request_method :: Lens' (Request a) StdMethod
request_path :: Lens' (Request a) RawPath
request_query :: Lens' (Request a) QueryString
request_headers :: forall a. Lens' (Request a) [Header]
request_body :: forall a. Lens' (Request a) RequestBody
-- | Constants and predicates used to create a RetryPolicy.
data Retry
Exponential :: Double -> Int -> Int -> (ServiceError -> Maybe Text) -> Retry
[$sel:base:Exponential] :: Retry -> Double
[$sel:growth:Exponential] :: Retry -> Int
[$sel:attempts:Exponential] :: Retry -> Int
-- | Returns a descriptive name for logging if the request should be
-- retried.
[$sel:check:Exponential] :: Retry -> ServiceError -> Maybe Text
retry_base :: Lens' Retry Double
retry_growth :: Lens' Retry Int
retry_attempts :: Lens' Retry Int
retry_check :: Lens' Retry (ServiceError -> Maybe Text)
class AsError a
-- | A general Amazonka error.
_Error :: AsError a => Prism' a Error
-- | An error occured while communicating over HTTP with a remote service.
_TransportError :: AsError a => Prism' a HttpException
-- | A serialisation error occured when attempting to deserialise a
-- response.
_SerializeError :: AsError a => Prism' a SerializeError
-- | A service specific error returned by the remote service.
_ServiceError :: AsError a => Prism' a ServiceError
-- | An error type representing errors that can be attributed to this
-- library.
data Error
TransportError :: HttpException -> Error
SerializeError :: SerializeError -> Error
ServiceError :: ServiceError -> Error
-- | An exception which may be generated by this library
data HttpException
data SerializeError
SerializeError' :: Abbrev -> Status -> Maybe ByteStringLazy -> String -> SerializeError
[$sel:abbrev:SerializeError'] :: SerializeError -> Abbrev
[$sel:status:SerializeError'] :: SerializeError -> Status
-- | The response body, if the response was not streaming.
[$sel:body:SerializeError'] :: SerializeError -> Maybe ByteStringLazy
[$sel:message:SerializeError'] :: SerializeError -> String
serializeError_abbrev :: Lens' SerializeError Abbrev
serializeError_status :: Lens' SerializeError Status
serializeError_body :: Lens' SerializeError (Maybe ByteStringLazy)
serializeError_message :: Lens' SerializeError String
data ServiceError
ServiceError' :: Abbrev -> Status -> [Header] -> ErrorCode -> Maybe ErrorMessage -> Maybe RequestId -> ServiceError
[$sel:abbrev:ServiceError'] :: ServiceError -> Abbrev
[$sel:status:ServiceError'] :: ServiceError -> Status
[$sel:headers:ServiceError'] :: ServiceError -> [Header]
[$sel:code:ServiceError'] :: ServiceError -> ErrorCode
[$sel:message:ServiceError'] :: ServiceError -> Maybe ErrorMessage
[$sel:requestId:ServiceError'] :: ServiceError -> Maybe RequestId
serviceError_abbrev :: Lens' ServiceError Abbrev
serviceError_status :: Lens' ServiceError Status
serviceError_headers :: Lens' ServiceError [Header]
serviceError_code :: Lens' ServiceError ErrorCode
serviceError_message :: Lens' ServiceError (Maybe ErrorMessage)
serviceError_requestId :: Lens' ServiceError (Maybe RequestId)
newtype ErrorCode
ErrorCode :: Text -> ErrorCode
-- | Construct an ErrorCode.
newErrorCode :: Text -> ErrorCode
newtype ErrorMessage
ErrorMessage :: Text -> ErrorMessage
[$sel:fromErrorMessage:ErrorMessage] :: ErrorMessage -> Text
newtype RequestId
RequestId :: Text -> RequestId
[$sel:fromRequestId:RequestId] :: RequestId -> Text
_ErrorCode :: Iso' ErrorCode Text
_ErrorMessage :: Iso' ErrorMessage Text
_RequestId :: Iso' RequestId Text
-- | The available AWS regions.
newtype Region
Region' :: Text -> Region
[$sel:fromRegion:Region'] :: Region -> Text
pattern Ohio :: Region
pattern NorthVirginia :: Region
pattern NorthCalifornia :: Region
pattern Oregon :: Region
pattern CapeTown :: Region
pattern HongKong :: Region
pattern Hyderabad :: Region
pattern Jakarta :: Region
pattern Melbourne :: Region
pattern Mumbai :: Region
pattern Osaka :: Region
pattern Seoul :: Region
pattern Singapore :: Region
pattern Sydney :: Region
pattern Tokyo :: Region
pattern Montreal :: Region
pattern Frankfurt :: Region
pattern Ireland :: Region
pattern London :: Region
pattern Milan :: Region
pattern Paris :: Region
pattern Spain :: Region
pattern Stockholm :: Region
pattern Zurich :: Region
pattern Bahrain :: Region
pattern UAE :: Region
pattern SaoPaulo :: Region
pattern GovCloudEast :: Region
pattern GovCloudWest :: Region
pattern Beijing :: Region
pattern Ningxia :: Region
data Endpoint
Endpoint :: ByteString -> RawPath -> Bool -> Int -> ByteString -> Endpoint
-- | The host to make requests to. Usually something like
-- s3.us-east-1.amazonaws.com.
[$sel:host:Endpoint] :: Endpoint -> ByteString
-- | Path segment prepended to the request path of any request made to this
-- endpoint. This is useful if you want to use the AWS API Gateway
-- Management API, which requires you to override the client endpoint
-- including a leading path segment (either the stage or, on a custom
-- domain, the mapped base path).
[$sel:basePath:Endpoint] :: Endpoint -> RawPath
[$sel:secure:Endpoint] :: Endpoint -> Bool
[$sel:port:Endpoint] :: Endpoint -> Int
-- | Signing scope, usually a region like us-east-1.
[$sel:scope:Endpoint] :: Endpoint -> ByteString
endpoint_host :: Lens' Endpoint ByteString
endpoint_basePath :: Lens' Endpoint RawPath
endpoint_secure :: Lens' Endpoint Bool
endpoint_port :: Lens' Endpoint Int
endpoint_scope :: Lens' Endpoint ByteString
-- | A convenience alias to avoid type ambiguity.
type ClientRequest = Request
-- | A convenience alias encapsulating the common Response.
type ClientResponse = Response
-- | A convenience alias encapsulating the common Response body.
type ClientBody = ConduitM () ByteString (ResourceT IO) ()
-- | Construct a ClientRequest using common parameters such as TLS
-- and prevent throwing errors when receiving erroneous status codes in
-- respones.
newClientRequest :: Endpoint -> Maybe Seconds -> ClientRequest
-- | A numeric value representing seconds.
newtype Seconds
Seconds :: DiffTime -> Seconds
toSeconds :: Seconds -> DiffTime
toMicroseconds :: Seconds -> Int
instance Amazonka.Data.Log.ToLog Amazonka.Types.Abbrev
instance Amazonka.Data.Text.ToText Amazonka.Types.Abbrev
instance Amazonka.Data.Text.FromText Amazonka.Types.Abbrev
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.Abbrev
instance Amazonka.Data.XML.FromXML Amazonka.Types.Abbrev
instance Data.String.IsString Amazonka.Types.Abbrev
instance GHC.Generics.Generic Amazonka.Types.Abbrev
instance GHC.Show.Show Amazonka.Types.Abbrev
instance GHC.Classes.Ord Amazonka.Types.Abbrev
instance GHC.Classes.Eq Amazonka.Types.Abbrev
instance Amazonka.Data.Log.ToLog Amazonka.Types.ErrorCode
instance Amazonka.Data.Text.ToText Amazonka.Types.ErrorCode
instance GHC.Show.Show Amazonka.Types.ErrorCode
instance GHC.Classes.Ord Amazonka.Types.ErrorCode
instance GHC.Classes.Eq Amazonka.Types.ErrorCode
instance Amazonka.Data.Log.ToLog Amazonka.Types.ErrorMessage
instance Amazonka.Data.Text.ToText Amazonka.Types.ErrorMessage
instance Amazonka.Data.Text.FromText Amazonka.Types.ErrorMessage
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.ErrorMessage
instance Amazonka.Data.XML.FromXML Amazonka.Types.ErrorMessage
instance Data.String.IsString Amazonka.Types.ErrorMessage
instance GHC.Generics.Generic Amazonka.Types.ErrorMessage
instance GHC.Show.Show Amazonka.Types.ErrorMessage
instance GHC.Classes.Ord Amazonka.Types.ErrorMessage
instance GHC.Classes.Eq Amazonka.Types.ErrorMessage
instance Amazonka.Data.Log.ToLog Amazonka.Types.RequestId
instance Amazonka.Data.Text.ToText Amazonka.Types.RequestId
instance Amazonka.Data.Text.FromText Amazonka.Types.RequestId
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.RequestId
instance Amazonka.Data.XML.FromXML Amazonka.Types.RequestId
instance Data.String.IsString Amazonka.Types.RequestId
instance GHC.Generics.Generic Amazonka.Types.RequestId
instance GHC.Show.Show Amazonka.Types.RequestId
instance GHC.Classes.Ord Amazonka.Types.RequestId
instance GHC.Classes.Eq Amazonka.Types.RequestId
instance GHC.Generics.Generic Amazonka.Types.SerializeError
instance GHC.Show.Show Amazonka.Types.SerializeError
instance GHC.Classes.Eq Amazonka.Types.SerializeError
instance GHC.Generics.Generic Amazonka.Types.ServiceError
instance GHC.Show.Show Amazonka.Types.ServiceError
instance GHC.Classes.Eq Amazonka.Types.ServiceError
instance GHC.Generics.Generic Amazonka.Types.Error
instance GHC.Show.Show Amazonka.Types.Error
instance GHC.Generics.Generic Amazonka.Types.Endpoint
instance GHC.Show.Show Amazonka.Types.Endpoint
instance GHC.Classes.Eq Amazonka.Types.Endpoint
instance GHC.Generics.Generic Amazonka.Types.Retry
instance GHC.Generics.Generic Amazonka.Types.S3AddressingStyle
instance GHC.Show.Show Amazonka.Types.S3AddressingStyle
instance GHC.Classes.Eq Amazonka.Types.S3AddressingStyle
instance Control.DeepSeq.NFData Amazonka.Types.AccessKey
instance Data.Hashable.Class.Hashable Amazonka.Types.AccessKey
instance Amazonka.Data.XML.ToXML Amazonka.Types.AccessKey
instance Amazonka.Data.XML.FromXML Amazonka.Types.AccessKey
instance Amazonka.Data.Query.ToQuery Amazonka.Types.AccessKey
instance Amazonka.Data.ByteString.ToByteString Amazonka.Types.AccessKey
instance Amazonka.Data.Log.ToLog Amazonka.Types.AccessKey
instance Amazonka.Data.Text.FromText Amazonka.Types.AccessKey
instance Amazonka.Data.Text.ToText Amazonka.Types.AccessKey
instance Data.String.IsString Amazonka.Types.AccessKey
instance GHC.Generics.Generic Amazonka.Types.AccessKey
instance GHC.Read.Read Amazonka.Types.AccessKey
instance GHC.Show.Show Amazonka.Types.AccessKey
instance GHC.Classes.Eq Amazonka.Types.AccessKey
instance Control.DeepSeq.NFData Amazonka.Types.SecretKey
instance Data.Hashable.Class.Hashable Amazonka.Types.SecretKey
instance Amazonka.Data.XML.ToXML Amazonka.Types.SecretKey
instance Amazonka.Data.XML.FromXML Amazonka.Types.SecretKey
instance Amazonka.Data.ByteString.ToByteString Amazonka.Types.SecretKey
instance Amazonka.Data.Text.FromText Amazonka.Types.SecretKey
instance Amazonka.Data.Text.ToText Amazonka.Types.SecretKey
instance Data.String.IsString Amazonka.Types.SecretKey
instance GHC.Generics.Generic Amazonka.Types.SecretKey
instance GHC.Classes.Eq Amazonka.Types.SecretKey
instance Control.DeepSeq.NFData Amazonka.Types.SessionToken
instance Data.Hashable.Class.Hashable Amazonka.Types.SessionToken
instance Amazonka.Data.XML.ToXML Amazonka.Types.SessionToken
instance Amazonka.Data.XML.FromXML Amazonka.Types.SessionToken
instance Amazonka.Data.ByteString.ToByteString Amazonka.Types.SessionToken
instance Amazonka.Data.Text.FromText Amazonka.Types.SessionToken
instance Amazonka.Data.Text.ToText Amazonka.Types.SessionToken
instance Data.String.IsString Amazonka.Types.SessionToken
instance GHC.Generics.Generic Amazonka.Types.SessionToken
instance GHC.Classes.Eq Amazonka.Types.SessionToken
instance Control.DeepSeq.NFData Amazonka.Types.AuthEnv
instance GHC.Generics.Generic Amazonka.Types.AuthEnv
instance GHC.Show.Show Amazonka.Types.AuthEnv
instance GHC.Classes.Eq Amazonka.Types.AuthEnv
instance Amazonka.Data.Log.ToLog Amazonka.Types.Region
instance Amazonka.Data.ByteString.ToByteString Amazonka.Types.Region
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.Region
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Types.Region
instance Amazonka.Data.XML.FromXML Amazonka.Types.Region
instance Amazonka.Data.XML.ToXML Amazonka.Types.Region
instance Amazonka.Data.Query.ToQuery Amazonka.Types.Region
instance Amazonka.Data.Text.FromText Amazonka.Types.Region
instance Amazonka.Data.Text.ToText Amazonka.Types.Region
instance Control.DeepSeq.NFData Amazonka.Types.Region
instance Data.Hashable.Class.Hashable Amazonka.Types.Region
instance Data.String.IsString Amazonka.Types.Region
instance GHC.Generics.Generic Amazonka.Types.Region
instance GHC.Classes.Ord Amazonka.Types.Region
instance GHC.Classes.Eq Amazonka.Types.Region
instance GHC.Read.Read Amazonka.Types.Region
instance GHC.Show.Show Amazonka.Types.Region
instance Control.DeepSeq.NFData Amazonka.Types.Seconds
instance GHC.Real.Real Amazonka.Types.Seconds
instance GHC.Num.Num Amazonka.Types.Seconds
instance GHC.Enum.Enum Amazonka.Types.Seconds
instance GHC.Generics.Generic Amazonka.Types.Seconds
instance GHC.Show.Show Amazonka.Types.Seconds
instance GHC.Read.Read Amazonka.Types.Seconds
instance GHC.Classes.Ord Amazonka.Types.Seconds
instance GHC.Classes.Eq Amazonka.Types.Seconds
instance GHC.Generics.Generic Amazonka.Types.Service
instance GHC.Generics.Generic (Amazonka.Types.Request a)
instance Data.Hashable.Class.Hashable Amazonka.Types.Seconds
instance Amazonka.Data.Text.FromText Amazonka.Types.Seconds
instance Amazonka.Data.Text.ToText Amazonka.Types.Seconds
instance Amazonka.Data.ByteString.ToByteString Amazonka.Types.Seconds
instance Amazonka.Data.Query.ToQuery Amazonka.Types.Seconds
instance Amazonka.Data.Log.ToLog Amazonka.Types.Seconds
instance Amazonka.Data.Log.ToLog Amazonka.Types.Auth
instance Amazonka.Data.Log.ToLog Amazonka.Types.AuthEnv
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.AuthEnv
instance Amazonka.Data.XML.FromXML Amazonka.Types.AuthEnv
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Types.SessionToken
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.SessionToken
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Types.SecretKey
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.SecretKey
instance Data.Aeson.Types.ToJSON.ToJSON Amazonka.Types.AccessKey
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.AccessKey
instance Amazonka.Data.Log.ToLog Amazonka.Types.Meta
instance Amazonka.Types.AsError GHC.Exception.Type.SomeException
instance Amazonka.Types.AsError Amazonka.Types.Error
instance GHC.Exception.Type.Exception Amazonka.Types.Error
instance Amazonka.Data.Log.ToLog Amazonka.Types.Error
instance Amazonka.Data.Log.ToLog Amazonka.Types.ServiceError
instance Amazonka.Data.Log.ToLog Amazonka.Types.SerializeError
instance Data.String.IsString Amazonka.Types.ErrorCode
instance Data.Aeson.Types.FromJSON.FromJSON Amazonka.Types.ErrorCode
instance Amazonka.Data.XML.FromXML Amazonka.Types.ErrorCode
instance Amazonka.Data.Text.FromText Amazonka.Types.ErrorCode
-- | This module provides an AWS compliant V2 Header request signer. It is
-- based heavily on boto, specifically boto's
-- HmacAuthV1Handler AWS capable signer. AWS documentation is
-- available here.
--
-- Notice: Limitations include an inability to sign with a security token
-- and inability to overwrite the Date header with an expiry.
module Amazonka.Sign.V2Header
v2Header :: Signer
-- | Construct a full header signer following the V2 Header scheme
newSigner :: RequestHeaders -> ByteString -> ByteString -> QueryString -> ByteString
-- | The following function mostly follows the toBS in amazonka QueryString
-- except for single QValue or single QPair keys not being suffixed with
-- an equals.
toSignerQueryBS :: QueryString -> ByteString
-- | Construct a header string for signing
constructSigningHeader :: Header -> ByteString
-- | Constructs a query string for signing
constructSigningQuery :: QueryString -> QueryString
constructFullPath :: ByteString -> ByteString -> ByteString
unionNecessaryHeaders :: [Header] -> [Header]
instance Amazonka.Data.Log.ToLog Amazonka.Sign.V2Header.V2Header
module Amazonka.Sign.V2
v2 :: Signer
instance Amazonka.Data.Log.ToLog Amazonka.Sign.V2.V2
-- | Functions contained in this module fully consume the body and thus
-- close the connection. This is needed to avoid hitting this issue:
-- https://github.com/brendanhay/amazonka/issues/490.
--
-- The only exception is receiveBody, which passes a streaming
-- response body to a callback and thus is not allowed to close the
-- connection. Users of streaming functions are advised to be careful and
-- consume the response body manually if they want the connection to be
-- closed promptly.
--
-- Note that using runResourceT will always close the
-- connection.
module Amazonka.Response
receiveNull :: MonadResource m => AWSResponse a -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveEmpty :: MonadResource m => (Int -> ResponseHeaders -> () -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveXMLWrapper :: MonadResource m => Text -> (Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveXML :: MonadResource m => (Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveJSON :: MonadResource m => (Int -> ResponseHeaders -> Object -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveBytes :: MonadResource m => (Int -> ResponseHeaders -> ByteString -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
receiveBody :: MonadResource m => (Int -> ResponseHeaders -> ResponseBody -> Either String (AWSResponse a)) -> (ByteStringLazy -> IO ByteStringLazy) -> Service -> Proxy a -> ClientResponse ClientBody -> m (Either Error (ClientResponse (AWSResponse a)))
module Amazonka.Pager
-- | Specify how an AWSRequest and it's associated Rs
-- response can generate a subsequent request, if available.
class AWSRequest a => AWSPager a
page :: AWSPager a => a -> AWSResponse a -> Maybe a
-- | Generalise IsTruncated and other optional/required response pagination
-- fields.
class AWSTruncated a
truncated :: AWSTruncated a => a -> Bool
stop :: AWSTruncated a => a -> Bool
choice :: (Alternative f, ToText a, ToText b) => (s -> f a) -> (s -> f b) -> Getter s (f Text)
instance Amazonka.Pager.AWSTruncated GHC.Types.Bool
instance Amazonka.Pager.AWSTruncated [a]
instance Amazonka.Pager.AWSTruncated (Data.HashMap.Internal.HashMap k v)
instance Amazonka.Pager.AWSTruncated (GHC.Maybe.Maybe a)
instance Amazonka.Pager.AWSTruncated (GHC.Maybe.Maybe GHC.Types.Bool)
module Amazonka.Error
-- | Provides a generalised prism for catching a specific service error
-- identified by the opaque service abbreviation and error code.
--
-- This can be used if the generated error prisms provided by
-- Amazonka.ServiceName.Types do not cover all the thrown
-- error codes. For example to define a new error prism:
--
--
-- {-# LANGUAGE OverloadedStrings #-}
--
-- import Amazonka.S3 (ServiceError, s3)
--
-- _NoSuchBucketPolicy :: AsError a => Fold a ServiceError
-- _NoSuchBucketPolicy = _MatchServiceError s3 "NoSuchBucketPolicy"
--
--
-- With example usage being:
--
-- -- >>> import Control.Exception.Lens (trying) -- -- >>> :t trying _NoSuchBucketPolicy -- MonadCatch m => m a -> m (Either ServiceError a) --_MatchServiceError :: AsError a => Service -> ErrorCode -> Fold a ServiceError statusSuccess :: Status -> Bool _HttpStatus :: AsError a => Traversal' a Status hasService :: (Applicative f, Choice p) => Service -> Optic' p f ServiceError ServiceError hasStatus :: (Applicative f, Choice p) => Int -> Optic' p f ServiceError ServiceError hasCode :: (Applicative f, Choice p) => ErrorCode -> Optic' p f ServiceError ServiceError serviceError :: Abbrev -> Status -> [Header] -> Maybe ErrorCode -> Maybe ErrorMessage -> Maybe RequestId -> ServiceError getRequestId :: [Header] -> Maybe RequestId getErrorCode :: Status -> [Header] -> ErrorCode parseJSONError :: Abbrev -> Status -> [Header] -> ByteStringLazy -> Error parseXMLError :: Abbrev -> Status -> [Header] -> ByteStringLazy -> Error parseRESTError :: Abbrev -> Status -> [Header] -> a -> Error decodeError :: Abbrev -> Status -> [Header] -> ByteStringLazy -> Either String ServiceError -> Error module Amazonka.Endpoint -- | A convenience function for overriding the Service -- Endpoint. -- -- See: $sel:endpoint:Service. setEndpoint :: Bool -> ByteString -> Int -> Service -> Service -- | Determine the full host address and credential scope within the -- specified Region. defaultEndpoint :: Service -> Region -> Endpoint module Amazonka.Waiter type Acceptor a = Request a -> Either Error (ClientResponse (AWSResponse a)) -> Maybe Accept data Accept AcceptSuccess :: Accept AcceptFailure :: Accept AcceptRetry :: Accept -- | Timing and acceptance criteria to check fulfillment of a remote -- operation. data Wait a Wait :: ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a [$sel:name:Wait] :: Wait a -> ByteString [$sel:attempts:Wait] :: Wait a -> Int [$sel:delay:Wait] :: Wait a -> Seconds [$sel:acceptors:Wait] :: Wait a -> [Acceptor a] wait_name :: Lens' (Wait a) ByteString wait_attempts :: forall a. Lens' (Wait a) Int wait_delay :: Lens' (Wait a) Seconds wait_acceptors :: Lens (Wait a) (Wait b) [Acceptor a] [Acceptor b] accept :: Wait a -> Acceptor a matchAll :: Eq b => b -> Accept -> Fold (AWSResponse a) b -> Acceptor a matchAny :: Eq b => b -> Accept -> Fold (AWSResponse a) b -> Acceptor a matchNonEmpty :: Bool -> Accept -> Fold (AWSResponse a) b -> Acceptor a matchError :: ErrorCode -> Accept -> Acceptor a matchStatus :: Int -> Accept -> Acceptor a nonEmptyText :: Fold a Text -> Fold a Bool instance GHC.Show.Show Amazonka.Waiter.Accept instance GHC.Classes.Eq Amazonka.Waiter.Accept instance Amazonka.Data.Log.ToLog Amazonka.Waiter.Accept -- | Re-export lenses and other optics for types in amazonka-core. -- You will probably find record updates, generic-lens, -- generic-optics, or (GHC >=9.2) -- -XOverloadedRecordDot more ergonomic than these. module Amazonka.Core.Lens _ResponseBody :: Iso' ResponseBody (ConduitM () ByteString (ResourceT IO) ()) _ChunkSize :: Iso' ChunkSize Int chunkedBody_size :: Lens' ChunkedBody ChunkSize chunkedBody_length :: Lens' ChunkedBody Integer chunkedBody_body :: Lens' ChunkedBody (ConduitM () ByteString (ResourceT IO) ()) _Time :: Iso' (Time a) UTCTime _Abbrev :: Iso' Abbrev Text _AccessKey :: Iso' AccessKey ByteString authEnv_accessKeyId :: Lens' AuthEnv AccessKey authEnv_secretAccessKey :: Lens' AuthEnv (Sensitive SecretKey) authEnv_sessionToken :: Lens' AuthEnv (Maybe (Sensitive SessionToken)) authEnv_expiration :: Lens' AuthEnv (Maybe ISO8601) endpoint_host :: Lens' Endpoint ByteString endpoint_basePath :: Lens' Endpoint RawPath endpoint_secure :: Lens' Endpoint Bool endpoint_port :: Lens' Endpoint Int endpoint_scope :: Lens' Endpoint ByteString _ErrorCode :: Iso' ErrorCode Text _ErrorMessage :: Iso' ErrorMessage Text request_service :: Lens' (Request a) Service request_method :: Lens' (Request a) StdMethod request_path :: Lens' (Request a) RawPath request_query :: Lens' (Request a) QueryString request_headers :: forall a. Lens' (Request a) [Header] request_body :: forall a. Lens' (Request a) RequestBody _RequestId :: Iso' RequestId Text retry_base :: Lens' Retry Double retry_growth :: Lens' Retry Int retry_attempts :: Lens' Retry Int retry_check :: Lens' Retry (ServiceError -> Maybe Text) _SecretKey :: Iso' SecretKey ByteString _SessionToken :: Iso' SessionToken ByteString serializeError_abbrev :: Lens' SerializeError Abbrev serializeError_status :: Lens' SerializeError Status serializeError_body :: Lens' SerializeError (Maybe ByteStringLazy) serializeError_message :: Lens' SerializeError String service_abbrev :: Lens' Service Abbrev service_signer :: Lens' Service Signer service_signingName :: Lens' Service ByteString service_version :: Lens' Service ByteString service_s3AddressingStyle :: Lens' Service S3AddressingStyle service_endpointPrefix :: Lens' Service ByteString service_endpoint :: Lens' Service (Region -> Endpoint) service_timeout :: Lens' Service (Maybe Seconds) service_check :: Lens' Service (Status -> Bool) service_error :: Lens' Service (Status -> [Header] -> ByteStringLazy -> Error) service_retry :: Lens' Service Retry serviceError_abbrev :: Lens' ServiceError Abbrev serviceError_status :: Lens' ServiceError Status serviceError_headers :: Lens' ServiceError [Header] serviceError_code :: Lens' ServiceError ErrorCode serviceError_message :: Lens' ServiceError (Maybe ErrorMessage) serviceError_requestId :: Lens' ServiceError (Maybe RequestId) signed_signedMeta :: Lens' (Signed a) Meta signed_signedRequest :: Lens' (Signed a) ClientRequest wait_name :: Lens' (Wait a) ByteString wait_attempts :: forall a. Lens' (Wait a) Int wait_delay :: Lens' (Wait a) Seconds wait_acceptors :: Lens (Wait a) (Wait b) [Acceptor a] [Acceptor b] -- | Types and values referenced by generated code. module Amazonka.Core (.!@) :: Functor f => f (Maybe a) -> a -> f a infixl 7 .!@ may :: Applicative f => ([a] -> f b) -> [a] -> f (Maybe b) module Amazonka.Request head' :: ToRequest a => Service -> a -> Request a delete :: ToRequest a => Service -> a -> Request a get :: ToRequest a => Service -> a -> Request a post :: ToRequest a => Service -> a -> Request a put :: ToRequest a => Service -> a -> Request a patchBody :: (ToRequest a, ToBody a) => Service -> a -> Request a patchJSON :: (ToRequest a, ToJSON a) => Service -> a -> Request a postXML :: (ToRequest a, ToElement a) => Service -> a -> Request a postJSON :: (ToRequest a, ToJSON a) => Service -> a -> Request a postQuery :: ToRequest a => Service -> a -> Request a postBody :: (ToRequest a, ToBody a) => Service -> a -> Request a putXML :: (ToRequest a, ToElement a) => Service -> a -> Request a putJSON :: (ToRequest a, ToJSON a) => Service -> a -> Request a putBody :: (ToRequest a, ToBody a) => Service -> a -> Request a defaultRequest :: ToRequest a => Service -> a -> Request a contentMD5Header :: Request a -> Request a expectHeader :: Request a -> Request a glacierVersionHeader :: ByteString -> Request a -> Request a s3vhost :: Request a -> Request a clientRequestHeaders :: Lens' ClientRequest RequestHeaders clientRequestQuery :: Lens' ClientRequest ByteString clientRequestURL :: ClientRequest -> ByteString module Amazonka.Sign.V4.Base data V4 V4 :: UTCTime -> Method -> Path -> Endpoint -> Credential -> CanonicalQuery -> CanonicalRequest -> CanonicalHeaders -> SignedHeaders -> StringToSign -> Signature -> [Header] -> Maybe Seconds -> V4 [$sel:metaTime:V4] :: V4 -> UTCTime [$sel:metaMethod:V4] :: V4 -> Method [$sel:metaPath:V4] :: V4 -> Path [$sel:metaEndpoint:V4] :: V4 -> Endpoint [$sel:metaCredential:V4] :: V4 -> Credential [$sel:metaCanonicalQuery:V4] :: V4 -> CanonicalQuery [$sel:metaCanonicalRequest:V4] :: V4 -> CanonicalRequest [$sel:metaCanonicalHeaders:V4] :: V4 -> CanonicalHeaders [$sel:metaSignedHeaders:V4] :: V4 -> SignedHeaders [$sel:metaStringToSign:V4] :: V4 -> StringToSign [$sel:metaSignature:V4] :: V4 -> Signature [$sel:metaHeaders:V4] :: V4 -> [Header] [$sel:metaTimeout:V4] :: V4 -> Maybe Seconds base :: Hash -> Request a -> AuthEnv -> Region -> UTCTime -> (V4, ClientRequest -> ClientRequest) -- | Used to tag provenance. This allows keeping the same layout as the -- signing documentation, passing ByteStrings everywhere, with -- some type guarantees. -- -- Data.Tagged is not used for no reason other than the dependency, -- syntactic length, and the ToByteString instance. newtype Tag (s :: Symbol) a Tag :: a -> Tag (s :: Symbol) a [$sel:untag:Tag] :: Tag (s :: Symbol) a -> a type Hash = Tag "body-digest" ByteString type StringToSign = Tag "string-to-sign" ByteString type Credential = Tag "credential" ByteString type CredentialScope = Tag "credential-scope" [ByteString] type CanonicalRequest = Tag "canonical-request" ByteString type CanonicalHeaders = Tag "canonical-headers" ByteString type CanonicalQuery = Tag "canonical-query" ByteString type SignedHeaders = Tag "signed-headers" ByteString type NormalisedHeaders = Tag "normalised-headers" [(ByteString, ByteString)] type Method = Tag "method" ByteString type CanonicalPath = Tag "canonical-path" ByteString type Path = Tag "path" ByteString type Signature = Tag "signature" ByteString authorisation :: V4 -> ByteString signRequest :: V4 -> RequestBody -> (ClientRequest -> ClientRequest) -> Signed a signMetadata :: AuthEnv -> Region -> UTCTime -> (Credential -> SignedHeaders -> QueryString -> QueryString) -> Hash -> Request a -> V4 algorithm :: ByteString signature :: SecretKey -> CredentialScope -> StringToSign -> Signature stringToSign :: UTCTime -> CredentialScope -> CanonicalRequest -> StringToSign credential :: AccessKey -> CredentialScope -> Credential credentialScope :: Service -> Endpoint -> UTCTime -> CredentialScope canonicalRequest :: Method -> CanonicalPath -> Hash -> CanonicalQuery -> CanonicalHeaders -> SignedHeaders -> CanonicalRequest escapedPath :: Region -> Request a -> Path canonicalPath :: Region -> Request a -> CanonicalPath -- | The complete raw path for a request, including any -- $sel:basePath:Endpoint on the endpoint. fullRawPath :: Region -> Request a -> RawPath canonicalQuery :: QueryString -> CanonicalQuery canonicalHeaders :: NormalisedHeaders -> CanonicalHeaders signedHeaders :: NormalisedHeaders -> SignedHeaders normaliseHeaders :: [Header] -> NormalisedHeaders instance GHC.Show.Show a => GHC.Show.Show (Amazonka.Sign.V4.Base.Tag s a) instance Amazonka.Data.Log.ToLog Amazonka.Sign.V4.Base.V4 instance Amazonka.Data.ByteString.ToByteString Amazonka.Sign.V4.Base.CredentialScope instance Amazonka.Data.ByteString.ToByteString (Amazonka.Sign.V4.Base.Tag s Data.ByteString.Internal.ByteString) instance Amazonka.Data.Log.ToLog (Amazonka.Sign.V4.Base.Tag s Data.ByteString.Internal.ByteString) module Amazonka.Sign.V4.Chunked chunked :: ChunkedBody -> Algorithm a metadataLength :: ChunkedBody -> Integer sha256 :: ByteString -> ByteString sha256Empty :: ByteString algorithm :: ByteString digest :: ByteString chunkSignatureHeader :: ByteString crlf :: ByteString module Amazonka.Sign.V4 data V4 V4 :: UTCTime -> Method -> Path -> Endpoint -> Credential -> CanonicalQuery -> CanonicalRequest -> CanonicalHeaders -> SignedHeaders -> StringToSign -> Signature -> [Header] -> Maybe Seconds -> V4 [$sel:metaTime:V4] :: V4 -> UTCTime [$sel:metaMethod:V4] :: V4 -> Method [$sel:metaPath:V4] :: V4 -> Path [$sel:metaEndpoint:V4] :: V4 -> Endpoint [$sel:metaCredential:V4] :: V4 -> Credential [$sel:metaCanonicalQuery:V4] :: V4 -> CanonicalQuery [$sel:metaCanonicalRequest:V4] :: V4 -> CanonicalRequest [$sel:metaCanonicalHeaders:V4] :: V4 -> CanonicalHeaders [$sel:metaSignedHeaders:V4] :: V4 -> SignedHeaders [$sel:metaStringToSign:V4] :: V4 -> StringToSign [$sel:metaSignature:V4] :: V4 -> Signature [$sel:metaHeaders:V4] :: V4 -> [Header] [$sel:metaTimeout:V4] :: V4 -> Maybe Seconds v4 :: Signer