Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- die :: HasCallStack => MonadIO m => Text -> m ()
- showT :: Show a => a -> Text
- putTextLn :: MonadIO m => Text -> m ()
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
- ignoringExceptions :: MonadUnliftIO m => m () -> m ()
- sktRecv :: MonadIO m => Socket -> Int -> m ByteString
- sktSendAll :: MonadIO m => Socket -> ByteString -> m ()
- module Ki.Unlifted
- module UnliftIO
- module UnliftIO.STM
- stateTVar :: TVar s -> (s -> (a, s)) -> STM a
- check :: Bool -> STM ()
- module PyF
- module Lucid
- module Lucid.Htmx
- makeAttribute :: Text -> Text -> Attribute
- data ParserInfo a
- (.=) :: (KeyValue kv, ToJSON v) => Key -> v -> kv
- (.:?) :: FromJSON a => Object -> Key -> Parser (Maybe a)
- (.:) :: FromJSON a => Object -> Key -> Parser a
- data Value
- type Pair = (Key, Value)
- decode' :: FromJSON a => ByteString -> Maybe a
- class FromJSON a where
- fromJSON :: FromJSON a => Value -> Result a
- class ToJSON a
- toJSON :: ToJSON a => a -> Value
- withText :: String -> (Text -> Parser a) -> Value -> Parser a
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- data Result a
- encodeJSON :: ToJSON a => a -> LByteString
- decodeJSON :: FromJSON a => LByteString -> Maybe a
- object :: [Pair] -> Value
- module XStatic
- class From source target
- from :: From source target => source -> target
- tryFrom :: TryFrom source target => source -> Either (TryFromException source target) target
- into :: forall target source. From source target => source -> target
- via :: forall through source target. (From source through, From through target) => source -> target
- unsafeFrom :: (HasCallStack, TryFrom source target, Show source, Typeable source, Typeable target) => source -> target
- (%~) :: ASetter s t a b -> (a -> b) -> s -> t
- (.~) :: ASetter s t a b -> b -> s -> t
- (^?) :: s -> Getting (First a) s a -> Maybe a
- ix :: Ixed m => Index m -> Traversal' m (IxValue m)
- set :: ASetter s t a b -> b -> s -> t
- over :: ASetter s t a b -> (a -> b) -> s -> t
- key :: AsValue t => Key -> Traversal' t Value
- _String :: AsValue t => Prism' t Text
- _Integer :: AsNumber t => Prism' t Integer
- _Integral :: (AsNumber t, Integral a) => Prism' t a
- _Bool :: AsValue t => Prism' t Bool
- _JSON :: (AsJSON t, FromJSON a, ToJSON b) => Prism t t a b
- data UUID
- class FromHttpApiData a where
- parseUrlPiece :: Text -> Either Text a
- parseHeader :: ByteString -> Either Text a
- parseQueryParam :: Text -> Either Text a
- class ToHttpApiData a where
- toUrlPiece :: a -> Text
- toEncodedUrlPiece :: a -> Builder
- toHeader :: a -> ByteString
- toQueryParam :: a -> Text
- class Serialise a where
- encode :: a -> Encoding
- decode :: Decoder s a
- encodeList :: [a] -> Encoding
- decodeList :: Decoder s [a]
- serialise :: Serialise a => a -> ByteString
- deserialise :: Serialise a => ByteString -> a
- deserialiseOrFail :: Serialise a => ByteString -> Either DeserialiseFailure a
- data UTCTime
- getCurrentTime :: IO UTCTime
- data Socket
- data Seq a
- data Text
- type LByteString = ByteString
- data ByteString
- data ShortByteString
- data IntMap a
- data IntSet
- data Set a
- data Map k a
- data HashMap k v
- type Port = Int
- class Eq a => Hashable a
- module Data.Text.Encoding
- module Data.Text.Encoding.Error
- type RawFilePath = ByteString
- fromList :: IsList l => [Item l] -> l
- bool :: a -> a -> Bool -> a
- traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
- module Control.Applicative
- module Control.Monad
- module Control.Monad.Reader
- module Data.Bifunctor
- module Data.Char
- module Data.Coerce
- module Data.Dynamic
- module Data.Either
- module Data.Functor.Identity
- module Data.Int
- module Data.Maybe
- module Data.Monoid
- module Data.Proxy
- module Data.Void
- module Data.Word
- module Debug.Trace
- module Foreign.C.Types
- module GHC.Stack
- class Generic a
- class HasField (x :: k) r a | x r -> a where
- getField :: r -> a
- data Natural
- data ThreadId
- myThreadId :: IO ThreadId
- threadDelay :: Int -> IO ()
- readMaybe :: Read a => String -> Maybe a
- class IsString a where
- fromString :: String -> a
- (&) :: a -> (a -> b) -> b
- toList :: Foldable t => t a -> [a]
Custom helpers
die :: HasCallStack => MonadIO m => Text -> m () #
ignoringExceptions :: MonadUnliftIO m => m () -> m () #
Run an IO action, ignoring synchronous exceptions
sktSendAll :: MonadIO m => Socket -> ByteString -> m () #
ki
module Ki.Unlifted
unliftio
module UnliftIO
module UnliftIO.STM
stateTVar :: TVar s -> (s -> (a, s)) -> STM a #
Like modifyTVar'
but the function is a simple state transition that can
return a side value which is passed on as the result of the STM
.
Since: stm-2.5.0
Check that the boolean condition is true and, if not, retry
.
In other words, check b = unless b retry
.
Since: stm-2.1.1
PyF
module PyF
lucid
module Lucid
module Lucid.Htmx
optparse-applicative
data ParserInfo a #
A full description for a runnable Parser
for a program.
Instances
Functor ParserInfo | |
Defined in Options.Applicative.Types fmap :: (a -> b) -> ParserInfo a -> ParserInfo b # (<$) :: a -> ParserInfo b -> ParserInfo a # |
aeson
(.:?) :: FromJSON a => Object -> Key -> Parser (Maybe 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 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.
A JSON value represented as a Haskell value.
Instances
Arbitrary Value | Since: aeson-2.0.3.0 |
CoArbitrary Value | Since: aeson-2.0.3.0 |
Defined in Data.Aeson.Types.Internal coarbitrary :: Value -> Gen b -> Gen b # | |
Function Value | Since: aeson-2.0.3.0 |
FromJSON Value | |
FromString Encoding | |
Defined in Data.Aeson.Types.ToJSON fromString :: String -> Encoding | |
FromString Value | |
Defined in Data.Aeson.Types.ToJSON fromString :: String -> Value | |
KeyValue Object | Constructs a singleton |
KeyValue Pair | |
ToJSON Value | |
Defined in Data.Aeson.Types.ToJSON | |
Data Value | |
Defined in Data.Aeson.Types.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value # dataTypeOf :: Value -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) # gmapT :: (forall b. Data b => b -> b) -> Value -> Value # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r # gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value # | |
IsString Value | |
Defined in Data.Aeson.Types.Internal fromString :: String -> Value # | |
Generic Value | |
Read Value | |
Show Value | Since version 1.5.6.0 version object values are printed in lexicographic key order
|
NFData Value | |
Defined in Data.Aeson.Types.Internal | |
Eq Value | |
Ord Value | The ordering is total, consistent with Since: aeson-1.5.2.0 |
Hashable Value | |
Defined in Data.Aeson.Types.Internal | |
AsJSON Value | |
AsNumber Value | |
AsValue Value | |
Lift Value | Since: aeson-0.11.0.0 |
(GToJSON' Encoding arity a, ConsToJSON Encoding arity a, Constructor c) => SumToJSON' TwoElemArray Encoding arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON | |
(GToJSON' Value arity a, ConsToJSON Value arity a, Constructor c) => SumToJSON' TwoElemArray Value arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON | |
GToJSON' Encoding arity (U1 :: TYPE LiftedRep -> Type) | |
GToJSON' Value arity (U1 :: TYPE LiftedRep -> Type) | |
GToJSON' Value arity (V1 :: TYPE LiftedRep -> Type) | |
ToJSON1 f => GToJSON' Encoding One (Rec1 f) | |
ToJSON1 f => GToJSON' Value One (Rec1 f) | |
(EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) | |
ToJSON a => GToJSON' Encoding arity (K1 i a :: TYPE LiftedRep -> Type) | |
(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON' Value arity (a :*: b) | |
ToJSON a => GToJSON' Value arity (K1 i a :: TYPE LiftedRep -> Type) | |
(ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) | |
(ToJSON1 f, GToJSON' Value One g) => GToJSON' Value One (f :.: g) | |
FromPairs Value (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON | |
v ~ Value => KeyValuePair v (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON | |
type Rep Value | |
Defined in Data.Aeson.Types.Internal type Rep Value = D1 ('MetaData "Value" "Data.Aeson.Types.Internal" "aeson-2.0.3.0-HrsDtaFI3o9DTod09rL5GT" 'False) ((C1 ('MetaCons "Object" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Object)) :+: (C1 ('MetaCons "Array" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Array)) :+: C1 ('MetaCons "String" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) :+: (C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Scientific)) :+: (C1 ('MetaCons "Bool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Null" 'PrefixI 'False) (U1 :: Type -> Type)))) | |
type Index Value | |
Defined in Data.Aeson.Lens | |
type IxValue Value | |
Defined in Data.Aeson.Lens |
decode' :: FromJSON a => ByteString -> Maybe a #
Efficiently deserialize a JSON value from a lazy ByteString
.
If this fails due to incomplete or invalid input, Nothing
is
returned.
The input must consist solely of a JSON document, with no trailing data except for whitespace.
This function parses and performs conversion immediately. See
json'
for details.
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:
fail
yields a custom error message: it is the recommended way of reporting a failure;empty
(ormzero
) is uninformative: use it when the error is meant to be caught by some(
;<|>
)typeMismatch
can be used to report a failure when the encountered value is not of the expected JSON type;unexpected
is an appropriate alternative when more than one type may be expected, or to keep the expected type implicit.
prependFailure
(or modifyFailure
) add more information to a parser's
error messages.
An example type and instance using typeMismatch
and prependFailure
:
-- Allow ourselves to writeText
literals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceFromJSON
Coord whereparseJSON
(Object
v) = Coord<$>
v.:
"x"<*>
v.:
"y" -- We do not expect a non-Object
value here. -- We could useempty
to fail, buttypeMismatch
-- 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:
instanceFromJSON
Coord whereparseJSON
=withObject
"Coord" $ \v -> Coord<$>
v.:
"x"<*>
v.:
"y"
Instead of manually writing your FromJSON
instance, there are two options
to do it automatically:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
parseJSON
.
To use the second, simply add a deriving
clause to your
datatype and declare a Generic
FromJSON
instance for your datatype without giving
a definition for parseJSON
.
For example, the previous example can be simplified to just:
{-# LANGUAGE DeriveGeneric #-} import GHC.Generics data Coord = Coord { x :: Double, y :: Double } derivingGeneric
instanceFromJSON
Coord
The default implementation will be equivalent to
parseJSON =
; if you need different
options, you can customize the generic decoding by defining:genericParseJSON
defaultOptions
customOptions =defaultOptions
{fieldLabelModifier
=map
toUpper
} instanceFromJSON
Coord whereparseJSON
=genericParseJSON
customOptions
Nothing
Instances
fromJSON :: FromJSON a => Value -> Result a #
Convert a value from JSON, failing if the types do not match.
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 writeText
literals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceToJSON
Coord wheretoJSON
(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:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
toJSON
.
To use the second, simply add a deriving
clause to your
datatype and declare a Generic
ToJSON
instance. If you require nothing other than
defaultOptions
, it is sufficient to write (and this is the only
alternative where the default toJSON
implementation is sufficient):
{-# LANGUAGE DeriveGeneric #-} import GHC.Generics data Coord = Coord { x :: Double, y :: Double } derivingGeneric
instanceToJSON
Coord wheretoEncoding
=genericToEncoding
defaultOptions
If on the other hand you wish to customize the generic decoding, you have to implement both methods:
customOptions =defaultOptions
{fieldLabelModifier
=map
toUpper
} instanceToJSON
Coord wheretoJSON
=genericToJSON
customOptionstoEncoding
=genericToEncoding
customOptions
Previous versions of this library only had the toJSON
method. Adding
toEncoding
had two reasons:
- toEncoding is more efficient for the common case that the output of
toJSON
is directly serialized to aByteString
. Further, expressing either method in terms of the other would be non-optimal. - The choice of defaults allows a smooth transition for existing users:
Existing instances that do not define
toEncoding
still compile and have the correct semantics. This is ensured by making the default implementation oftoEncoding
usetoJSON
. This produces correct results, but since it performs an intermediate conversion to aValue
, it will be less efficient than directly emitting anEncoding
. (this also means that specifying nothing more thaninstance ToJSON Coord
would be sufficient as a generically decoding instance, but there probably exists no good reason to not specifytoEncoding
in new instances.)
Instances
withObject :: String -> (Object -> Parser a) -> Value -> Parser a #
applies withObject
name f valuef
to the Object
when value
is an Object
and fails otherwise.
Error message example
withObject "MyType" f (String "oops") -- Error: "parsing MyType failed, expected Object, but encountered String"
The result of running a Parser
.
Instances
MonadFail Result | |
Defined in Data.Aeson.Types.Internal | |
Foldable Result | |
Defined in Data.Aeson.Types.Internal fold :: Monoid m => Result m -> m # foldMap :: Monoid m => (a -> m) -> Result a -> m # foldMap' :: Monoid m => (a -> m) -> Result a -> m # foldr :: (a -> b -> b) -> b -> Result a -> b # foldr' :: (a -> b -> b) -> b -> Result a -> b # foldl :: (b -> a -> b) -> b -> Result a -> b # foldl' :: (b -> a -> b) -> b -> Result a -> b # foldr1 :: (a -> a -> a) -> Result a -> a # foldl1 :: (a -> a -> a) -> Result a -> a # elem :: Eq a => a -> Result a -> Bool # maximum :: Ord a => Result a -> a # minimum :: Ord a => Result a -> a # | |
Traversable Result | |
Alternative Result | |
Applicative Result | |
Functor Result | |
Monad Result | |
MonadPlus Result | |
Monoid (Result a) | |
Semigroup (Result a) | |
Show a => Show (Result a) | |
NFData a => NFData (Result a) | |
Defined in Data.Aeson.Types.Internal | |
Eq a => Eq (Result a) | |
encodeJSON :: ToJSON a => a -> LByteString #
decodeJSON :: FromJSON a => LByteString -> Maybe a #
xstatic
module XStatic
witch
This type class is for converting values from some source
type into
some other target
type. The constraint
means that
you can convert from a value of type From
source targetsource
into a value of type
target
.
This type class is for conversions that always succeed. If your conversion
sometimes fails, consider implementing TryFrom
instead.
Instances
from :: From source target => source -> target #
This method implements the conversion of a value between types. At call
sites you may prefer to use into
instead.
-- Avoid this: from (x :: s) -- Prefer this: from @s x
The default implementation of this method simply calls coerce
,
which works for types that have the same runtime representation. This
means that for newtype
s you do not need to implement this method at
all. For example:
>>>
newtype Name = Name String
>>>
instance From Name String
>>>
instance From String Name
tryFrom :: TryFrom source target => source -> Either (TryFromException source target) target #
This method implements the conversion of a value between types. At call
sites you may want to use tryInto
instead.
-- Avoid this: tryFrom (x :: s) -- Prefer this: tryFrom @s
Consider using maybeTryFrom
or eitherTryFrom
to implement this
method.
into :: forall target source. From source target => source -> target #
This is the same as from
except that the type variables are in the
opposite order.
-- Avoid this: from x :: t -- Prefer this: into @t x
via :: forall through source target. (From source through, From through target) => source -> target #
This function first converts from some source
type into some through
type, and then converts that into some target
type. Usually this is used
when writing From
instances. Sometimes this can be used to work
around the lack of an instance that should probably exist.
-- Avoid this: from @u . into @u -- Prefer this: via @u
unsafeFrom :: (HasCallStack, TryFrom source target, Show source, Typeable source, Typeable target) => source -> target #
This function is like tryFrom
except that it will throw an
impure exception if the conversion fails.
-- Avoid this: either throw id . tryFrom @s -- Prefer this: unsafeFrom @s
lens
(%~) :: ASetter s t a b -> (a -> 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
%~
ffmapDefault
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 -> 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
(^?) :: s -> Getting (First a) s a -> Maybe a infixl 8 #
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
ix :: Ixed m => Index m -> Traversal' m (IxValue m) #
NB: Setting the value of this Traversal
will only set the value in
at
if it is already present.
If you want to be able to insert missing values, you want at
.
>>>
Seq.fromList [a,b,c,d] & ix 2 %~ f
fromList [a,b,f c,d]
>>>
Seq.fromList [a,b,c,d] & ix 2 .~ e
fromList [a,b,e,d]
>>>
Seq.fromList [a,b,c,d] ^? ix 2
Just c
>>>
Seq.fromList [] ^? ix 2
Nothing
set :: ASetter s t a b -> b -> s -> t #
Replace the target of a Lens
or all of the targets of a Setter
or Traversal
with a constant value.
(<$
) ≡set
mapped
>>>
set _2 "hello" (1,())
(1,"hello")
>>>
set mapped () [1,2,3,4]
[(),(),(),()]
Note: Attempting to set
a Fold
or Getter
will fail at compile time with an
relatively nice error message.
set
::Setter
s t a b -> b -> s -> tset
::Iso
s t a b -> b -> s -> tset
::Lens
s t a b -> b -> s -> tset
::Traversal
s t a b -> b -> s -> t
over :: ASetter s t a b -> (a -> b) -> s -> t #
Modify the target of a Lens
or all the targets of a Setter
or Traversal
with a function.
fmap
≡over
mapped
fmapDefault
≡over
traverse
sets
.
over
≡id
over
.
sets
≡id
Given any valid Setter
l
, you can also rely on the law:
over
l f.
over
l g =over
l (f.
g)
e.g.
>>>
over mapped f (over mapped g [a,b,c]) == over mapped (f . g) [a,b,c]
True
Another way to view over
is to say that it transforms a Setter
into a
"semantic editor combinator".
>>>
over mapped f (Just a)
Just (f a)
>>>
over mapped (*10) [1,2,3]
[10,20,30]
>>>
over _1 f (a,b)
(f a,b)
>>>
over _1 show (10,20)
("10",20)
over
::Setter
s t a b -> (a -> b) -> s -> tover
::ASetter
s t a b -> (a -> b) -> s -> t
lens-aeson
_String :: AsValue t => Prism' t Text #
>>>
"{\"a\": \"xyz\", \"b\": true}" ^? key "a" . _String
Just "xyz"
>>>
"{\"a\": \"xyz\", \"b\": true}" ^? key "b" . _String
Nothing
>>>
_Object._Wrapped # [("key" :: Key, _String # "value")] :: String
"{\"key\":\"value\"}"
_Integer :: AsNumber t => Prism' t Integer #
Prism into an Integer
over a Value
or Scientific
>>>
"[10]" ^? nth 0 . _Integer
Just 10
>>>
"[10.5]" ^? nth 0 . _Integer
Just 10
>>>
"42" ^? _Integer
Just 42
_Integral :: (AsNumber t, Integral a) => Prism' t a #
Access Integer Value
s as Integrals.
>>>
"[10]" ^? nth 0 . _Integral
Just 10
>>>
"[10.5]" ^? nth 0 . _Integral
Just 10
_Bool :: AsValue t => Prism' t Bool #
>>>
"{\"a\": \"xyz\", \"b\": true}" ^? key "b" . _Bool
Just True
>>>
"{\"a\": \"xyz\", \"b\": true}" ^? key "a" . _Bool
Nothing
>>>
_Bool # True :: String
"true"
>>>
_Bool # False :: String
"false"
uuid
Type representing Universally Unique Identifiers (UUID) as specified in RFC 4122.
Instances
FromJSON UUID | |
FromJSONKey UUID | |
Defined in Data.Aeson.Types.FromJSON | |
ToJSON UUID | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSONKey UUID | |
Defined in Data.Aeson.Types.ToJSON | |
Data UUID | |
Defined in Data.UUID.Types.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UUID -> c UUID # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UUID # dataTypeOf :: UUID -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UUID) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UUID) # gmapT :: (forall b. Data b => b -> b) -> UUID -> UUID # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UUID -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UUID -> r # gmapQ :: (forall d. Data d => d -> u) -> UUID -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UUID -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UUID -> m UUID # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UUID -> m UUID # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UUID -> m UUID # | |
Storable UUID | This |
Defined in Data.UUID.Types.Internal | |
Read UUID | |
Show UUID | Pretty prints a
|
Binary UUID | This |
NFData UUID | |
Defined in Data.UUID.Types.Internal | |
Eq UUID | |
Ord UUID | |
Hashable UUID | |
Defined in Data.UUID.Types.Internal | |
FromHttpApiData UUID | |
Defined in Web.Internal.HttpApiData parseUrlPiece :: Text -> Either Text UUID # parseHeader :: ByteString -> Either Text UUID # | |
ToHttpApiData UUID | |
Defined in Web.Internal.HttpApiData toUrlPiece :: UUID -> Text # toEncodedUrlPiece :: UUID -> Builder # toHeader :: UUID -> ByteString # toQueryParam :: UUID -> Text # | |
Random UUID | This |
Uniform UUID | |
Defined in Data.UUID.Types.Internal uniformM :: StatefulGen g m => g -> m UUID # | |
Lift UUID | |
servant
class FromHttpApiData a where #
Parse value from HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
parseUrlPiece :: Text -> Either Text a #
Parse URL path piece.
parseHeader :: ByteString -> Either Text a #
Parse HTTP header value.
parseQueryParam :: Text -> Either Text a #
Parse query param value.
Instances
class ToHttpApiData a where #
Convert value to HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
toUrlPiece :: a -> Text #
Convert to URL path piece.
toEncodedUrlPiece :: a -> Builder #
Convert to a URL path piece, making sure to encode any special chars.
The default definition uses encodePathSegmentsRelative
,
but this may be overriden with a more efficient version.
toHeader :: a -> ByteString #
Convert to HTTP header value.
toQueryParam :: a -> Text #
Convert to query param value.
Instances
serialise
Types that are instances of the
class allow values
to be quickly encoded or decoded directly to a CBOR representation,
for object transmission or storage.Serialise
Since: serialise-0.2.0.0
Nothing
Definition for encoding a given type into a binary
representation, using the Encoding
.Monoid
Since: serialise-0.2.0.0
Definition of a given
for a type.Decoder
Since: serialise-0.2.0.0
encodeList :: [a] -> Encoding #
Utility to support specialised encoding for some list type -
used for
/Char
instances in this package.String
Since: serialise-0.2.0.0
decodeList :: Decoder s [a] #
Instances
serialise :: Serialise a => a -> ByteString #
Serialise a Haskell value to an external binary representation.
The output is represented as a lazy ByteString
and is constructed
incrementally.
Since: serialise-0.2.0.0
deserialise :: Serialise a => ByteString -> a #
Deserialise a Haskell value from the external binary representation
(which must have been made using serialise
or related function).
Throws:
if the given external
representation is invalid or does not correspond to a value of the
expected type.DeserialiseFailure
Since: serialise-0.2.0.0
deserialiseOrFail :: Serialise a => ByteString -> Either DeserialiseFailure a #
Deserialise a Haskell value from the external binary representation,
or get back a
.DeserialiseFailure
Since: serialise-0.2.0.0
time
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.
Instances
FromJSON UTCTime | |
FromJSONKey UTCTime | |
ToJSON UTCTime | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSONKey UTCTime | |
Defined in Data.Aeson.Types.ToJSON | |
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime # toConstr :: UTCTime -> Constr # dataTypeOf :: UTCTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
FromFormKey UTCTime | |
Defined in Web.Internal.FormUrlEncoded | |
ToFormKey UTCTime | |
Defined in Web.Internal.FormUrlEncoded | |
FromHttpApiData UTCTime |
|
Defined in Web.Internal.HttpApiData parseUrlPiece :: Text -> Either Text UTCTime # parseHeader :: ByteString -> Either Text UTCTime # | |
ToHttpApiData UTCTime |
|
Defined in Web.Internal.HttpApiData toUrlPiece :: UTCTime -> Text # toEncodedUrlPiece :: UTCTime -> Builder # toHeader :: UTCTime -> ByteString # toQueryParam :: UTCTime -> Text # | |
Serialise UTCTime |
Since: serialise-0.2.0.0 |
FromField UTCTime | |
Defined in Database.SQLite.Simple.FromField | |
ToField UTCTime | |
Defined in Database.SQLite.Simple.ToField |
getCurrentTime :: IO UTCTime #
Get the current UTCTime
from the system clock.
network
Basic type for a socket.
text bytestring containers
General-purpose finite sequences.
Instances
FromJSON1 Seq | |
ToJSON1 Seq | |
Defined in Data.Aeson.Types.ToJSON | |
MonadFix Seq | Since: containers-0.5.11 |
Defined in Data.Sequence.Internal | |
MonadZip Seq |
|
Foldable Seq | |
Defined in Data.Sequence.Internal fold :: Monoid m => Seq m -> m # foldMap :: Monoid m => (a -> m) -> Seq a -> m # foldMap' :: Monoid m => (a -> m) -> Seq a -> m # foldr :: (a -> b -> b) -> b -> Seq a -> b # foldr' :: (a -> b -> b) -> b -> Seq a -> b # foldl :: (b -> a -> b) -> b -> Seq a -> b # foldl' :: (b -> a -> b) -> b -> Seq a -> b # foldr1 :: (a -> a -> a) -> Seq a -> a # foldl1 :: (a -> a -> a) -> Seq a -> a # elem :: Eq a => a -> Seq a -> Bool # maximum :: Ord a => Seq a -> a # | |
Eq1 Seq | Since: containers-0.5.9 |
Ord1 Seq | Since: containers-0.5.9 |
Defined in Data.Sequence.Internal | |
Read1 Seq | Since: containers-0.5.9 |
Defined in Data.Sequence.Internal | |
Show1 Seq | Since: containers-0.5.9 |
Traversable Seq | |
Alternative Seq | Since: containers-0.5.4 |
Applicative Seq | Since: containers-0.5.4 |
Functor Seq | |
Monad Seq | |
MonadPlus Seq | |
UnzipWith Seq | |
Defined in Data.Sequence.Internal unzipWith' :: (x -> (a, b)) -> Seq x -> (Seq a, Seq b) | |
Hashable1 Seq | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
FoldableWithIndex Int Seq | |
FunctorWithIndex Int Seq | The position in the |
TraversableWithIndex Int Seq | |
FromJSON a => FromJSON (Seq a) | |
ToJSON a => ToJSON (Seq a) | |
Defined in Data.Aeson.Types.ToJSON | |
Data a => Data (Seq a) | |
Defined in Data.Sequence.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Seq a -> c (Seq a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Seq a) # dataTypeOf :: Seq a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Seq a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Seq a)) # gmapT :: (forall b. Data b => b -> b) -> Seq a -> Seq a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Seq a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Seq a -> r # gmapQ :: (forall d. Data d => d -> u) -> Seq a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Seq a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Seq a -> m (Seq a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Seq a -> m (Seq a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Seq a -> m (Seq a) # | |
a ~ Char => IsString (Seq a) | Since: containers-0.5.7 |
Defined in Data.Sequence.Internal fromString :: String -> Seq a # | |
Monoid (Seq a) | |
Semigroup (Seq a) | Since: containers-0.5.7 |
IsList (Seq a) | |
Read a => Read (Seq a) | |
Show a => Show (Seq a) | |
Binary e => Binary (Seq e) | |
NFData a => NFData (Seq a) | |
Defined in Data.Sequence.Internal | |
Eq a => Eq (Seq a) | |
Ord a => Ord (Seq a) | |
Hashable v => Hashable (Seq v) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
Ixed (Seq a) | |
Defined in Control.Lens.At | |
AsEmpty (Seq a) | |
Defined in Control.Lens.Empty | |
Reversing (Seq a) | |
Defined in Control.Lens.Internal.Iso | |
Wrapped (Seq a) | |
Ord a => Stream (Seq a) | Since: megaparsec-9.0.0 |
Defined in Text.Megaparsec.Stream tokenToChunk :: Proxy (Seq a) -> Token (Seq a) -> Tokens (Seq a) # tokensToChunk :: Proxy (Seq a) -> [Token (Seq a)] -> Tokens (Seq a) # chunkToTokens :: Proxy (Seq a) -> Tokens (Seq a) -> [Token (Seq a)] # chunkLength :: Proxy (Seq a) -> Tokens (Seq a) -> Int # chunkEmpty :: Proxy (Seq a) -> Tokens (Seq a) -> Bool # take1_ :: Seq a -> Maybe (Token (Seq a), Seq a) # takeN_ :: Int -> Seq a -> Maybe (Tokens (Seq a), Seq a) # takeWhile_ :: (Token (Seq a) -> Bool) -> Seq a -> (Tokens (Seq a), Seq a) # | |
Serialise a => Serialise (Seq a) | Since: serialise-0.2.0.0 |
t ~ Seq a' => Rewrapped (Seq a) t | |
Defined in Control.Lens.Wrapped | |
Cons (Seq a) (Seq b) a b | |
Snoc (Seq a) (Seq b) a b | |
Each (Seq a) (Seq b) a b |
|
type Item (Seq a) | |
Defined in Data.Sequence.Internal | |
type Index (Seq a) | |
Defined in Control.Lens.At | |
type IxValue (Seq a) | |
Defined in Control.Lens.At | |
type Unwrapped (Seq a) | |
Defined in Control.Lens.Wrapped | |
type Token (Seq a) | |
Defined in Text.Megaparsec.Stream | |
type Tokens (Seq a) | |
Defined in Text.Megaparsec.Stream |
A space efficient, packed, unboxed Unicode text type.
Instances
type LByteString = ByteString #
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.
Instances
data ShortByteString #
A compact representation of a Word8
vector.
It has a lower memory overhead than a ByteString
and does not
contribute to heap fragmentation. It can be converted to or from a
ByteString
(at the cost of copying the string data). It supports very few
other operations.
It is suitable for use as an internal representation for code that needs
to keep many short strings in memory, but it should not be used as an
interchange type. That is, it should not generally be used in public APIs.
The ByteString
type is usually more suitable for use in interfaces; it is
more flexible and it supports a wide range of operations.
Instances
A map of integers to values a
.
Instances
FromJSON1 IntMap | |
ToJSON1 IntMap | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> IntMap a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [IntMap a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> IntMap a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [IntMap a] -> Encoding # | |
Foldable IntMap | Folds in order of increasing key. |
Defined in Data.IntMap.Internal fold :: Monoid m => IntMap m -> m # foldMap :: Monoid m => (a -> m) -> IntMap a -> m # foldMap' :: Monoid m => (a -> m) -> IntMap a -> m # foldr :: (a -> b -> b) -> b -> IntMap a -> b # foldr' :: (a -> b -> b) -> b -> IntMap a -> b # foldl :: (b -> a -> b) -> b -> IntMap a -> b # foldl' :: (b -> a -> b) -> b -> IntMap a -> b # foldr1 :: (a -> a -> a) -> IntMap a -> a # foldl1 :: (a -> a -> a) -> IntMap a -> a # elem :: Eq a => a -> IntMap a -> Bool # maximum :: Ord a => IntMap a -> a # minimum :: Ord a => IntMap a -> a # | |
Eq1 IntMap | Since: containers-0.5.9 |
Ord1 IntMap | Since: containers-0.5.9 |
Defined in Data.IntMap.Internal | |
Read1 IntMap | Since: containers-0.5.9 |
Defined in Data.IntMap.Internal | |
Show1 IntMap | Since: containers-0.5.9 |
Traversable IntMap | Traverses in order of increasing key. |
Functor IntMap | |
TrieMap IntMap | |
Defined in GHC.Data.TrieMap | |
Hashable1 IntMap | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
FoldableWithIndex Int IntMap | |
Defined in WithIndex | |
FunctorWithIndex Int IntMap | |
TraversableWithIndex Int IntMap | |
TraverseMax Int IntMap | |
Defined in Control.Lens.Traversal traverseMax :: IndexedTraversal' Int (IntMap v) v # | |
TraverseMin Int IntMap | |
Defined in Control.Lens.Traversal traverseMin :: IndexedTraversal' Int (IntMap v) v # | |
FromJSON a => FromJSON (IntMap a) | |
ToJSON a => ToJSON (IntMap a) | |
Defined in Data.Aeson.Types.ToJSON | |
Data a => Data (IntMap a) | |
Defined in Data.IntMap.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IntMap a -> c (IntMap a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (IntMap a) # toConstr :: IntMap a -> Constr # dataTypeOf :: IntMap a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (IntMap a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (IntMap a)) # gmapT :: (forall b. Data b => b -> b) -> IntMap a -> IntMap a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IntMap a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IntMap a -> r # gmapQ :: (forall d. Data d => d -> u) -> IntMap a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IntMap a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IntMap a -> m (IntMap a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IntMap a -> m (IntMap a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IntMap a -> m (IntMap a) # | |
Monoid (IntMap a) | |
Semigroup (IntMap a) | Since: containers-0.5.7 |
IsList (IntMap a) | Since: containers-0.5.6.2 |
Read e => Read (IntMap e) | |
Show a => Show (IntMap a) | |
Binary e => Binary (IntMap e) | |
NFData a => NFData (IntMap a) | |
Defined in Data.IntMap.Internal | |
Outputable elt => Outputable (IntMap elt) | |
Defined in GHC.Utils.Outputable | |
Eq a => Eq (IntMap a) | |
Ord a => Ord (IntMap a) | |
Defined in Data.IntMap.Internal | |
Hashable v => Hashable (IntMap v) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
FromHttpApiData v => FromForm (IntMap [v]) | |
ToHttpApiData v => ToForm (IntMap [v]) | |
Defined in Web.Internal.FormUrlEncoded | |
At (IntMap a) | |
Ixed (IntMap a) | |
Defined in Control.Lens.At | |
AsEmpty (IntMap a) | |
Defined in Control.Lens.Empty | |
Wrapped (IntMap a) | |
Serialise a => Serialise (IntMap a) | Since: serialise-0.2.0.0 |
t ~ IntMap a' => Rewrapped (IntMap a) t | Use |
Defined in Control.Lens.Wrapped | |
Each (IntMap a) (IntMap b) a b |
|
type Key IntMap | |
Defined in GHC.Data.TrieMap | |
type Item (IntMap a) | |
Defined in Data.IntMap.Internal | |
type Index (IntMap a) | |
Defined in Control.Lens.At | |
type IxValue (IntMap a) | |
Defined in Control.Lens.At | |
type Unwrapped (IntMap a) | |
Defined in Control.Lens.Wrapped |
A set of integers.
Instances
FromJSON IntSet | |
ToJSON IntSet | |
Defined in Data.Aeson.Types.ToJSON | |
Data IntSet | |
Defined in Data.IntSet.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IntSet -> c IntSet # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IntSet # toConstr :: IntSet -> Constr # dataTypeOf :: IntSet -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IntSet) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IntSet) # gmapT :: (forall b. Data b => b -> b) -> IntSet -> IntSet # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IntSet -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IntSet -> r # gmapQ :: (forall d. Data d => d -> u) -> IntSet -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IntSet -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IntSet -> m IntSet # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IntSet -> m IntSet # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IntSet -> m IntSet # | |
Monoid IntSet | |
Semigroup IntSet | Since: containers-0.5.7 |
IsList IntSet | Since: containers-0.5.6.2 |
Read IntSet | |
Show IntSet | |
Binary IntSet | |
NFData IntSet | |
Defined in Data.IntSet.Internal | |
Outputable IntSet | |
Defined in GHC.Utils.Outputable | |
Eq IntSet | |
Ord IntSet | |
Hashable IntSet | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
At IntSet | |
Contains IntSet | |
Ixed IntSet | |
Defined in Control.Lens.At | |
AsEmpty IntSet | |
Defined in Control.Lens.Empty | |
Wrapped IntSet | |
Serialise IntSet | Since: serialise-0.2.0.0 |
t ~ IntSet => Rewrapped IntSet t | Use |
Defined in Control.Lens.Wrapped | |
type Item IntSet | |
Defined in Data.IntSet.Internal | |
type Index IntSet | |
Defined in Control.Lens.At | |
type IxValue IntSet | |
Defined in Control.Lens.At | |
type Unwrapped IntSet | |
Defined in Control.Lens.Wrapped |
A set of values a
.
Instances
ToJSON1 Set | |
Defined in Data.Aeson.Types.ToJSON | |
Foldable Set | Folds in order of increasing key. |
Defined in Data.Set.Internal fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Eq1 Set | Since: containers-0.5.9 |
Ord1 Set | Since: containers-0.5.9 |
Defined in Data.Set.Internal | |
Show1 Set | Since: containers-0.5.9 |
Hashable1 Set | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
OutputableP env a => OutputableP env (Set a) | |
Defined in GHC.Utils.Outputable | |
(Ord a, FromJSON a) => FromJSON (Set a) | |
ToJSON a => ToJSON (Set a) | |
Defined in Data.Aeson.Types.ToJSON | |
(Data a, Ord a) => Data (Set a) | |
Defined in Data.Set.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Set a -> c (Set a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Set a) # dataTypeOf :: Set a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Set a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Set a)) # gmapT :: (forall b. Data b => b -> b) -> Set a -> Set a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r # gmapQ :: (forall d. Data d => d -> u) -> Set a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Set a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # | |
Ord a => Monoid (Set a) | |
Ord a => Semigroup (Set a) | Since: containers-0.5.7 |
Ord a => IsList (Set a) | Since: containers-0.5.6.2 |
(Read a, Ord a) => Read (Set a) | |
Show a => Show (Set a) | |
Binary a => Binary (Set a) | |
NFData a => NFData (Set a) | |
Defined in Data.Set.Internal | |
Outputable a => Outputable (Set a) | |
Defined in GHC.Utils.Outputable | |
Eq a => Eq (Set a) | |
Ord a => Ord (Set a) | |
Hashable v => Hashable (Set v) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
Ord k => At (Set k) | |
Ord a => Contains (Set a) | |
Ord k => Ixed (Set k) | |
Defined in Control.Lens.At | |
AsEmpty (Set a) | |
Defined in Control.Lens.Empty | |
Ord a => Wrapped (Set a) | |
(Ord a, Serialise a) => Serialise (Set a) | Since: serialise-0.2.0.0 |
(t ~ Set a', Ord a) => Rewrapped (Set a) t | Use |
Defined in Control.Lens.Wrapped | |
type Item (Set a) | |
Defined in Data.Set.Internal | |
type Index (Set a) | |
Defined in Control.Lens.At | |
type IxValue (Set k) | |
Defined in Control.Lens.At | |
type Unwrapped (Set a) | |
Defined in Control.Lens.Wrapped |
A Map from keys k
to values a
.
The Semigroup
operation for Map
is union
, which prefers
values from the left operand. If m1
maps a key k
to a value
a1
, and m2
maps the same key to a different value a2
, then
their union m1 <> m2
maps k
to a1
.
Instances
Bifoldable Map | Since: containers-0.6.3.1 |
Eq2 Map | Since: containers-0.5.9 |
Ord2 Map | Since: containers-0.5.9 |
Defined in Data.Map.Internal | |
Show2 Map | Since: containers-0.5.9 |
Hashable2 Map | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
FoldableWithIndex k (Map k) | |
FunctorWithIndex k (Map k) | |
TraversableWithIndex k (Map k) | |
Ord k => TraverseMax k (Map k) | |
Defined in Control.Lens.Traversal traverseMax :: IndexedTraversal' k (Map k v) v # | |
Ord k => TraverseMin k (Map k) | |
Defined in Control.Lens.Traversal traverseMin :: IndexedTraversal' k (Map k v) v # | |
(OutputableP env key, OutputableP env elt) => OutputableP env (Map key elt) | |
Defined in GHC.Utils.Outputable | |
(FromJSONKey k, Ord k) => FromJSON1 (Map k) | |
ToJSONKey k => ToJSON1 (Map k) | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> Map k a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Map k a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Map k a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Map k a] -> Encoding # | |
Foldable (Map k) | Folds in order of increasing key. |
Defined in Data.Map.Internal fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldMap' :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # | |
Eq k => Eq1 (Map k) | Since: containers-0.5.9 |
Ord k => Ord1 (Map k) | Since: containers-0.5.9 |
Defined in Data.Map.Internal | |
(Ord k, Read k) => Read1 (Map k) | Since: containers-0.5.9 |
Defined in Data.Map.Internal | |
Show k => Show1 (Map k) | Since: containers-0.5.9 |
Traversable (Map k) | Traverses in order of increasing key. |
Functor (Map k) | |
Ord k => TrieMap (Map k) | |
Defined in GHC.Data.TrieMap | |
Hashable k => Hashable1 (Map k) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
(FromJSONKey k, Ord k, FromJSON v) => FromJSON (Map k v) | |
(ToJSON v, ToJSONKey k) => ToJSON (Map k v) | |
Defined in Data.Aeson.Types.ToJSON | |
(Data k, Data a, Ord k) => Data (Map k a) | |
Defined in Data.Map.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Map k a -> c (Map k a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Map k a) # toConstr :: Map k a -> Constr # dataTypeOf :: Map k a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Map k a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Map k a)) # gmapT :: (forall b. Data b => b -> b) -> Map k a -> Map k a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Map k a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Map k a -> r # gmapQ :: (forall d. Data d => d -> u) -> Map k a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Map k a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Map k a -> m (Map k a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Map k a -> m (Map k a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Map k a -> m (Map k a) # | |
Ord k => Monoid (Map k v) | |
Ord k => Semigroup (Map k v) | |
Ord k => IsList (Map k v) | Since: containers-0.5.6.2 |
(Ord k, Read k, Read e) => Read (Map k e) | |
(Show k, Show a) => Show (Map k a) | |
(Binary k, Binary e) => Binary (Map k e) | |
(NFData k, NFData a) => NFData (Map k a) | |
Defined in Data.Map.Internal | |
(Outputable key, Outputable elt) => Outputable (Map key elt) | |
Defined in GHC.Utils.Outputable | |
(Eq k, Eq a) => Eq (Map k a) | |
(Ord k, Ord v) => Ord (Map k v) | |
(Hashable k, Hashable v) => Hashable (Map k v) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
(Ord k, FromFormKey k, FromHttpApiData v) => FromForm (Map k [v]) | |
(ToFormKey k, ToHttpApiData v) => ToForm (Map k [v]) | |
Defined in Web.Internal.FormUrlEncoded | |
Ord k => At (Map k a) | |
Ord k => Ixed (Map k a) | |
Defined in Control.Lens.At | |
AsEmpty (Map k a) | |
Defined in Control.Lens.Empty | |
Ord k => Wrapped (Map k a) | |
(Ord k, Serialise k, Serialise v) => Serialise (Map k v) | Since: serialise-0.2.0.0 |
(t ~ Map k' a', Ord k) => Rewrapped (Map k a) t | Use |
Defined in Control.Lens.Wrapped | |
c ~ d => Each (Map c a) (Map d b) a b |
|
type Key (Map k) | |
Defined in GHC.Data.TrieMap | |
type Item (Map k v) | |
Defined in Data.Map.Internal | |
type Index (Map k a) | |
Defined in Control.Lens.At | |
type IxValue (Map k a) | |
Defined in Control.Lens.At | |
type Unwrapped (Map k a) | |
Defined in Control.Lens.Wrapped |
A map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
Instances
Bifoldable HashMap | Since: unordered-containers-0.2.11 |
Eq2 HashMap | |
Ord2 HashMap | |
Defined in Data.HashMap.Internal | |
Show2 HashMap | |
NFData2 HashMap | Since: unordered-containers-0.2.14.0 |
Defined in Data.HashMap.Internal | |
Hashable2 HashMap | |
Defined in Data.HashMap.Internal | |
(Lift k, Lift v) => Lift (HashMap k v :: Type) | Since: unordered-containers-0.2.17.0 |
(FromJSONKey k, Eq k, Hashable k) => FromJSON1 (HashMap k) | |
ToJSONKey k => ToJSON1 (HashMap k) | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> HashMap k a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [HashMap k a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> HashMap k a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [HashMap k a] -> Encoding # | |
Foldable (HashMap k) | |
Defined in Data.HashMap.Internal fold :: Monoid m => HashMap k m -> m # foldMap :: Monoid m => (a -> m) -> HashMap k a -> m # foldMap' :: Monoid m => (a -> m) -> HashMap k a -> m # foldr :: (a -> b -> b) -> b -> HashMap k a -> b # foldr' :: (a -> b -> b) -> b -> HashMap k a -> b # foldl :: (b -> a -> b) -> b -> HashMap k a -> b # foldl' :: (b -> a -> b) -> b -> HashMap k a -> b # foldr1 :: (a -> a -> a) -> HashMap k a -> a # foldl1 :: (a -> a -> a) -> HashMap k a -> a # toList :: HashMap k a -> [a] # length :: HashMap k a -> Int # elem :: Eq a => a -> HashMap k a -> Bool # maximum :: Ord a => HashMap k a -> a # minimum :: Ord a => HashMap k a -> a # | |
Eq k => Eq1 (HashMap k) | |
Ord k => Ord1 (HashMap k) | |
Defined in Data.HashMap.Internal | |
(Eq k, Hashable k, Read k) => Read1 (HashMap k) | |
Defined in Data.HashMap.Internal | |
Show k => Show1 (HashMap k) | |
Traversable (HashMap k) | |
Functor (HashMap k) | |
NFData k => NFData1 (HashMap k) | Since: unordered-containers-0.2.14.0 |
Defined in Data.HashMap.Internal | |
Hashable k => Hashable1 (HashMap k) | |
Defined in Data.HashMap.Internal | |
(FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON (HashMap k v) | |
(ToJSON v, ToJSONKey k) => ToJSON (HashMap k v) | |
Defined in Data.Aeson.Types.ToJSON | |
(Data k, Data v, Eq k, Hashable k) => Data (HashMap k v) | |
Defined in Data.HashMap.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HashMap k v -> c (HashMap k v) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HashMap k v) # toConstr :: HashMap k v -> Constr # dataTypeOf :: HashMap k v -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HashMap k v)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HashMap k v)) # gmapT :: (forall b. Data b => b -> b) -> HashMap k v -> HashMap k v # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HashMap k v -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HashMap k v -> r # gmapQ :: (forall d. Data d => d -> u) -> HashMap k v -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HashMap k v -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HashMap k v -> m (HashMap k v) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HashMap k v -> m (HashMap k v) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HashMap k v -> m (HashMap k v) # | |
(Eq k, Hashable k) => Monoid (HashMap k v) | If a key occurs in both maps, the mapping from the first will be the mapping in the result. Examples
|
(Eq k, Hashable k) => Semigroup (HashMap k v) | If a key occurs in both maps, the mapping from the first will be the mapping in the result. Examples
|
(Eq k, Hashable k) => IsList (HashMap k v) | |
(Eq k, Hashable k, Read k, Read e) => Read (HashMap k e) | |
(Show k, Show v) => Show (HashMap k v) | |
(NFData k, NFData v) => NFData (HashMap k v) | |
Defined in Data.HashMap.Internal | |
(Eq k, Eq v) => Eq (HashMap k v) | Note that, in the presence of hash collisions, equal
In general, the lack of substitutivity can be observed with any function that depends on the key ordering, such as folds and traversals. |
(Ord k, Ord v) => Ord (HashMap k v) | The ordering is total and consistent with the |
Defined in Data.HashMap.Internal | |
(Hashable k, Hashable v) => Hashable (HashMap k v) | |
Defined in Data.HashMap.Internal | |
(Eq k, Hashable k, FromFormKey k, FromHttpApiData v) => FromForm (HashMap k [v]) | |
(ToFormKey k, ToHttpApiData v) => ToForm (HashMap k [v]) | |
Defined in Web.Internal.FormUrlEncoded | |
(Eq k, Hashable k) => At (HashMap k a) | |
(Eq k, Hashable k) => Ixed (HashMap k a) | |
Defined in Control.Lens.At | |
AsEmpty (HashMap k a) | |
Defined in Control.Lens.Empty | |
(Hashable k, Eq k) => Wrapped (HashMap k a) | |
(Serialise k, Hashable k, Eq k, Serialise v) => Serialise (HashMap k v) | Since: serialise-0.2.0.0 |
(t ~ HashMap k' a', Hashable k, Eq k) => Rewrapped (HashMap k a) t | Use |
Defined in Control.Lens.Wrapped | |
c ~ d => Each (HashMap c a) (HashMap d b) a b |
|
type Item (HashMap k v) | |
Defined in Data.HashMap.Internal | |
type Index (HashMap k a) | |
Defined in Control.Lens.At | |
type IxValue (HashMap k a) | |
Defined in Control.Lens.At | |
type Unwrapped (HashMap k a) | |
Defined in Control.Lens.Wrapped |
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
Instances
module Data.Text.Encoding
module Data.Text.Encoding.Error
base extra
type RawFilePath = ByteString #
A literal POSIX file path
fromList :: IsList l => [Item l] -> l #
The fromList
function constructs the structure l
from the given
list of Item l
Case analysis for the Bool
type.
evaluates to bool
x y px
when p
is False
, and evaluates to y
when p
is True
.
This is equivalent to if p then y else x
; that is, one can
think of it as an if-then-else construct with its arguments
reordered.
Examples
Basic usage:
>>>
bool "foo" "bar" True
"bar">>>
bool "foo" "bar" False
"foo"
Confirm that
and bool
x y pif p then y else x
are
equivalent:
>>>
let p = True; x = "bar"; y = "foo"
>>>
bool x y p == if p then y else x
True>>>
let p = False
>>>
bool x y p == if p then y else x
True
Since: base-4.7.0.0
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () #
Map each element of a structure to an Applicative
action, evaluate these
actions from left to right, and ignore the results. For a version that
doesn't ignore the results see traverse
.
traverse_
is just like mapM_
, but generalised to Applicative
actions.
Examples
Basic usage:
>>>
traverse_ print ["Hello", "world", "!"]
"Hello" "world" "!"
module Control.Applicative
module Control.Monad
module Control.Monad.Reader
module Data.Bifunctor
module Data.Char
module Data.Coerce
module Data.Dynamic
module Data.Either
module Data.Functor.Identity
module Data.Int
module Data.Maybe
module Data.Monoid
module Data.Proxy
module Data.Void
module Data.Word
module Debug.Trace
module Foreign.C.Types
module GHC.Stack
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
Instances
class HasField (x :: k) r a | x r -> a where #
Constraint representing the fact that the field x
belongs to
the record type r
and has field type a
. This will be solved
automatically, but manual instances may be provided as well.
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
A ThreadId
is an abstract type representing a handle to a thread.
ThreadId
is an instance of Eq
, Ord
and Show
, where
the Ord
instance implements an arbitrary total ordering over
ThreadId
s. The Show
instance lets you convert an arbitrary-valued
ThreadId
to string form; showing a ThreadId
value is occasionally
useful when debugging or diagnosing the behaviour of a concurrent
program.
Note: in GHC, if you have a ThreadId
, you essentially have
a pointer to the thread itself. This means the thread itself can't be
garbage collected until you drop the ThreadId
.
This misfeature will hopefully be corrected at a later date.
Instances
Show ThreadId | Since: base-4.2.0.0 |
Eq ThreadId | Since: base-4.2.0.0 |
Ord ThreadId | Since: base-4.2.0.0 |
Defined in GHC.Conc.Sync | |
Hashable ThreadId | |
Defined in Data.Hashable.Class |
myThreadId :: IO ThreadId #
Returns the ThreadId
of the calling thread (GHC only).
threadDelay :: Int -> IO () #
Suspends the current thread for a given number of microseconds (GHC only).
There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will never continue to run earlier than specified.
readMaybe :: Read a => String -> Maybe a #
Parse a string using the Read
instance.
Succeeds if there is exactly one valid result.
>>>
readMaybe "123" :: Maybe Int
Just 123
>>>
readMaybe "hello" :: Maybe Int
Nothing
Since: base-4.6.0.0
Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).
fromString :: String -> a #
Instances
toList :: Foldable t => t a -> [a] #
List of elements of a structure, from left to right. If the entire list is intended to be reduced via a fold, just fold the structure directly bypassing the list.
Examples
Basic usage:
>>>
toList Nothing
[]
>>>
toList (Just 42)
[42]
>>>
toList (Left "foo")
[]
>>>
toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
[5,17,12,8]
For lists, toList
is the identity:
>>>
toList [1, 2, 3]
[1,2,3]
Since: base-4.8.0.0