xlsx-tabular-0.2.2.1: Xlsx table cell value extraction utility

Safe HaskellNone
LanguageHaskell2010

Codec.Xlsx.Util.Tabular.Imports

Description

Internal imports.

Synopsis

Documentation

join :: Monad m => m (m a) -> m a #

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.

find :: Foldable t => (a -> Bool) -> t a -> Maybe a #

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

fromMaybe :: a -> Maybe a -> a #

The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:

>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""

Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:

>>> import Text.Read ( readMaybe )
>>> fromMaybe 0 (readMaybe "5")
5
>>> fromMaybe 0 (readMaybe "")
0

isJust :: Maybe a -> Bool #

The isJust function returns True iff its argument is of the form Just _.

Examples

Basic usage:

>>> isJust (Just 3)
True
>>> isJust (Just ())
True
>>> isJust Nothing
False

Only the outer constructor is taken into consideration:

>>> isJust (Just Nothing)
True

keys :: Map k a -> [k] #

O(n). Return all keys of the map in ascending order. Subject to list fusion.

keys (fromList [(5,"a"), (3,"b")]) == [3,5]
keys empty == []

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #

An infix synonym for fmap.

The name of this operator is an allusion to $. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas $ is function application, <$> is function application lifted over a Functor.

Examples

Convert from a Maybe Int to a Maybe String using show:

>>> show <$> Nothing
Nothing
>>> show <$> Just 3
Just "3"

Convert from an Either Int Int to an Either Int String using show:

>>> show <$> Left 17
Left 17
>>> show <$> Right 17
Right "17"

Double each element of a list:

>>> (*2) <$> [1,2,3]
[2,4,6]

Apply even to the second element of a pair:

>>> even <$> (2,2)
(2,True)

(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b infixl 4 #

Sequential application.

A few functors support an implementation of <*> that is more efficient than the default one.

view :: MonadReader s m => Getting a s a -> m a #

View the value pointed to by a Getter, Iso or Lens or the result of folding over all the results of a Fold or Traversal that points at a monoidal value.

view . toid
>>> view (to f) a
f a
>>> view _2 (1,"hello")
"hello"
>>> view (to succ) 5
6
>>> view (_2._1) ("hello",("world","!!!"))
"world"

As view is commonly used to access the target of a Getter or obtain a monoidal summary of the targets of a Fold, It may be useful to think of it as having one of these more restricted signatures:

view ::             Getter s a     -> s -> a
view :: Monoid m => Fold s m       -> s -> m
view ::             Iso' s a       -> s -> a
view ::             Lens' s a      -> s -> a
view :: Monoid m => Traversal' s m -> s -> m

In a more general setting, such as when working with a Monad transformer stack you can use:

view :: MonadReader s m             => Getter s a     -> m a
view :: (MonadReader s m, Monoid a) => Fold s a       -> m a
view :: MonadReader s m             => Iso' s a       -> m a
view :: MonadReader s m             => Lens' s a      -> m a
view :: (MonadReader s m, Monoid a) => Traversal' s a -> m a

to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' * * p f s 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

contains :: Contains m => Index m -> Lens' m Bool #

>>> IntSet.fromList [1,2,3,4] ^. contains 3
True
>>> IntSet.fromList [1,2,3,4] ^. contains 5
False
>>> IntSet.fromList [1,2,3,4] & contains 3 .~ False
fromList [1,2,4]

(^.) :: s -> Getting a s a -> a infixl 8 #

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

>>> Left 4 ^?_Left
Just 4
>>> Right 4 ^?_Left
Nothing
>>> "world" ^? ix 3
Just 'l'
>>> "world" ^? ix 20
Nothing
(^?) ≡ flip preview
(^?) :: 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

(.~) :: 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

(?~) :: ASetter s t a (Maybe b) -> b -> 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)]
(?~) :: 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

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

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

Since: 4.8.0.0

_1 :: Field1 s t a b => Lens s t a b #

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'

_2 :: Field2 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

_Right :: (Choice p, Applicative f) => p a (f b) -> p (Either c a) (f (Either c b)) #

This Prism provides a Traversal for tweaking the Right half of an Either:

>>> over _Right (+1) (Left 2)
Left 2
>>> over _Right (+1) (Right 2)
Right 3
>>> Right "hello" ^._Right
"hello"
>>> Left "hello" ^._Right :: [Double]
[]

It also can be turned around to obtain the embedding into the Right half of an Either:

>>> _Right # 5
Right 5
>>> 5^.re _Right
Right 5

data Text :: * #

A space efficient, packed, unboxed Unicode text type.

Instances

ToJSON Text 
KeyValue Pair 

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

ToJSONKey Text 
FromJSON Text 
FromJSONKey Text 
Ixed Text 
SemiSequence Text 

Associated Types

type Index Text :: * #

IsSequence Text 

Methods

fromList :: [Element Text] -> Text #

lengthIndex :: Text -> Index Text #

break :: (Element Text -> Bool) -> Text -> (Text, Text) #

span :: (Element Text -> Bool) -> Text -> (Text, Text) #

dropWhile :: (Element Text -> Bool) -> Text -> Text #

takeWhile :: (Element Text -> Bool) -> Text -> Text #

splitAt :: Index Text -> Text -> (Text, Text) #

unsafeSplitAt :: Index Text -> Text -> (Text, Text) #

take :: Index Text -> Text -> Text #

unsafeTake :: Index Text -> Text -> Text #

drop :: Index Text -> Text -> Text #

unsafeDrop :: Index Text -> Text -> Text #

dropEnd :: Index Text -> Text -> Text #

partition :: (Element Text -> Bool) -> Text -> (Text, Text) #

uncons :: Text -> Maybe (Element Text, Text) #

unsnoc :: Text -> Maybe (Text, Element Text) #

filter :: (Element Text -> Bool) -> Text -> Text #

filterM :: Monad m => (Element Text -> m Bool) -> Text -> m Text #

replicate :: Index Text -> Element Text -> Text #

replicateM :: Monad m => Index Text -> m (Element Text) -> m Text #

groupBy :: (Element Text -> Element Text -> Bool) -> Text -> [Text] #

groupAllOn :: Eq b => (Element Text -> b) -> Text -> [Text] #

subsequences :: Text -> [Text] #

permutations :: Text -> [Text] #

tailEx :: Text -> Text #

tailMay :: Text -> Maybe Text #

initEx :: Text -> Text #

initMay :: Text -> Maybe Text #

unsafeTail :: Text -> Text #

unsafeInit :: Text -> Text #

index :: Text -> Index Text -> Maybe (Element Text) #

indexEx :: Text -> Index Text -> Element Text #

unsafeIndex :: Text -> Index Text -> Element Text #

splitWhen :: (Element Text -> Bool) -> Text -> [Text] #

Textual Text 

Methods

words :: Text -> [Text] #

unwords :: ((* ~ Element seq) Text, MonoFoldable seq) => seq -> Text #

lines :: Text -> [Text] #

unlines :: ((* ~ Element seq) Text, MonoFoldable seq) => seq -> Text #

toLower :: Text -> Text #

toUpper :: Text -> Text #

toCaseFold :: Text -> Text #

breakWord :: Text -> (Text, Text) #

breakLine :: Text -> (Text, Text) #

MonoFunctor Text 

Methods

omap :: (Element Text -> Element Text) -> Text -> Text #

MonoFoldable Text 

Methods

ofoldMap :: Monoid m => (Element Text -> m) -> Text -> m #

ofoldr :: (Element Text -> b -> b) -> b -> Text -> b #

ofoldl' :: (a -> Element Text -> a) -> a -> Text -> a #

otoList :: Text -> [Element Text] #

oall :: (Element Text -> Bool) -> Text -> Bool #

oany :: (Element Text -> Bool) -> Text -> Bool #

onull :: Text -> Bool #

olength :: Text -> Int #

olength64 :: Text -> Int64 #

ocompareLength :: Integral i => Text -> i -> Ordering #

otraverse_ :: Applicative f => (Element Text -> f b) -> Text -> f () #

ofor_ :: Applicative f => Text -> (Element Text -> f b) -> f () #

omapM_ :: Applicative m => (Element Text -> m ()) -> Text -> m () #

oforM_ :: Applicative m => Text -> (Element Text -> m ()) -> m () #

ofoldlM :: Monad m => (a -> Element Text -> m a) -> a -> Text -> m a #

ofoldMap1Ex :: Semigroup m => (Element Text -> m) -> Text -> m #

ofoldr1Ex :: (Element Text -> Element Text -> Element Text) -> Text -> Element Text #

ofoldl1Ex' :: (Element Text -> Element Text -> Element Text) -> Text -> Element Text #

headEx :: Text -> Element Text #

lastEx :: Text -> Element Text #

unsafeHead :: Text -> Element Text #

unsafeLast :: Text -> Element Text #

maximumByEx :: (Element Text -> Element Text -> Ordering) -> Text -> Element Text #

minimumByEx :: (Element Text -> Element Text -> Ordering) -> Text -> Element Text #

oelem :: Element Text -> Text -> Bool #

onotElem :: Element Text -> Text -> Bool #

MonoTraversable Text 

Methods

otraverse :: Applicative f => (Element Text -> f (Element Text)) -> Text -> f Text #

omapM :: Applicative m => (Element Text -> m (Element Text)) -> Text -> m Text #

MonoPointed Text 

Methods

opoint :: Element Text -> Text #

GrowingAppend Text 
FromAttrVal Text 
LazySequence Text Text 
Utf8 Text ByteString 
FromPairs Value (DList Pair) 

Methods

fromPairs :: DList Pair -> Value

ToJSON v => GKeyValue v (DList Pair) 

Methods

gPair :: String -> v -> DList Pair

type Item Text 
type Item Text = Char
type Index Text 
type Index Text = Int
type IxValue Text 
type Index Text 
type Index Text = Int
type Element Text 

data IntSet :: * #

A set of integers.

Instances

IsList IntSet 

Associated Types

type Item IntSet :: * #

Eq IntSet 

Methods

(==) :: IntSet -> IntSet -> Bool #

(/=) :: IntSet -> IntSet -> Bool #

Data IntSet 

Methods

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 :: (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 #

Ord IntSet 
Read IntSet 
Show IntSet 
Semigroup IntSet 
Monoid IntSet 
ToJSON IntSet 
FromJSON IntSet 
NFData IntSet 

Methods

rnf :: IntSet -> () #

Contains IntSet 
Ixed IntSet 
At IntSet 
Wrapped IntSet 

Associated Types

type Unwrapped IntSet :: * #

MonoFoldable IntSet 

Methods

ofoldMap :: Monoid m => (Element IntSet -> m) -> IntSet -> m #

ofoldr :: (Element IntSet -> b -> b) -> b -> IntSet -> b #

ofoldl' :: (a -> Element IntSet -> a) -> a -> IntSet -> a #

otoList :: IntSet -> [Element IntSet] #

oall :: (Element IntSet -> Bool) -> IntSet -> Bool #

oany :: (Element IntSet -> Bool) -> IntSet -> Bool #

onull :: IntSet -> Bool #

olength :: IntSet -> Int #

olength64 :: IntSet -> Int64 #

ocompareLength :: Integral i => IntSet -> i -> Ordering #

otraverse_ :: Applicative f => (Element IntSet -> f b) -> IntSet -> f () #

ofor_ :: Applicative f => IntSet -> (Element IntSet -> f b) -> f () #

omapM_ :: Applicative m => (Element IntSet -> m ()) -> IntSet -> m () #

oforM_ :: Applicative m => IntSet -> (Element IntSet -> m ()) -> m () #

ofoldlM :: Monad m => (a -> Element IntSet -> m a) -> a -> IntSet -> m a #

ofoldMap1Ex :: Semigroup m => (Element IntSet -> m) -> IntSet -> m #

ofoldr1Ex :: (Element IntSet -> Element IntSet -> Element IntSet) -> IntSet -> Element IntSet #

ofoldl1Ex' :: (Element IntSet -> Element IntSet -> Element IntSet) -> IntSet -> Element IntSet #

headEx :: IntSet -> Element IntSet #

lastEx :: IntSet -> Element IntSet #

unsafeHead :: IntSet -> Element IntSet #

unsafeLast :: IntSet -> Element IntSet #

maximumByEx :: (Element IntSet -> Element IntSet -> Ordering) -> IntSet -> Element IntSet #

minimumByEx :: (Element IntSet -> Element IntSet -> Ordering) -> IntSet -> Element IntSet #

oelem :: Element IntSet -> IntSet -> Bool #

onotElem :: Element IntSet -> IntSet -> Bool #

MonoPointed IntSet 
GrowingAppend IntSet 
(~) * t IntSet => Rewrapped IntSet t

Use wrapping fromList. unwrapping returns a sorted list.

type Item IntSet 
type Item IntSet = Key
type Index IntSet 
type IxValue IntSet 
type IxValue IntSet = ()
type Unwrapped IntSet 
type Element IntSet 

fromList :: [Key] -> IntSet #

O(n*min(n,W)). Create a set from a list of integers.

member :: Key -> IntSet -> Bool #

O(min(n,W)). Is the value a member of the set?

class FromJSON a where #

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:

  • empty and mzero work, but are terse and uninformative;
  • fail yields a custom error message;
  • typeMismatch produces an informative message for cases when the value encountered is not of the expected type.

An example type and instance using typeMismatch:

-- 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 mzero to fail, but typeMismatch
    -- gives a much more informative error message.
    parseJSON invalid    = typeMismatch "Coord" invalid

For this common case of only being concerned with a single type of JSON value, the functions withObject, withNumber, 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:

  • 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 Generic clause to your datatype and declare a FromJSON instance for your datatype without giving a definition for parseJSON.

For example, the previous example can be simplified to just:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance FromJSON Coord

The default implementation will be equivalent to parseJSON = genericParseJSON defaultOptions; If you need different options, you can customize the generic decoding by defining:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance FromJSON Coord where
    parseJSON = genericParseJSON customOptions

Methods

parseJSON :: Value -> Parser a #

Instances

FromJSON Bool 
FromJSON Char 
FromJSON Double 
FromJSON Float 
FromJSON Int 
FromJSON Int8 
FromJSON Int16 
FromJSON Int32 
FromJSON Int64 
FromJSON Integer

WARNING: Only parse Integers from trusted input since an attacker could easily fill up the memory of the target system by specifying a scientific number with a big exponent like 1e1000000000.

FromJSON Natural 
FromJSON Ordering 
FromJSON Word 
FromJSON Word8 
FromJSON Word16 
FromJSON Word32 
FromJSON Word64 
FromJSON () 

Methods

parseJSON :: Value -> Parser () #

parseJSONList :: Value -> Parser [()] #

FromJSON Scientific 
FromJSON Number 
FromJSON Text 
FromJSON UTCTime 
FromJSON Value 
FromJSON DotNetTime 
FromJSON Text 
FromJSON Version 
FromJSON CTime 
FromJSON IntSet 
FromJSON ZonedTime

Supported string formats:

YYYY-MM-DD HH:MM Z YYYY-MM-DD HH:MM:SS Z YYYY-MM-DD HH:MM:SS.SSS Z

The first space may instead be a T, and the second space is optional. The Z represents UTC. The Z may be replaced with a time zone offset of the form +0000 or -08:00, where the first two digits are hours, the : is optional and the second two digits (also optional) are minutes.

FromJSON LocalTime 
FromJSON TimeOfDay 
FromJSON NominalDiffTime

WARNING: Only parse lengths of time from trusted input since an attacker could easily fill up the memory of the target system by specifying a scientific number with a big exponent like 1e1000000000.

FromJSON DiffTime

WARNING: Only parse lengths of time from trusted input since an attacker could easily fill up the memory of the target system by specifying a scientific number with a big exponent like 1e1000000000.

FromJSON Day 
FromJSON UUID 
FromJSON a => FromJSON [a] 

Methods

parseJSON :: Value -> Parser [a] #

parseJSONList :: Value -> Parser [[a]] #

FromJSON a => FromJSON (Maybe a) 
(FromJSON a, Integral a) => FromJSON (Ratio a) 
HasResolution a => FromJSON (Fixed a)

WARNING: Only parse fixed-precision numbers from trusted input since an attacker could easily fill up the memory of the target system by specifying a scientific number with a big exponent like 1e1000000000.

FromJSON a => FromJSON (Min a) 

Methods

parseJSON :: Value -> Parser (Min a) #

parseJSONList :: Value -> Parser [Min a] #

FromJSON a => FromJSON (Max a) 

Methods

parseJSON :: Value -> Parser (Max a) #

parseJSONList :: Value -> Parser [Max a] #

FromJSON a => FromJSON (First a) 
FromJSON a => FromJSON (Last a) 
FromJSON a => FromJSON (WrappedMonoid a) 
FromJSON a => FromJSON (Option a) 
FromJSON a => FromJSON (NonEmpty a) 
FromJSON a => FromJSON (Identity a) 
FromJSON a => FromJSON (Dual a) 
FromJSON a => FromJSON (First a) 
FromJSON a => FromJSON (Last a) 
FromJSON a => FromJSON (IntMap a) 
FromJSON v => FromJSON (Tree v) 
FromJSON a => FromJSON (Seq a) 

Methods

parseJSON :: Value -> Parser (Seq a) #

parseJSONList :: Value -> Parser [Seq a] #

(Ord a, FromJSON a) => FromJSON (Set a) 

Methods

parseJSON :: Value -> Parser (Set a) #

parseJSONList :: Value -> Parser [Set a] #

FromJSON a => FromJSON (DList a) 
(Prim a, FromJSON a) => FromJSON (Vector a) 
(Storable a, FromJSON a) => FromJSON (Vector a) 
(Vector Vector a, FromJSON a) => FromJSON (Vector a) 
(Eq a, Hashable a, FromJSON a) => FromJSON (HashSet a) 
FromJSON a => FromJSON (Vector a) 
(FromJSON a, FromJSON b) => FromJSON (Either a b) 

Methods

parseJSON :: Value -> Parser (Either a b) #

parseJSONList :: Value -> Parser [Either a b] #

(FromJSON a, FromJSON b) => FromJSON (a, b) 

Methods

parseJSON :: Value -> Parser (a, b) #

parseJSONList :: Value -> Parser [(a, b)] #

(FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON (HashMap k v) 
(FromJSONKey k, Ord k, FromJSON v) => FromJSON (Map k v) 

Methods

parseJSON :: Value -> Parser (Map k v) #

parseJSONList :: Value -> Parser [Map k v] #

FromJSON (Proxy k a) 

Methods

parseJSON :: Value -> Parser (Proxy k a) #

parseJSONList :: Value -> Parser [Proxy k a] #

(FromJSON a, FromJSON b, FromJSON c) => FromJSON (a, b, c) 

Methods

parseJSON :: Value -> Parser (a, b, c) #

parseJSONList :: Value -> Parser [(a, b, c)] #

FromJSON a => FromJSON (Const k a b) 

Methods

parseJSON :: Value -> Parser (Const k a b) #

parseJSONList :: Value -> Parser [Const k a b] #

FromJSON b => FromJSON (Tagged k a b) 

Methods

parseJSON :: Value -> Parser (Tagged k a b) #

parseJSONList :: Value -> Parser [Tagged k a b] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON (a, b, c, d) 

Methods

parseJSON :: Value -> Parser (a, b, c, d) #

parseJSONList :: Value -> Parser [(a, b, c, d)] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Product * f g a) 

Methods

parseJSON :: Value -> Parser (Product * f g a) #

parseJSONList :: Value -> Parser [Product * f g a] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Sum * f g a) 

Methods

parseJSON :: Value -> Parser (Sum * f g a) #

parseJSONList :: Value -> Parser [Sum * f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON (a, b, c, d, e) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e) #

parseJSONList :: Value -> Parser [(a, b, c, d, e)] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Compose * * f g a) 

Methods

parseJSON :: Value -> Parser (Compose * * f g a) #

parseJSONList :: Value -> Parser [Compose * * f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON (a, b, c, d, e, f) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON (a, b, c, d, e, f, g) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON (a, b, c, d, e, f, g, h) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON (a, b, c, d, e, f, g, h, i) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON (a, b, c, d, e, f, g, h, i, j) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON (a, b, c, d, e, f, g, h, i, j, k) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n, FromJSON o) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] #

class ToJSON a where #

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:

  • 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 Generic clause to your datatype and declare a ToJSON instance. If you require nothing other than defaultOptions, it is sufficient to write (and this is the only alternative where the default toJSON implementation is sufficient):

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance ToJSON Coord where
    toEncoding = genericToEncoding defaultOptions

If on the other hand you wish to customize the generic decoding, you have to implement both methods:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance ToJSON Coord where
    toJSON     = genericToJSON customOptions
    toEncoding = genericToEncoding customOptions

Previous versions of this library only had the toJSON method. Adding toEncoding had to reasons:

  1. toEncoding is more efficient for the common case that the output of toJSON is directly serialized to a ByteString. Further, expressing either method in terms of the other would be non-optimal.
  2. The choice of defaults allows a smooth transition for existing users: Existing instances that do not define toEncoding still compile and have the correct semantics. This is ensured by making the default implementation of toEncoding use toJSON. This produces correct results, but since it performs an intermediate conversion to a Value, it will be less efficient than directly emitting an Encoding. (this also means that specifying nothing more than instance ToJSON Coord would be sufficient as a generically decoding instance, but there probably exists no good reason to not specify toEncoding in new instances.)

Methods

toJSON :: a -> Value #

Convert a Haskell value to a JSON-friendly intermediate type.

Instances

ToJSON Bool 
ToJSON Char 
ToJSON Double 
ToJSON Float 
ToJSON Int 
ToJSON Int8 
ToJSON Int16 
ToJSON Int32 
ToJSON Int64 
ToJSON Integer 
ToJSON Natural 
ToJSON Ordering 
ToJSON Word 
ToJSON Word8 
ToJSON Word16 
ToJSON Word32 
ToJSON Word64 
ToJSON () 

Methods

toJSON :: () -> Value #

toEncoding :: () -> Encoding #

toJSONList :: [()] -> Value #

toEncodingList :: [()] -> Encoding #

ToJSON Scientific 
ToJSON Number 
ToJSON Text 
ToJSON UTCTime 
ToJSON Value 
ToJSON DotNetTime 
ToJSON Text 
ToJSON Version 
ToJSON CTime 
ToJSON IntSet 
ToJSON ZonedTime 
ToJSON LocalTime 
ToJSON TimeOfDay 
ToJSON NominalDiffTime 
ToJSON DiffTime 
ToJSON Day 
ToJSON UUID 
ToJSON a => ToJSON [a] 

Methods

toJSON :: [a] -> Value #

toEncoding :: [a] -> Encoding #

toJSONList :: [[a]] -> Value #

toEncodingList :: [[a]] -> Encoding #

ToJSON a => ToJSON (Maybe a) 
(ToJSON a, Integral a) => ToJSON (Ratio a) 
HasResolution a => ToJSON (Fixed a) 
ToJSON a => ToJSON (Min a) 

Methods

toJSON :: Min a -> Value #

toEncoding :: Min a -> Encoding #

toJSONList :: [Min a] -> Value #

toEncodingList :: [Min a] -> Encoding #

ToJSON a => ToJSON (Max a) 

Methods

toJSON :: Max a -> Value #

toEncoding :: Max a -> Encoding #

toJSONList :: [Max a] -> Value #

toEncodingList :: [Max a] -> Encoding #

ToJSON a => ToJSON (First a) 
ToJSON a => ToJSON (Last a) 
ToJSON a => ToJSON (WrappedMonoid a) 
ToJSON a => ToJSON (Option a) 
ToJSON a => ToJSON (NonEmpty a) 
ToJSON a => ToJSON (Identity a) 
ToJSON a => ToJSON (Dual a) 
ToJSON a => ToJSON (First a) 
ToJSON a => ToJSON (Last a) 
ToJSON a => ToJSON (IntMap a) 
ToJSON v => ToJSON (Tree v) 
ToJSON a => ToJSON (Seq a) 

Methods

toJSON :: Seq a -> Value #

toEncoding :: Seq a -> Encoding #

toJSONList :: [Seq a] -> Value #

toEncodingList :: [Seq a] -> Encoding #

ToJSON a => ToJSON (Set a) 

Methods

toJSON :: Set a -> Value #

toEncoding :: Set a -> Encoding #

toJSONList :: [Set a] -> Value #

toEncodingList :: [Set a] -> Encoding #

ToJSON a => ToJSON (DList a) 
(Prim a, ToJSON a) => ToJSON (Vector a) 
(Storable a, ToJSON a) => ToJSON (Vector a) 
(Vector Vector a, ToJSON a) => ToJSON (Vector a) 
ToJSON a => ToJSON (HashSet a) 
ToJSON a => ToJSON (Vector a) 
(ToJSON a, ToJSON b) => ToJSON (Either a b) 

Methods

toJSON :: Either a b -> Value #

toEncoding :: Either a b -> Encoding #

toJSONList :: [Either a b] -> Value #

toEncodingList :: [Either a b] -> Encoding #

(ToJSON a, ToJSON b) => ToJSON (a, b) 

Methods

toJSON :: (a, b) -> Value #

toEncoding :: (a, b) -> Encoding #

toJSONList :: [(a, b)] -> Value #

toEncodingList :: [(a, b)] -> Encoding #

(ToJSON v, ToJSONKey k) => ToJSON (HashMap k v) 
(ToJSON v, ToJSONKey k) => ToJSON (Map k v) 

Methods

toJSON :: Map k v -> Value #

toEncoding :: Map k v -> Encoding #

toJSONList :: [Map k v] -> Value #

toEncodingList :: [Map k v] -> Encoding #

ToJSON (Proxy k a) 

Methods

toJSON :: Proxy k a -> Value #

toEncoding :: Proxy k a -> Encoding #

toJSONList :: [Proxy k a] -> Value #

toEncodingList :: [Proxy k a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) 

Methods

toJSON :: (a, b, c) -> Value #

toEncoding :: (a, b, c) -> Encoding #

toJSONList :: [(a, b, c)] -> Value #

toEncodingList :: [(a, b, c)] -> Encoding #

ToJSON a => ToJSON (Const k a b) 

Methods

toJSON :: Const k a b -> Value #

toEncoding :: Const k a b -> Encoding #

toJSONList :: [Const k a b] -> Value #

toEncodingList :: [Const k a b] -> Encoding #

ToJSON b => ToJSON (Tagged k a b) 

Methods

toJSON :: Tagged k a b -> Value #

toEncoding :: Tagged k a b -> Encoding #

toJSONList :: [Tagged k a b] -> Value #

toEncodingList :: [Tagged k a b] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) 

Methods

toJSON :: (a, b, c, d) -> Value #

toEncoding :: (a, b, c, d) -> Encoding #

toJSONList :: [(a, b, c, d)] -> Value #

toEncodingList :: [(a, b, c, d)] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Product * f g a) 

Methods

toJSON :: Product * f g a -> Value #

toEncoding :: Product * f g a -> Encoding #

toJSONList :: [Product * f g a] -> Value #

toEncodingList :: [Product * f g a] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Sum * f g a) 

Methods

toJSON :: Sum * f g a -> Value #

toEncoding :: Sum * f g a -> Encoding #

toJSONList :: [Sum * f g a] -> Value #

toEncodingList :: [Sum * f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e) 

Methods

toJSON :: (a, b, c, d, e) -> Value #

toEncoding :: (a, b, c, d, e) -> Encoding #

toJSONList :: [(a, b, c, d, e)] -> Value #

toEncodingList :: [(a, b, c, d, e)] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Compose * * f g a) 

Methods

toJSON :: Compose * * f g a -> Value #

toEncoding :: Compose * * f g a -> Encoding #

toJSONList :: [Compose * * f g a] -> Value #

toEncodingList :: [Compose * * f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f) 

Methods

toJSON :: (a, b, c, d, e, f) -> Value #

toEncoding :: (a, b, c, d, e, f) -> Encoding #

toJSONList :: [(a, b, c, d, e, f)] -> Value #

toEncodingList :: [(a, b, c, d, e, f)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g) 

Methods

toJSON :: (a, b, c, d, e, f, g) -> Value #

toEncoding :: (a, b, c, d, e, f, g) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON (a, b, c, d, e, f, g, h) 

Methods

toJSON :: (a, b, c, d, e, f, g, h) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON (a, b, c, d, e, f, g, h, i) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON (a, b, c, d, e, f, g, h, i, j) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON (a, b, c, d, e, f, g, h, i, j, k) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n, ToJSON o) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Encoding #

toJSON :: ToJSON a => a -> Value #

Convert a Haskell value to a JSON-friendly intermediate type.

data Value :: * #

A JSON value represented as a Haskell value.

Constructors

Object !Object 

Instances

Eq Value 

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Data Value 

Methods

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 #

toConstr :: Value -> Constr #

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 :: (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 #

Read Value 
Show Value 

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

IsString Value 

Methods

fromString :: String -> Value #

Generic Value 

Associated Types

type Rep Value :: * -> * #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

Lift Value 

Methods

lift :: Value -> Q Exp #

FromString Encoding 
FromString Value 

Methods

fromString :: String -> Value

Hashable Value 

Methods

hashWithSalt :: Int -> Value -> Int #

hash :: Value -> Int #

ToJSON Value 
KeyValue Pair 

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

FromJSON Value 
NFData Value 

Methods

rnf :: Value -> () #

FromPairs Encoding Series 
GKeyValue Encoding Series 

Methods

gPair :: String -> Encoding -> Series

GToJSON Encoding arity (U1 *) 

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> U1 * a -> Encoding

GToJSON Value arity (U1 *) 

Methods

gToJSON :: Options -> ToArgs Value arity a -> U1 * a -> Value

ToJSON1 f => GToJSON Encoding One (Rec1 * f) 

Methods

gToJSON :: Options -> ToArgs Encoding One a -> Rec1 * f a -> Encoding

ToJSON1 f => GToJSON Value One (Rec1 * f) 

Methods

gToJSON :: Options -> ToArgs Value One a -> Rec1 * f a -> Value

ToJSON a => GToJSON Encoding arity (K1 * i a) 

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> K1 * i a a -> Encoding

(EncodeProduct arity a, EncodeProduct arity b) => GToJSON Encoding arity ((:*:) * a b) 

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> (* :*: a) b a -> Encoding

ToJSON a => GToJSON Value arity (K1 * i a) 

Methods

gToJSON :: Options -> ToArgs Value arity a -> K1 * i a a -> Value

(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON Value arity ((:*:) * a b) 

Methods

gToJSON :: Options -> ToArgs Value arity a -> (* :*: a) b a -> Value

(ToJSON1 f, GToJSON Encoding One g) => GToJSON Encoding One ((:.:) * * f g) 

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (* :.: *) f g a -> Encoding

(ToJSON1 f, GToJSON Value One g) => GToJSON Value One ((:.:) * * f g) 

Methods

gToJSON :: Options -> ToArgs Value One a -> (* :.: *) f g a -> Value

FromPairs Value (DList Pair) 

Methods

fromPairs :: DList Pair -> Value

ToJSON v => GKeyValue v (DList Pair) 

Methods

gPair :: String -> v -> DList Pair

(GToJSON Encoding arity a, ConsToJSON Encoding arity a, Constructor Meta c) => SumToJSON' * TwoElemArray Encoding arity (C1 * c a) 

Methods

sumToJSON' :: Options -> ToArgs arity (C1 * c a) a -> f a -> Tagged TwoElemArray Encoding arity

(GToJSON Value arity a, ConsToJSON Value arity a, Constructor Meta c) => SumToJSON' * TwoElemArray Value arity (C1 * c a) 

Methods

sumToJSON' :: Options -> ToArgs arity (C1 * c a) a -> f a -> Tagged TwoElemArray Value arity

type Rep Value 

object :: [Pair] -> Value #

Create a Value from a list of name/value Pairs. If duplicate keys arise, earlier keys and their associated values win.

(.=) :: KeyValue kv => forall v. ToJSON v => Text -> v -> kv infixr 8 #

(.:) :: FromJSON a => Object -> Text -> 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.

deriveJSON #

Arguments

:: Options

Encoding options.

-> Name

Name of the type for which to generate ToJSON and FromJSON instances.

-> Q [Dec] 

Generates both ToJSON and FromJSON instance declarations for the given data type or data family instance constructor.

This is a convienience function which is equivalent to calling both deriveToJSON and deriveFromJSON.

fieldLabelModifier :: Options -> String -> String #

Function applied to field labels. Handy for removing common record prefixes for example.

constructorTagModifier :: Options -> String -> String #

Function applied to constructor tags which could be handy for lower-casing them for example.