{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
#include "overlapping-compat.h"
#include "incoherent-compat.h"
{-# OPTIONS_GHC -fno-warn-deprecations #-}
module Data.Aeson.Types.ToJSON
(
ToJSON(..)
, ToJSON1(..)
, toJSON1
, toEncoding1
, ToJSON2(..)
, toJSON2
, toEncoding2
, GToJSON(..)
, ToArgs(..)
, genericToJSON
, genericToEncoding
, genericLiftToJSON
, genericLiftToEncoding
, ToJSONKey(..)
, ToJSONKeyFunction(..)
, toJSONKeyText
, contramapToJSONKeyFunction
, GToJSONKey()
, genericToJSONKey
, KeyValue(..)
, KeyValuePair(..)
, FromPairs(..)
, listEncoding
, listValue
) where
import Prelude.Compat
import Control.Applicative (Const(..))
import Control.Monad.ST (ST)
import Data.Aeson.Encoding (Encoding, Encoding', Series, dict, emptyArray_)
import Data.Aeson.Encoding.Internal ((>*<))
import Data.Aeson.Internal.Functions (mapHashKeyVal, mapKeyVal)
import Data.Aeson.Types.Generic (AllNullary, False, IsRecord, One, ProductSize, Tagged2(..), True, Zero, productSize)
import Data.Aeson.Types.Internal
import Data.Attoparsec.Number (Number(..))
import Data.Bits (unsafeShiftR)
import Data.DList (DList)
import Data.Fixed (Fixed, HasResolution, Nano)
import Data.Foldable (toList)
import Data.Functor.Compose (Compose(..))
import Data.Functor.Contravariant (Contravariant (..))
import Data.Functor.Identity (Identity(..))
import Data.Functor.Product (Product(..))
import Data.Functor.Sum (Sum(..))
import Data.Int (Int16, Int32, Int64, Int8)
import Data.List (intersperse)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Semigroup ((<>))
import Data.Proxy (Proxy(..))
import Data.Ratio (Ratio, denominator, numerator)
import Data.Scientific (Scientific)
import Data.Tagged (Tagged(..))
import Data.Text (Text, pack)
import Data.Time (Day, DiffTime, LocalTime, NominalDiffTime, TimeOfDay, UTCTime, ZonedTime)
import Data.Time.Calendar.Compat (CalendarDiffDays (..), DayOfWeek (..))
import Data.Time.LocalTime.Compat (CalendarDiffTime (..))
import Data.Time.Clock.System.Compat (SystemTime (..))
import Data.Time.Format.Compat (FormatTime, formatTime, defaultTimeLocale)
import Data.Vector (Vector)
import Data.Version (Version, showVersion)
import Data.Void (Void, absurd)
import Data.Word (Word16, Word32, Word64, Word8)
import Foreign.Storable (Storable)
import Foreign.C.Types (CTime (..))
import GHC.Generics
import Numeric.Natural (Natural)
import qualified Data.Aeson.Encoding as E
import qualified Data.Aeson.Encoding.Internal as E (InArray, comma, econcat, retagEncoding)
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import qualified Data.DList as DList
import qualified Data.HashMap.Strict as H
import qualified Data.HashSet as HashSet
import qualified Data.IntMap as IntMap
import qualified Data.IntSet as IntSet
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as M
import qualified Data.Monoid as Monoid
import qualified Data.Scientific as Scientific
import qualified Data.Semigroup as Semigroup
import qualified Data.Sequence as Seq
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Text.Lazy as LT
import qualified Data.Tree as Tree
import qualified Data.UUID.Types as UUID
import qualified Data.Vector as V
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Primitive as VP
import qualified Data.Vector.Storable as VS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Aeson.Encoding.Builder as EB
import qualified Data.ByteString.Builder as B
import qualified GHC.Exts as Exts
import qualified Data.Primitive.Array as PM
import qualified Data.Primitive.SmallArray as PM
import qualified Data.Primitive.Types as PM
#if MIN_VERSION_primitive(0,6,4)
#if !MIN_VERSION_primitive(0,7,0)
import qualified Data.Primitive.UnliftedArray as PM
#endif
import qualified Data.Primitive.PrimArray as PM
#endif
#if !(MIN_VERSION_bytestring(0,10,0))
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Marshal.Utils (copyBytes)
import Foreign.Ptr (plusPtr)
import qualified Data.ByteString.Internal as S
import qualified Data.ByteString.Lazy.Internal as L
#endif
toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
toJSONPair a :: a -> Value
a b :: b -> Value
b = (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
a ((a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
a) b -> Value
b ((b -> Value) -> [b] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue b -> Value
b)
{-# INLINE toJSONPair #-}
realFloatToJSON :: RealFloat a => a -> Value
realFloatToJSON :: a -> Value
realFloatToJSON d :: a
d
| a -> Bool
forall a. RealFloat a => a -> Bool
isNaN a
d Bool -> Bool -> Bool
|| a -> Bool
forall a. RealFloat a => a -> Bool
isInfinite a
d = Value
Null
| Bool
otherwise = Scientific -> Value
Number (Scientific -> Value) -> Scientific -> Value
forall a b. (a -> b) -> a -> b
$ a -> Scientific
forall a. RealFloat a => a -> Scientific
Scientific.fromFloatDigits a
d
{-# INLINE realFloatToJSON #-}
class GToJSON enc arity f where
gToJSON :: Options -> ToArgs enc arity a -> f a -> enc
data ToArgs res arity a where
NoToArgs :: ToArgs res Zero a
To1Args :: (a -> res) -> ([a] -> res) -> ToArgs res One a
genericToJSON :: (Generic a, GToJSON Value Zero (Rep a))
=> Options -> a -> Value
genericToJSON :: Options -> a -> Value
genericToJSON opts :: Options
opts = Options -> ToArgs Value Zero Any -> Rep a Any -> Value
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Value Zero Any
forall res a. ToArgs res Zero a
NoToArgs (Rep a Any -> Value) -> (a -> Rep a Any) -> a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a Any
forall a x. Generic a => a -> Rep a x
from
genericLiftToJSON :: (Generic1 f, GToJSON Value One (Rep1 f))
=> Options -> (a -> Value) -> ([a] -> Value)
-> f a -> Value
genericLiftToJSON :: Options -> (a -> Value) -> ([a] -> Value) -> f a -> Value
genericLiftToJSON opts :: Options
opts tj :: a -> Value
tj tjl :: [a] -> Value
tjl = Options -> ToArgs Value One a -> Rep1 f a -> Value
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ((a -> Value) -> ([a] -> Value) -> ToArgs Value One a
forall a res. (a -> res) -> ([a] -> res) -> ToArgs res One a
To1Args a -> Value
tj [a] -> Value
tjl) (Rep1 f a -> Value) -> (f a -> Rep1 f a) -> f a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> Rep1 f a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1
genericToEncoding :: (Generic a, GToJSON Encoding Zero (Rep a))
=> Options -> a -> Encoding
genericToEncoding :: Options -> a -> Encoding
genericToEncoding opts :: Options
opts = Options -> ToArgs Encoding Zero Any -> Rep a Any -> Encoding
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Encoding Zero Any
forall res a. ToArgs res Zero a
NoToArgs (Rep a Any -> Encoding) -> (a -> Rep a Any) -> a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a Any
forall a x. Generic a => a -> Rep a x
from
genericLiftToEncoding :: (Generic1 f, GToJSON Encoding One (Rep1 f))
=> Options -> (a -> Encoding) -> ([a] -> Encoding)
-> f a -> Encoding
genericLiftToEncoding :: Options -> (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
genericLiftToEncoding opts :: Options
opts te :: a -> Encoding
te tel :: [a] -> Encoding
tel = Options -> ToArgs Encoding One a -> Rep1 f a -> Encoding
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ((a -> Encoding) -> ([a] -> Encoding) -> ToArgs Encoding One a
forall a res. (a -> res) -> ([a] -> res) -> ToArgs res One a
To1Args a -> Encoding
te [a] -> Encoding
tel) (Rep1 f a -> Encoding) -> (f a -> Rep1 f a) -> f a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> Rep1 f a
forall k (f :: k -> *) (a :: k). Generic1 f => f a -> Rep1 f a
from1
class ToJSON a where
toJSON :: a -> Value
default toJSON :: (Generic a, GToJSON Value Zero (Rep a)) => a -> Value
toJSON = Options -> a -> Value
forall a.
(Generic a, GToJSON Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
defaultOptions
toEncoding :: a -> Encoding
toEncoding = Value -> Encoding
E.value (Value -> Encoding) -> (a -> Value) -> a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON
{-# INLINE toEncoding #-}
toJSONList :: [a] -> Value
toJSONList = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
forall a. ToJSON a => a -> Value
toJSON
{-# INLINE toJSONList #-}
toEncodingList :: [a] -> Encoding
toEncodingList = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding
{-# INLINE toEncodingList #-}
class KeyValue kv where
(.=) :: ToJSON v => Text -> v -> kv
infixr 8 .=
instance KeyValue Series where
name :: Text
name .= :: Text -> v -> Series
.= value :: v
value = Text -> Encoding -> Series
E.pair Text
name (v -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding v
value)
{-# INLINE (.=) #-}
instance KeyValue Pair where
name :: Text
name .= :: Text -> v -> Pair
.= value :: v
value = (Text
name, v -> Value
forall a. ToJSON a => a -> Value
toJSON v
value)
{-# INLINE (.=) #-}
instance KeyValue Object where
name :: Text
name .= :: Text -> v -> Object
.= value :: v
value = Text -> Value -> Object
forall k v. Hashable k => k -> v -> HashMap k v
H.singleton Text
name (v -> Value
forall a. ToJSON a => a -> Value
toJSON v
value)
{-# INLINE (.=) #-}
class ToJSONKey a where
toJSONKey :: ToJSONKeyFunction a
default toJSONKey :: ToJSON a => ToJSONKeyFunction a
toJSONKey = (a -> Value) -> (a -> Encoding) -> ToJSONKeyFunction a
forall a. (a -> Value) -> (a -> Encoding) -> ToJSONKeyFunction a
ToJSONKeyValue a -> Value
forall a. ToJSON a => a -> Value
toJSON a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding
toJSONKeyList :: ToJSONKeyFunction [a]
default toJSONKeyList :: ToJSON a => ToJSONKeyFunction [a]
toJSONKeyList = ([a] -> Value) -> ([a] -> Encoding) -> ToJSONKeyFunction [a]
forall a. (a -> Value) -> (a -> Encoding) -> ToJSONKeyFunction a
ToJSONKeyValue [a] -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding
data ToJSONKeyFunction a
= ToJSONKeyText !(a -> Text) !(a -> Encoding' Text)
| ToJSONKeyValue !(a -> Value) !(a -> Encoding)
toJSONKeyText :: (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText :: (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText f :: a -> Text
f = (a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
forall a.
(a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
ToJSONKeyText a -> Text
f (Text -> Encoding' Text
forall a. Text -> Encoding' a
E.text (Text -> Encoding' Text) -> (a -> Text) -> a -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Text
f)
toJSONKeyTextEnc :: (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc :: (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc e :: a -> Encoding' Text
e = (a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
forall a.
(a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
ToJSONKeyText a -> Text
tot a -> Encoding' Text
e
where
tot :: a -> Text
tot = (Char -> Bool) -> Text -> Text
T.dropAround (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '"')
(Text -> Text) -> (a -> Text) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
T.decodeLatin1
(ByteString -> Text) -> (a -> ByteString) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
lazyToStrictByteString
(ByteString -> ByteString) -> (a -> ByteString) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Encoding' Text -> ByteString
forall a. Encoding' a -> ByteString
E.encodingToLazyByteString
(Encoding' Text -> ByteString)
-> (a -> Encoding' Text) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Encoding' Text
e
instance Contravariant ToJSONKeyFunction where
contramap :: (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramap = (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
forall a b. (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramapToJSONKeyFunction
contramapToJSONKeyFunction :: (b -> a) -> ToJSONKeyFunction a -> ToJSONKeyFunction b
contramapToJSONKeyFunction :: (b -> a) -> ToJSONKeyFunction a -> ToJSONKeyFunction b
contramapToJSONKeyFunction h :: b -> a
h x :: ToJSONKeyFunction a
x = case ToJSONKeyFunction a
x of
ToJSONKeyText f :: a -> Text
f g :: a -> Encoding' Text
g -> (b -> Text) -> (b -> Encoding' Text) -> ToJSONKeyFunction b
forall a.
(a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
ToJSONKeyText (a -> Text
f (a -> Text) -> (b -> a) -> b -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
h) (a -> Encoding' Text
g (a -> Encoding' Text) -> (b -> a) -> b -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
h)
ToJSONKeyValue f :: a -> Value
f g :: a -> Encoding
g -> (b -> Value) -> (b -> Encoding) -> ToJSONKeyFunction b
forall a. (a -> Value) -> (a -> Encoding) -> ToJSONKeyFunction a
ToJSONKeyValue (a -> Value
f (a -> Value) -> (b -> a) -> b -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
h) (a -> Encoding
g (a -> Encoding) -> (b -> a) -> b -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
h)
genericToJSONKey :: (Generic a, GToJSONKey (Rep a))
=> JSONKeyOptions -> ToJSONKeyFunction a
genericToJSONKey :: JSONKeyOptions -> ToJSONKeyFunction a
genericToJSONKey opts :: JSONKeyOptions
opts = (a -> Text) -> ToJSONKeyFunction a
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText (String -> Text
pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSONKeyOptions -> String -> String
keyModifier JSONKeyOptions
opts (String -> String) -> (a -> String) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep a Any -> String
forall k (f :: k -> *) (a :: k). GetConName f => f a -> String
getConName (Rep a Any -> String) -> (a -> Rep a Any) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Rep a Any
forall a x. Generic a => a -> Rep a x
from)
class GetConName f => GToJSONKey f
instance GetConName f => GToJSONKey f
class ToJSON1 f where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> f a -> Value
default liftToJSON :: (Generic1 f, GToJSON Value One (Rep1 f))
=> (a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON = Options -> (a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
(Generic1 f, GToJSON Value One (Rep1 f)) =>
Options -> (a -> Value) -> ([a] -> Value) -> f a -> Value
genericLiftToJSON Options
defaultOptions
liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList f :: a -> Value
f g :: [a] -> Value
g = (f a -> Value) -> [f a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue ((a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
f [a] -> Value
g)
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
default liftToEncoding :: (Generic1 f, GToJSON Encoding One (Rep1 f))
=> (a -> Encoding) -> ([a] -> Encoding)
-> f a -> Encoding
liftToEncoding = Options -> (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
(Generic1 f, GToJSON Encoding One (Rep1 f)) =>
Options -> (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
genericLiftToEncoding Options
defaultOptions
liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList f :: a -> Encoding
f g :: [a] -> Encoding
g = (f a -> Encoding) -> [f a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding ((a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
f [a] -> Encoding
g)
toJSON1 :: (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1 :: f a -> Value
toJSON1 = (a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE toJSON1 #-}
toEncoding1 :: (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1 :: f a -> Encoding
toEncoding1 = (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE toEncoding1 #-}
class ToJSON2 f where
liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> f a b -> Value
liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [f a b] -> Value
liftToJSONList2 fa :: a -> Value
fa ga :: [a] -> Value
ga fb :: b -> Value
fb gb :: [b] -> Value
gb = (f a b -> Value) -> [f a b] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue ((a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
fa [a] -> Value
ga b -> Value
fb [b] -> Value
gb)
liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> f a b -> Encoding
liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [f a b] -> Encoding
liftToEncodingList2 fa :: a -> Encoding
fa ga :: [a] -> Encoding
ga fb :: b -> Encoding
fb gb :: [b] -> Encoding
gb = (f a b -> Encoding) -> [f a b] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding ((a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 a -> Encoding
fa [a] -> Encoding
ga b -> Encoding
fb [b] -> Encoding
gb)
toJSON2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Value
toJSON2 :: f a b -> Value
toJSON2 = (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList b -> Value
forall a. ToJSON a => a -> Value
toJSON [b] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE toJSON2 #-}
toEncoding2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Encoding
toEncoding2 :: f a b -> Encoding
toEncoding2 = (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [b] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE toEncoding2 #-}
listEncoding :: (a -> Encoding) -> [a] -> Encoding
listEncoding :: (a -> Encoding) -> [a] -> Encoding
listEncoding = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list
{-# INLINE listEncoding #-}
listValue :: (a -> Value) -> [a] -> Value
listValue :: (a -> Value) -> [a] -> Value
listValue f :: a -> Value
f = Array -> Value
Array (Array -> Value) -> ([a] -> Array) -> [a] -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Value] -> Array
forall a. [a] -> Vector a
V.fromList ([Value] -> Array) -> ([a] -> [Value]) -> [a] -> Array
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Value) -> [a] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map a -> Value
f
{-# INLINE listValue #-}
instance ToJSON1 [] where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> [a] -> Value
liftToJSON _ to' :: [a] -> Value
to' = [a] -> Value
to'
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> [a] -> Encoding
liftToEncoding _ to' :: [a] -> Encoding
to' = [a] -> Encoding
to'
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON [a] where
{-# SPECIALIZE instance ToJSON String #-}
{-# SPECIALIZE instance ToJSON [String] #-}
{-# SPECIALIZE instance ToJSON [Array] #-}
{-# SPECIALIZE instance ToJSON [Object] #-}
toJSON :: [a] -> Value
toJSON = [a] -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: [a] -> Encoding
toEncoding = [a] -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance OVERLAPPABLE_ (GToJSON enc arity a) => GToJSON enc arity (M1 i c a) where
gToJSON :: Options -> ToArgs enc arity a -> M1 i c a a -> enc
gToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs = Options -> ToArgs enc arity a -> a a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs (a a -> enc) -> (M1 i c a a -> a a) -> M1 i c a a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. M1 i c a a -> a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
{-# INLINE gToJSON #-}
instance GToJSON enc One Par1 where
gToJSON :: Options -> ToArgs enc One a -> Par1 a -> enc
gToJSON _opts :: Options
_opts (To1Args tj :: a -> enc
tj _) = a -> enc
tj (a -> enc) -> (Par1 a -> a) -> Par1 a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Par1 a -> a
forall p. Par1 p -> p
unPar1
{-# INLINE gToJSON #-}
instance ( ConsToJSON enc arity a
, AllNullary (C1 c a) allNullary
, SumToJSON enc arity (C1 c a) allNullary
) => GToJSON enc arity (D1 d (C1 c a)) where
gToJSON :: Options -> ToArgs enc arity a -> D1 d (C1 c a) a -> enc
gToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs
| Options -> Bool
tagSingleConstructors Options
opts = (Tagged allNullary enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged allNullary enc -> enc)
(Tagged allNullary enc -> enc)
-> (D1 d (C1 c a) a -> Tagged allNullary enc)
-> D1 d (C1 c a) a
-> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> C1 c a a -> Tagged allNullary enc
forall k enc arity (f :: * -> *) (allNullary :: k) a.
SumToJSON enc arity f allNullary =>
Options -> ToArgs enc arity a -> f a -> Tagged allNullary enc
sumToJSON Options
opts ToArgs enc arity a
targs
(C1 c a a -> Tagged allNullary enc)
-> (D1 d (C1 c a) a -> C1 c a a)
-> D1 d (C1 c a) a
-> Tagged allNullary enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D1 d (C1 c a) a -> C1 c a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
| Bool
otherwise = Options -> ToArgs enc arity a -> a a -> enc
forall enc arity (f :: * -> *) a.
ConsToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
consToJSON Options
opts ToArgs enc arity a
targs (a a -> enc) -> (D1 d (C1 c a) a -> a a) -> D1 d (C1 c a) a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. C1 c a a -> a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1 (C1 c a a -> a a)
-> (D1 d (C1 c a) a -> C1 c a a) -> D1 d (C1 c a) a -> a a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D1 d (C1 c a) a -> C1 c a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
{-# INLINE gToJSON #-}
instance (ConsToJSON enc arity a) => GToJSON enc arity (C1 c a) where
gToJSON :: Options -> ToArgs enc arity a -> C1 c a a -> enc
gToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs = Options -> ToArgs enc arity a -> a a -> enc
forall enc arity (f :: * -> *) a.
ConsToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
consToJSON Options
opts ToArgs enc arity a
targs (a a -> enc) -> (C1 c a a -> a a) -> C1 c a a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. C1 c a a -> a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
{-# INLINE gToJSON #-}
instance ( AllNullary (a :+: b) allNullary
, SumToJSON enc arity (a :+: b) allNullary
) => GToJSON enc arity (a :+: b)
where
gToJSON :: Options -> ToArgs enc arity a -> (:+:) a b a -> enc
gToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs = (Tagged allNullary enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged allNullary enc -> enc)
(Tagged allNullary enc -> enc)
-> ((:+:) a b a -> Tagged allNullary enc) -> (:+:) a b a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options
-> ToArgs enc arity a -> (:+:) a b a -> Tagged allNullary enc
forall k enc arity (f :: * -> *) (allNullary :: k) a.
SumToJSON enc arity f allNullary =>
Options -> ToArgs enc arity a -> f a -> Tagged allNullary enc
sumToJSON Options
opts ToArgs enc arity a
targs
{-# INLINE gToJSON #-}
instance GToJSON Value arity V1 where
gToJSON :: Options -> ToArgs Value arity a -> V1 a -> Value
gToJSON _ _ x :: V1 a
x = V1 a
x V1 a -> Value -> Value
forall a b. a -> b -> b
`seq` String -> Value
forall a. HasCallStack => String -> a
error "case: V1"
{-# INLINE gToJSON #-}
instance ToJSON a => GToJSON Value arity (K1 i a) where
gToJSON :: Options -> ToArgs Value arity a -> K1 i a a -> Value
gToJSON _opts :: Options
_opts _ = a -> Value
forall a. ToJSON a => a -> Value
toJSON (a -> Value) -> (K1 i a a -> a) -> K1 i a a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i a a -> a
forall i c k (p :: k). K1 i c p -> c
unK1
{-# INLINE gToJSON #-}
instance ToJSON1 f => GToJSON Value One (Rec1 f) where
gToJSON :: Options -> ToArgs Value One a -> Rec1 f a -> Value
gToJSON _opts :: Options
_opts (To1Args tj :: a -> Value
tj tjl :: [a] -> Value
tjl) = (a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tj [a] -> Value
tjl (f a -> Value) -> (Rec1 f a -> f a) -> Rec1 f a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rec1 f a -> f a
forall k (f :: k -> *) (p :: k). Rec1 f p -> f p
unRec1
{-# INLINE gToJSON #-}
instance GToJSON Value arity U1 where
gToJSON :: Options -> ToArgs Value arity a -> U1 a -> Value
gToJSON _opts :: Options
_opts _ _ = Value
emptyArray
{-# INLINE gToJSON #-}
instance ( WriteProduct arity a, WriteProduct arity b
, ProductSize a, ProductSize b
) => GToJSON Value arity (a :*: b)
where
gToJSON :: Options -> ToArgs Value arity a -> (:*:) a b a -> Value
gToJSON opts :: Options
opts targs :: ToArgs Value arity a
targs p :: (:*:) a b a
p =
Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew Int
lenProduct
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> (:*:) a b a
-> ST s ()
forall arity (f :: * -> *) a s.
WriteProduct arity f =>
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> f a
-> ST s ()
writeProduct Options
opts ToArgs Value arity a
targs MVector s Value
mv 0 Int
lenProduct (:*:) a b a
p
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
where
lenProduct :: Int
lenProduct = (Tagged2 (a :*: b) Int -> Int
forall (s :: * -> *) b. Tagged2 s b -> b
unTagged2 :: Tagged2 (a :*: b) Int -> Int)
Tagged2 (a :*: b) Int
forall (f :: * -> *). ProductSize f => Tagged2 f Int
productSize
{-# INLINE gToJSON #-}
instance ( ToJSON1 f
, GToJSON Value One g
) => GToJSON Value One (f :.: g)
where
gToJSON :: Options -> ToArgs Value One a -> (:.:) f g a -> Value
gToJSON opts :: Options
opts targs :: ToArgs Value One a
targs =
let gtj :: g a -> Value
gtj = Options -> ToArgs Value One a -> g a -> Value
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Value One a
targs in
(g a -> Value) -> ([g a] -> Value) -> f (g a) -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON g a -> Value
gtj ((g a -> Value) -> [g a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue g a -> Value
gtj) (f (g a) -> Value)
-> ((:.:) f g a -> f (g a)) -> (:.:) f g a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:.:) f g a -> f (g a)
forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1).
(:.:) f g p -> f (g p)
unComp1
{-# INLINE gToJSON #-}
instance ToJSON a => GToJSON Encoding arity (K1 i a) where
gToJSON :: Options -> ToArgs Encoding arity a -> K1 i a a -> Encoding
gToJSON _opts :: Options
_opts _ = a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (a -> Encoding) -> (K1 i a a -> a) -> K1 i a a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. K1 i a a -> a
forall i c k (p :: k). K1 i c p -> c
unK1
{-# INLINE gToJSON #-}
instance ToJSON1 f => GToJSON Encoding One (Rec1 f) where
gToJSON :: Options -> ToArgs Encoding One a -> Rec1 f a -> Encoding
gToJSON _opts :: Options
_opts (To1Args te :: a -> Encoding
te tel :: [a] -> Encoding
tel) = (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel (f a -> Encoding) -> (Rec1 f a -> f a) -> Rec1 f a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rec1 f a -> f a
forall k (f :: k -> *) (p :: k). Rec1 f p -> f p
unRec1
{-# INLINE gToJSON #-}
instance GToJSON Encoding arity U1 where
gToJSON :: Options -> ToArgs Encoding arity a -> U1 a -> Encoding
gToJSON _opts :: Options
_opts _ _ = Encoding
E.emptyArray_
{-# INLINE gToJSON #-}
instance ( EncodeProduct arity a
, EncodeProduct arity b
) => GToJSON Encoding arity (a :*: b)
where
gToJSON :: Options -> ToArgs Encoding arity a -> (:*:) a b a -> Encoding
gToJSON opts :: Options
opts targs :: ToArgs Encoding arity a
targs p :: (:*:) a b a
p = (Encoding' InArray -> Encoding) -> [Encoding' InArray] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding' InArray -> Encoding
forall a b. Encoding' a -> Encoding' b
E.retagEncoding [Options
-> ToArgs Encoding arity a -> (:*:) a b a -> Encoding' InArray
forall arity (f :: * -> *) a.
EncodeProduct arity f =>
Options -> ToArgs Encoding arity a -> f a -> Encoding' InArray
encodeProduct Options
opts ToArgs Encoding arity a
targs (:*:) a b a
p]
{-# INLINE gToJSON #-}
instance ( ToJSON1 f
, GToJSON Encoding One g
) => GToJSON Encoding One (f :.: g)
where
gToJSON :: Options -> ToArgs Encoding One a -> (:.:) f g a -> Encoding
gToJSON opts :: Options
opts targs :: ToArgs Encoding One a
targs =
let gte :: g a -> Encoding
gte = Options -> ToArgs Encoding One a -> g a -> Encoding
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Encoding One a
targs in
(g a -> Encoding) -> ([g a] -> Encoding) -> f (g a) -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding g a -> Encoding
gte ((g a -> Encoding) -> [g a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding g a -> Encoding
gte) (f (g a) -> Encoding)
-> ((:.:) f g a -> f (g a)) -> (:.:) f g a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:.:) f g a -> f (g a)
forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1).
(:.:) f g p -> f (g p)
unComp1
{-# INLINE gToJSON #-}
class SumToJSON enc arity f allNullary where
sumToJSON :: Options -> ToArgs enc arity a
-> f a -> Tagged allNullary enc
instance ( GetConName f
, FromString enc
, TaggedObject enc arity f
, SumToJSON' ObjectWithSingleField enc arity f
, SumToJSON' TwoElemArray enc arity f
, SumToJSON' UntaggedValue enc arity f
) => SumToJSON enc arity f True
where
sumToJSON :: Options -> ToArgs enc arity a -> f a -> Tagged True enc
sumToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs
| Options -> Bool
allNullaryToStringTag Options
opts = enc -> Tagged True enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged True enc) -> (f a -> enc) -> f a -> Tagged True enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> enc
forall enc. FromString enc => String -> enc
fromString
(String -> enc) -> (f a -> String) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> String -> String
constructorTagModifier Options
opts (String -> String) -> (f a -> String) -> f a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> String
forall k (f :: k -> *) (a :: k). GetConName f => f a -> String
getConName
| Bool
otherwise = enc -> Tagged True enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged True enc) -> (f a -> enc) -> f a -> Tagged True enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> enc
forall enc arity (f :: * -> *) a.
(TaggedObject enc arity f,
SumToJSON' ObjectWithSingleField enc arity f,
SumToJSON' TwoElemArray enc arity f,
SumToJSON' UntaggedValue enc arity f) =>
Options -> ToArgs enc arity a -> f a -> enc
nonAllNullarySumToJSON Options
opts ToArgs enc arity a
targs
instance ( TaggedObject enc arity f
, SumToJSON' ObjectWithSingleField enc arity f
, SumToJSON' TwoElemArray enc arity f
, SumToJSON' UntaggedValue enc arity f
) => SumToJSON enc arity f False
where
sumToJSON :: Options -> ToArgs enc arity a -> f a -> Tagged False enc
sumToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs = enc -> Tagged False enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged False enc)
-> (f a -> enc) -> f a -> Tagged False enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> enc
forall enc arity (f :: * -> *) a.
(TaggedObject enc arity f,
SumToJSON' ObjectWithSingleField enc arity f,
SumToJSON' TwoElemArray enc arity f,
SumToJSON' UntaggedValue enc arity f) =>
Options -> ToArgs enc arity a -> f a -> enc
nonAllNullarySumToJSON Options
opts ToArgs enc arity a
targs
nonAllNullarySumToJSON :: ( TaggedObject enc arity f
, SumToJSON' ObjectWithSingleField enc arity f
, SumToJSON' TwoElemArray enc arity f
, SumToJSON' UntaggedValue enc arity f
) => Options -> ToArgs enc arity a
-> f a -> enc
nonAllNullarySumToJSON :: Options -> ToArgs enc arity a -> f a -> enc
nonAllNullarySumToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs =
case Options -> SumEncoding
sumEncoding Options
opts of
TaggedObject{..} ->
Options -> ToArgs enc arity a -> String -> String -> f a -> enc
forall enc arity (f :: * -> *) a.
TaggedObject enc arity f =>
Options -> ToArgs enc arity a -> String -> String -> f a -> enc
taggedObject Options
opts ToArgs enc arity a
targs String
tagFieldName String
contentsFieldName
ObjectWithSingleField ->
(forall enc. Tagged ObjectWithSingleField enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged ObjectWithSingleField enc -> enc)
(Tagged ObjectWithSingleField enc -> enc)
-> (f a -> Tagged ObjectWithSingleField enc) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options
-> ToArgs enc arity a -> f a -> Tagged ObjectWithSingleField enc
forall k (s :: k) enc arity (f :: * -> *) a.
SumToJSON' s enc arity f =>
Options -> ToArgs enc arity a -> f a -> Tagged s enc
sumToJSON' Options
opts ToArgs enc arity a
targs
TwoElemArray ->
(forall enc. Tagged TwoElemArray enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged TwoElemArray enc -> enc)
(Tagged TwoElemArray enc -> enc)
-> (f a -> Tagged TwoElemArray enc) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> Tagged TwoElemArray enc
forall k (s :: k) enc arity (f :: * -> *) a.
SumToJSON' s enc arity f =>
Options -> ToArgs enc arity a -> f a -> Tagged s enc
sumToJSON' Options
opts ToArgs enc arity a
targs
UntaggedValue ->
(forall enc. Tagged UntaggedValue enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged UntaggedValue enc -> enc)
(Tagged UntaggedValue enc -> enc)
-> (f a -> Tagged UntaggedValue enc) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> Tagged UntaggedValue enc
forall k (s :: k) enc arity (f :: * -> *) a.
SumToJSON' s enc arity f =>
Options -> ToArgs enc arity a -> f a -> Tagged s enc
sumToJSON' Options
opts ToArgs enc arity a
targs
class FromString enc where
fromString :: String -> enc
instance FromString Encoding where
fromString :: String -> Encoding
fromString = String -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding
instance FromString Value where
fromString :: String -> Value
fromString = Text -> Value
String (Text -> Value) -> (String -> Text) -> String -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack
class TaggedObject enc arity f where
taggedObject :: Options -> ToArgs enc arity a
-> String -> String
-> f a -> enc
instance ( TaggedObject enc arity a
, TaggedObject enc arity b
) => TaggedObject enc arity (a :+: b)
where
taggedObject :: Options
-> ToArgs enc arity a -> String -> String -> (:+:) a b a -> enc
taggedObject opts :: Options
opts targs :: ToArgs enc arity a
targs tagFieldName :: String
tagFieldName contentsFieldName :: String
contentsFieldName (L1 x :: a a
x) =
Options -> ToArgs enc arity a -> String -> String -> a a -> enc
forall enc arity (f :: * -> *) a.
TaggedObject enc arity f =>
Options -> ToArgs enc arity a -> String -> String -> f a -> enc
taggedObject Options
opts ToArgs enc arity a
targs String
tagFieldName String
contentsFieldName a a
x
taggedObject opts :: Options
opts targs :: ToArgs enc arity a
targs tagFieldName :: String
tagFieldName contentsFieldName :: String
contentsFieldName (R1 x :: b a
x) =
Options -> ToArgs enc arity a -> String -> String -> b a -> enc
forall enc arity (f :: * -> *) a.
TaggedObject enc arity f =>
Options -> ToArgs enc arity a -> String -> String -> f a -> enc
taggedObject Options
opts ToArgs enc arity a
targs String
tagFieldName String
contentsFieldName b a
x
instance ( IsRecord a isRecord
, TaggedObject' enc pairs arity a isRecord
, FromPairs enc pairs
, FromString enc
, KeyValuePair enc pairs
, Constructor c
) => TaggedObject enc arity (C1 c a)
where
taggedObject :: Options
-> ToArgs enc arity a -> String -> String -> C1 c a a -> enc
taggedObject opts :: Options
opts targs :: ToArgs enc arity a
targs tagFieldName :: String
tagFieldName contentsFieldName :: String
contentsFieldName =
pairs -> enc
forall enc pairs. FromPairs enc pairs => pairs -> enc
fromPairs (pairs -> enc) -> (C1 c a a -> pairs) -> C1 c a a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. pairs -> pairs -> pairs
forall a. Monoid a => a -> a -> a
mappend pairs
tag (pairs -> pairs) -> (C1 c a a -> pairs) -> C1 c a a -> pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. C1 c a a -> pairs
contents
where
tag :: pairs
tag = String
tagFieldName String -> enc -> pairs
forall v kv. KeyValuePair v kv => String -> v -> kv
`pair`
(String -> enc
forall enc. FromString enc => String -> enc
fromString (Options -> String -> String
constructorTagModifier Options
opts (Any c a Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName (forall k (t :: Meta -> (* -> *) -> k -> *) (p :: k). t c a p
forall a. HasCallStack => a
undefined :: t c a p)))
:: enc)
contents :: C1 c a a -> pairs
contents =
(Tagged isRecord pairs -> pairs
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged isRecord pairs -> pairs) (Tagged isRecord pairs -> pairs)
-> (C1 c a a -> Tagged isRecord pairs) -> C1 c a a -> pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Options
-> ToArgs enc arity a -> String -> a a -> Tagged isRecord pairs
forall k enc pairs arity (f :: * -> *) (isRecord :: k) a.
TaggedObject' enc pairs arity f isRecord =>
Options
-> ToArgs enc arity a -> String -> f a -> Tagged isRecord pairs
taggedObject' Options
opts ToArgs enc arity a
targs String
contentsFieldName (a a -> Tagged isRecord pairs)
-> (C1 c a a -> a a) -> C1 c a a -> Tagged isRecord pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. C1 c a a -> a a
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1
class TaggedObject' enc pairs arity f isRecord where
taggedObject' :: Options -> ToArgs enc arity a
-> String -> f a -> Tagged isRecord pairs
instance ( GToJSON enc arity f
, KeyValuePair enc pairs
) => TaggedObject' enc pairs arity f False
where
taggedObject' :: Options
-> ToArgs enc arity a -> String -> f a -> Tagged False pairs
taggedObject' opts :: Options
opts targs :: ToArgs enc arity a
targs contentsFieldName :: String
contentsFieldName =
pairs -> Tagged False pairs
forall k (s :: k) b. b -> Tagged s b
Tagged (pairs -> Tagged False pairs)
-> (f a -> pairs) -> f a -> Tagged False pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
contentsFieldName String -> enc -> pairs
forall v kv. KeyValuePair v kv => String -> v -> kv
`pair`) (enc -> pairs) -> (f a -> enc) -> f a -> pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs
instance OVERLAPPING_ Monoid pairs => TaggedObject' enc pairs arity U1 False where
taggedObject' :: Options
-> ToArgs enc arity a -> String -> U1 a -> Tagged False pairs
taggedObject' _ _ _ _ = pairs -> Tagged False pairs
forall k (s :: k) b. b -> Tagged s b
Tagged pairs
forall a. Monoid a => a
mempty
instance ( RecordToPairs enc pairs arity f
) => TaggedObject' enc pairs arity f True
where
taggedObject' :: Options -> ToArgs enc arity a -> String -> f a -> Tagged True pairs
taggedObject' opts :: Options
opts targs :: ToArgs enc arity a
targs _ = pairs -> Tagged True pairs
forall k (s :: k) b. b -> Tagged s b
Tagged (pairs -> Tagged True pairs)
-> (f a -> pairs) -> f a -> Tagged True pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> pairs
forall enc pairs arity (f :: * -> *) a.
RecordToPairs enc pairs arity f =>
Options -> ToArgs enc arity a -> f a -> pairs
recordToPairs Options
opts ToArgs enc arity a
targs
class GetConName f where
getConName :: f a -> String
instance (GetConName a, GetConName b) => GetConName (a :+: b) where
getConName :: (:+:) a b a -> String
getConName (L1 x :: a a
x) = a a -> String
forall k (f :: k -> *) (a :: k). GetConName f => f a -> String
getConName a a
x
getConName (R1 x :: b a
x) = b a -> String
forall k (f :: k -> *) (a :: k). GetConName f => f a -> String
getConName b a
x
instance (Constructor c) => GetConName (C1 c a) where
getConName :: C1 c a a -> String
getConName = C1 c a a -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName
instance GetConName a => GetConName (D1 d a) where
getConName :: D1 d a a -> String
getConName (M1 x :: a a
x) = a a -> String
forall k (f :: k -> *) (a :: k). GetConName f => f a -> String
getConName a a
x
data ObjectWithSingleField
data TwoElemArray
data UntaggedValue
class SumToJSON' s enc arity f where
sumToJSON' :: Options -> ToArgs enc arity a
-> f a -> Tagged s enc
instance ( SumToJSON' s enc arity a
, SumToJSON' s enc arity b
) => SumToJSON' s enc arity (a :+: b)
where
sumToJSON' :: Options -> ToArgs enc arity a -> (:+:) a b a -> Tagged s enc
sumToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs (L1 x :: a a
x) = Options -> ToArgs enc arity a -> a a -> Tagged s enc
forall k (s :: k) enc arity (f :: * -> *) a.
SumToJSON' s enc arity f =>
Options -> ToArgs enc arity a -> f a -> Tagged s enc
sumToJSON' Options
opts ToArgs enc arity a
targs a a
x
sumToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs (R1 x :: b a
x) = Options -> ToArgs enc arity a -> b a -> Tagged s enc
forall k (s :: k) enc arity (f :: * -> *) a.
SumToJSON' s enc arity f =>
Options -> ToArgs enc arity a -> f a -> Tagged s enc
sumToJSON' Options
opts ToArgs enc arity a
targs b a
x
instance ( GToJSON Value arity a
, ConsToJSON Value arity a
, Constructor c
) => SumToJSON' TwoElemArray Value arity (C1 c a) where
sumToJSON' :: Options
-> ToArgs Value arity a -> C1 c a a -> Tagged TwoElemArray Value
sumToJSON' opts :: Options
opts targs :: ToArgs Value arity a
targs x :: C1 c a a
x = Value -> Tagged TwoElemArray Value
forall k (s :: k) b. b -> Tagged s b
Tagged (Value -> Tagged TwoElemArray Value)
-> Value -> Tagged TwoElemArray Value
forall a b. (a -> b) -> a -> b
$ Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 2
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (Value -> ST s ()) -> Value -> ST s ()
forall a b. (a -> b) -> a -> b
$ Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Options -> String -> String
constructorTagModifier Options
opts
(String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Any c a Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName (forall k (t :: Meta -> (* -> *) -> k -> *) (p :: k). t c a p
forall a. HasCallStack => a
undefined :: t c a p)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (Value -> ST s ()) -> Value -> ST s ()
forall a b. (a -> b) -> a -> b
$ Options -> ToArgs Value arity a -> C1 c a a -> Value
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Value arity a
targs C1 c a a
x
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
instance ( GToJSON Encoding arity a
, ConsToJSON Encoding arity a
, Constructor c
) => SumToJSON' TwoElemArray Encoding arity (C1 c a)
where
sumToJSON' :: Options
-> ToArgs Encoding arity a
-> C1 c a a
-> Tagged TwoElemArray Encoding
sumToJSON' opts :: Options
opts targs :: ToArgs Encoding arity a
targs x :: C1 c a a
x = Encoding -> Tagged TwoElemArray Encoding
forall k (s :: k) b. b -> Tagged s b
Tagged (Encoding -> Tagged TwoElemArray Encoding)
-> Encoding -> Tagged TwoElemArray Encoding
forall a b. (a -> b) -> a -> b
$ (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ String -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Options -> String -> String
constructorTagModifier Options
opts (Any c a Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName (forall k (t :: Meta -> (* -> *) -> k -> *) (p :: k). t c a p
forall a. HasCallStack => a
undefined :: t c a p)))
, Options -> ToArgs Encoding arity a -> C1 c a a -> Encoding
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Encoding arity a
targs C1 c a a
x
]
class ConsToJSON enc arity f where
consToJSON :: Options -> ToArgs enc arity a
-> f a -> enc
class ConsToJSON' enc arity f isRecord where
consToJSON' :: Options -> ToArgs enc arity a
-> f a -> Tagged isRecord enc
instance ( IsRecord f isRecord
, ConsToJSON' enc arity f isRecord
) => ConsToJSON enc arity f
where
consToJSON :: Options -> ToArgs enc arity a -> f a -> enc
consToJSON opts :: Options
opts targs :: ToArgs enc arity a
targs =
(Tagged isRecord enc -> enc
forall k (s :: k) b. Tagged s b -> b
unTagged :: Tagged isRecord enc -> enc)
(Tagged isRecord enc -> enc)
-> (f a -> Tagged isRecord enc) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> Tagged isRecord enc
forall k enc arity (f :: * -> *) (isRecord :: k) a.
ConsToJSON' enc arity f isRecord =>
Options -> ToArgs enc arity a -> f a -> Tagged isRecord enc
consToJSON' Options
opts ToArgs enc arity a
targs
{-# INLINE consToJSON #-}
instance OVERLAPPING_
( RecordToPairs enc pairs arity (S1 s f)
, FromPairs enc pairs
, GToJSON enc arity f
) => ConsToJSON' enc arity (S1 s f) True
where
consToJSON' :: Options -> ToArgs enc arity a -> S1 s f a -> Tagged True enc
consToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs
| Options -> Bool
unwrapUnaryRecords Options
opts = enc -> Tagged True enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged True enc)
-> (S1 s f a -> enc) -> S1 s f a -> Tagged True enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> S1 s f a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs
| Bool
otherwise = enc -> Tagged True enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged True enc)
-> (S1 s f a -> enc) -> S1 s f a -> Tagged True enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. pairs -> enc
forall enc pairs. FromPairs enc pairs => pairs -> enc
fromPairs (pairs -> enc) -> (S1 s f a -> pairs) -> S1 s f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> S1 s f a -> pairs
forall enc pairs arity (f :: * -> *) a.
RecordToPairs enc pairs arity f =>
Options -> ToArgs enc arity a -> f a -> pairs
recordToPairs Options
opts ToArgs enc arity a
targs
{-# INLINE consToJSON' #-}
instance ( RecordToPairs enc pairs arity f
, FromPairs enc pairs
) => ConsToJSON' enc arity f True
where
consToJSON' :: Options -> ToArgs enc arity a -> f a -> Tagged True enc
consToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs = enc -> Tagged True enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged True enc) -> (f a -> enc) -> f a -> Tagged True enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. pairs -> enc
forall enc pairs. FromPairs enc pairs => pairs -> enc
fromPairs (pairs -> enc) -> (f a -> pairs) -> f a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> pairs
forall enc pairs arity (f :: * -> *) a.
RecordToPairs enc pairs arity f =>
Options -> ToArgs enc arity a -> f a -> pairs
recordToPairs Options
opts ToArgs enc arity a
targs
{-# INLINE consToJSON' #-}
instance GToJSON enc arity f => ConsToJSON' enc arity f False where
consToJSON' :: Options -> ToArgs enc arity a -> f a -> Tagged False enc
consToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs = enc -> Tagged False enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged False enc)
-> (f a -> enc) -> f a -> Tagged False enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> f a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs
{-# INLINE consToJSON' #-}
class RecordToPairs enc pairs arity f where
recordToPairs :: Options -> ToArgs enc arity a
-> f a -> pairs
instance ( Monoid pairs
, RecordToPairs enc pairs arity a
, RecordToPairs enc pairs arity b
) => RecordToPairs enc pairs arity (a :*: b)
where
recordToPairs :: Options -> ToArgs enc arity a -> (:*:) a b a -> pairs
recordToPairs opts :: Options
opts (ToArgs enc arity a
targs :: ToArgs enc arity p) (a :: a a
a :*: b :: b a
b) =
a a -> pairs
forall (f :: * -> *).
RecordToPairs enc pairs arity f =>
f a -> pairs
pairsOf a a
a pairs -> pairs -> pairs
forall a. Monoid a => a -> a -> a
`mappend` b a -> pairs
forall (f :: * -> *).
RecordToPairs enc pairs arity f =>
f a -> pairs
pairsOf b a
b
where
pairsOf :: (RecordToPairs enc pairs arity f) => f p -> pairs
pairsOf :: f a -> pairs
pairsOf = Options -> ToArgs enc arity a -> f a -> pairs
forall enc pairs arity (f :: * -> *) a.
RecordToPairs enc pairs arity f =>
Options -> ToArgs enc arity a -> f a -> pairs
recordToPairs Options
opts ToArgs enc arity a
targs
{-# INLINE recordToPairs #-}
instance ( Selector s
, GToJSON enc arity a
, KeyValuePair enc pairs
) => RecordToPairs enc pairs arity (S1 s a)
where
recordToPairs :: Options -> ToArgs enc arity a -> S1 s a a -> pairs
recordToPairs = Options -> ToArgs enc arity a -> S1 s a a -> pairs
forall (s :: Meta) enc arity (a :: * -> *) pairs p.
(Selector s, GToJSON enc arity a, KeyValuePair enc pairs) =>
Options -> ToArgs enc arity p -> S1 s a p -> pairs
fieldToPair
{-# INLINE recordToPairs #-}
instance INCOHERENT_
( Selector s
, GToJSON enc arity (K1 i (Maybe a))
, KeyValuePair enc pairs
, Monoid pairs
) => RecordToPairs enc pairs arity (S1 s (K1 i (Maybe a)))
where
recordToPairs :: Options -> ToArgs enc arity a -> S1 s (K1 i (Maybe a)) a -> pairs
recordToPairs opts :: Options
opts _ (M1 k1 :: K1 i (Maybe a) a
k1) | Options -> Bool
omitNothingFields Options
opts
, K1 Nothing <- K1 i (Maybe a) a
k1 = pairs
forall a. Monoid a => a
mempty
recordToPairs opts :: Options
opts targs :: ToArgs enc arity a
targs m1 :: S1 s (K1 i (Maybe a)) a
m1 = Options -> ToArgs enc arity a -> S1 s (K1 i (Maybe a)) a -> pairs
forall (s :: Meta) enc arity (a :: * -> *) pairs p.
(Selector s, GToJSON enc arity a, KeyValuePair enc pairs) =>
Options -> ToArgs enc arity p -> S1 s a p -> pairs
fieldToPair Options
opts ToArgs enc arity a
targs S1 s (K1 i (Maybe a)) a
m1
{-# INLINE recordToPairs #-}
instance INCOHERENT_
( Selector s
, GToJSON enc arity (K1 i (Maybe a))
, KeyValuePair enc pairs
, Monoid pairs
) => RecordToPairs enc pairs arity (S1 s (K1 i (Semigroup.Option a)))
where
recordToPairs :: Options -> ToArgs enc arity a -> S1 s (K1 i (Option a)) a -> pairs
recordToPairs opts :: Options
opts targs :: ToArgs enc arity a
targs = Options -> ToArgs enc arity a -> M1 S s (K1 i (Maybe a)) a -> pairs
forall enc pairs arity (f :: * -> *) a.
RecordToPairs enc pairs arity f =>
Options -> ToArgs enc arity a -> f a -> pairs
recordToPairs Options
opts ToArgs enc arity a
targs (M1 S s (K1 i (Maybe a)) a -> pairs)
-> (S1 s (K1 i (Option a)) a -> M1 S s (K1 i (Maybe a)) a)
-> S1 s (K1 i (Option a)) a
-> pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. S1 s (K1 i (Option a)) a -> M1 S s (K1 i (Maybe a)) a
forall k (p :: k).
S1 s (K1 i (Option a)) p -> S1 s (K1 i (Maybe a)) p
unwrap
where
unwrap :: S1 s (K1 i (Semigroup.Option a)) p -> S1 s (K1 i (Maybe a)) p
unwrap :: S1 s (K1 i (Option a)) p -> S1 s (K1 i (Maybe a)) p
unwrap (M1 (K1 (Semigroup.Option a :: Maybe a
a))) = K1 i (Maybe a) p -> S1 s (K1 i (Maybe a)) p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (Maybe a -> K1 i (Maybe a) p
forall k i c (p :: k). c -> K1 i c p
K1 Maybe a
a)
{-# INLINE recordToPairs #-}
fieldToPair :: (Selector s
, GToJSON enc arity a
, KeyValuePair enc pairs)
=> Options -> ToArgs enc arity p
-> S1 s a p -> pairs
fieldToPair :: Options -> ToArgs enc arity p -> S1 s a p -> pairs
fieldToPair opts :: Options
opts targs :: ToArgs enc arity p
targs m1 :: S1 s a p
m1 =
let key :: String
key = Options -> String -> String
fieldLabelModifier Options
opts (S1 s a p -> String
forall k (s :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Selector s =>
t s f a -> String
selName S1 s a p
m1)
value :: enc
value = Options -> ToArgs enc arity p -> a p -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity p
targs (S1 s a p -> a p
forall i (c :: Meta) k (f :: k -> *) (p :: k). M1 i c f p -> f p
unM1 S1 s a p
m1)
in String
key String -> enc -> pairs
forall v kv. KeyValuePair v kv => String -> v -> kv
`pair` enc
value
{-# INLINE fieldToPair #-}
class WriteProduct arity f where
writeProduct :: Options
-> ToArgs Value arity a
-> VM.MVector s Value
-> Int
-> Int
-> f a
-> ST s ()
instance ( WriteProduct arity a
, WriteProduct arity b
) => WriteProduct arity (a :*: b) where
writeProduct :: Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> (:*:) a b a
-> ST s ()
writeProduct opts :: Options
opts targs :: ToArgs Value arity a
targs mv :: MVector s Value
mv ix :: Int
ix len :: Int
len (a :: a a
a :*: b :: b a
b) = do
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> a a
-> ST s ()
forall arity (f :: * -> *) a s.
WriteProduct arity f =>
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> f a
-> ST s ()
writeProduct Options
opts ToArgs Value arity a
targs MVector s Value
mv Int
ix Int
lenL a a
a
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> b a
-> ST s ()
forall arity (f :: * -> *) a s.
WriteProduct arity f =>
Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> f a
-> ST s ()
writeProduct Options
opts ToArgs Value arity a
targs MVector s Value
mv Int
ixR Int
lenR b a
b
where
lenL :: Int
lenL = Int
len Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`unsafeShiftR` 1
lenR :: Int
lenR = Int
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
lenL
ixR :: Int
ixR = Int
ix Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
lenL
{-# INLINE writeProduct #-}
instance OVERLAPPABLE_ (GToJSON Value arity a) => WriteProduct arity a where
writeProduct :: Options
-> ToArgs Value arity a
-> MVector s Value
-> Int
-> Int
-> a a
-> ST s ()
writeProduct opts :: Options
opts targs :: ToArgs Value arity a
targs mv :: MVector s Value
mv ix :: Int
ix _ =
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv Int
ix (Value -> ST s ()) -> (a a -> Value) -> a a -> ST s ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs Value arity a -> a a -> Value
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Value arity a
targs
{-# INLINE writeProduct #-}
class EncodeProduct arity f where
encodeProduct :: Options -> ToArgs Encoding arity a
-> f a -> Encoding' E.InArray
instance ( EncodeProduct arity a
, EncodeProduct arity b
) => EncodeProduct arity (a :*: b) where
encodeProduct :: Options
-> ToArgs Encoding arity a -> (:*:) a b a -> Encoding' InArray
encodeProduct opts :: Options
opts targs :: ToArgs Encoding arity a
targs (a :: a a
a :*: b :: b a
b) | Options -> Bool
omitNothingFields Options
opts =
[Encoding' InArray] -> Encoding' InArray
forall a. [Encoding' a] -> Encoding' a
E.econcat ([Encoding' InArray] -> Encoding' InArray)
-> [Encoding' InArray] -> Encoding' InArray
forall a b. (a -> b) -> a -> b
$ Encoding' InArray -> [Encoding' InArray] -> [Encoding' InArray]
forall a. a -> [a] -> [a]
intersperse Encoding' InArray
forall a. Encoding' a
E.comma ([Encoding' InArray] -> [Encoding' InArray])
-> [Encoding' InArray] -> [Encoding' InArray]
forall a b. (a -> b) -> a -> b
$
(Encoding' InArray -> Bool)
-> [Encoding' InArray] -> [Encoding' InArray]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (Encoding' InArray -> Bool) -> Encoding' InArray -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Encoding' InArray -> Bool
forall a. Encoding' a -> Bool
E.nullEncoding)
[Options -> ToArgs Encoding arity a -> a a -> Encoding' InArray
forall arity (f :: * -> *) a.
EncodeProduct arity f =>
Options -> ToArgs Encoding arity a -> f a -> Encoding' InArray
encodeProduct Options
opts ToArgs Encoding arity a
targs a a
a, Options -> ToArgs Encoding arity a -> b a -> Encoding' InArray
forall arity (f :: * -> *) a.
EncodeProduct arity f =>
Options -> ToArgs Encoding arity a -> f a -> Encoding' InArray
encodeProduct Options
opts ToArgs Encoding arity a
targs b a
b]
encodeProduct opts :: Options
opts targs :: ToArgs Encoding arity a
targs (a :: a a
a :*: b :: b a
b) =
Options -> ToArgs Encoding arity a -> a a -> Encoding' InArray
forall arity (f :: * -> *) a.
EncodeProduct arity f =>
Options -> ToArgs Encoding arity a -> f a -> Encoding' InArray
encodeProduct Options
opts ToArgs Encoding arity a
targs a a
a Encoding' InArray -> Encoding' InArray -> Encoding' InArray
forall a b. Encoding' a -> Encoding' b -> Encoding' InArray
>*<
Options -> ToArgs Encoding arity a -> b a -> Encoding' InArray
forall arity (f :: * -> *) a.
EncodeProduct arity f =>
Options -> ToArgs Encoding arity a -> f a -> Encoding' InArray
encodeProduct Options
opts ToArgs Encoding arity a
targs b a
b
{-# INLINE encodeProduct #-}
instance OVERLAPPABLE_ (GToJSON Encoding arity a) => EncodeProduct arity a where
encodeProduct :: Options -> ToArgs Encoding arity a -> a a -> Encoding' InArray
encodeProduct opts :: Options
opts targs :: ToArgs Encoding arity a
targs a :: a a
a = Encoding -> Encoding' InArray
forall a b. Encoding' a -> Encoding' b
E.retagEncoding (Encoding -> Encoding' InArray) -> Encoding -> Encoding' InArray
forall a b. (a -> b) -> a -> b
$ Options -> ToArgs Encoding arity a -> a a -> Encoding
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs Encoding arity a
targs a a
a
{-# INLINE encodeProduct #-}
instance ( GToJSON enc arity a
, ConsToJSON enc arity a
, FromPairs enc pairs
, KeyValuePair enc pairs
, Constructor c
) => SumToJSON' ObjectWithSingleField enc arity (C1 c a)
where
sumToJSON' :: Options
-> ToArgs enc arity a
-> C1 c a a
-> Tagged ObjectWithSingleField enc
sumToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs =
enc -> Tagged ObjectWithSingleField enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged ObjectWithSingleField enc)
-> (C1 c a a -> enc)
-> C1 c a a
-> Tagged ObjectWithSingleField enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. pairs -> enc
forall enc pairs. FromPairs enc pairs => pairs -> enc
fromPairs (pairs -> enc) -> (C1 c a a -> pairs) -> C1 c a a -> enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
typ String -> enc -> pairs
forall v kv. KeyValuePair v kv => String -> v -> kv
`pair`) (enc -> pairs) -> (C1 c a a -> enc) -> C1 c a a -> pairs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> C1 c a a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs
where
typ :: String
typ = Options -> String -> String
constructorTagModifier Options
opts (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
Any c a Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName (forall k (t :: Meta -> (* -> *) -> k -> *) (p :: k). t c a p
forall a. HasCallStack => a
undefined :: t c a p)
instance OVERLAPPABLE_
( ConsToJSON enc arity a
) => SumToJSON' UntaggedValue enc arity (C1 c a)
where
sumToJSON' :: Options
-> ToArgs enc arity a -> C1 c a a -> Tagged UntaggedValue enc
sumToJSON' opts :: Options
opts targs :: ToArgs enc arity a
targs = enc -> Tagged UntaggedValue enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged UntaggedValue enc)
-> (C1 c a a -> enc) -> C1 c a a -> Tagged UntaggedValue enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> ToArgs enc arity a -> C1 c a a -> enc
forall enc arity (f :: * -> *) a.
GToJSON enc arity f =>
Options -> ToArgs enc arity a -> f a -> enc
gToJSON Options
opts ToArgs enc arity a
targs
instance OVERLAPPING_
( Constructor c
, FromString enc
) => SumToJSON' UntaggedValue enc arity (C1 c U1)
where
sumToJSON' :: Options
-> ToArgs enc arity a -> C1 c U1 a -> Tagged UntaggedValue enc
sumToJSON' opts :: Options
opts _ _ = enc -> Tagged UntaggedValue enc
forall k (s :: k) b. b -> Tagged s b
Tagged (enc -> Tagged UntaggedValue enc)
-> (String -> enc) -> String -> Tagged UntaggedValue enc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> enc
forall enc. FromString enc => String -> enc
fromString (String -> Tagged UntaggedValue enc)
-> String -> Tagged UntaggedValue enc
forall a b. (a -> b) -> a -> b
$
Options -> String -> String
constructorTagModifier Options
opts (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Any c U1 Any -> String
forall k (c :: k) k1 (t :: k -> (k1 -> *) -> k1 -> *)
(f :: k1 -> *) (a :: k1).
Constructor c =>
t c f a -> String
conName (forall k k (t :: Meta -> (k -> *) -> k -> *) (p :: k). t c U1 p
forall a. HasCallStack => a
undefined :: t c U1 p)
instance ToJSON2 Const where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> Const a b
-> Value
liftToJSON2 t :: a -> Value
t _ _ _ (Const x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> Const a b
-> Encoding
liftToEncoding2 t :: a -> Encoding
t _ _ _ (Const x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding2 #-}
instance ToJSON a => ToJSON1 (Const a) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Const a a -> Value
liftToJSON _ _ (Const x :: a
x) = a -> Value
forall a. ToJSON a => a -> Value
toJSON a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Const a a -> Encoding
liftToEncoding _ _ (Const x :: a
x) = a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Const a b) where
toJSON :: Const a b -> Value
toJSON (Const x :: a
x) = a -> Value
forall a. ToJSON a => a -> Value
toJSON a
x
{-# INLINE toJSON #-}
toEncoding :: Const a b -> Encoding
toEncoding (Const x :: a
x) = a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
x
{-# INLINE toEncoding #-}
instance ToJSON1 Maybe where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Maybe a -> Value
liftToJSON t :: a -> Value
t _ (Just a :: a
a) = a -> Value
t a
a
liftToJSON _ _ Nothing = Value
Null
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Just a :: a
a) = a -> Encoding
t a
a
liftToEncoding _ _ Nothing = Encoding
E.null_
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (Maybe a) where
toJSON :: Maybe a -> Value
toJSON = Maybe a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Maybe a -> Encoding
toEncoding = Maybe a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON2 Either where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> Either a b
-> Value
liftToJSON2 toA :: a -> Value
toA _ _toB :: b -> Value
_toB _ (Left a :: a
a) = Object -> Value
Object (Object -> Value) -> Object -> Value
forall a b. (a -> b) -> a -> b
$ Text -> Value -> Object
forall k v. Hashable k => k -> v -> HashMap k v
H.singleton "Left" (a -> Value
toA a
a)
liftToJSON2 _toA :: a -> Value
_toA _ toB :: b -> Value
toB _ (Right b :: b
b) = Object -> Value
Object (Object -> Value) -> Object -> Value
forall a b. (a -> b) -> a -> b
$ Text -> Value -> Object
forall k v. Hashable k => k -> v -> HashMap k v
H.singleton "Right" (b -> Value
toB b
b)
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> Either a b
-> Encoding
liftToEncoding2 toA :: a -> Encoding
toA _ _toB :: b -> Encoding
_toB _ (Left a :: a
a) = Series -> Encoding
E.pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$ Text -> Encoding -> Series
E.pair "Left" (Encoding -> Series) -> Encoding -> Series
forall a b. (a -> b) -> a -> b
$ a -> Encoding
toA a
a
liftToEncoding2 _toA :: a -> Encoding
_toA _ toB :: b -> Encoding
toB _ (Right b :: b
b) = Series -> Encoding
E.pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$ Text -> Encoding -> Series
E.pair "Right" (Encoding -> Series) -> Encoding -> Series
forall a b. (a -> b) -> a -> b
$ b -> Encoding
toB b
b
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a) => ToJSON1 (Either a) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Either a a -> Value
liftToJSON = (a -> Value)
-> ([a] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> Either a a
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Either a a -> Encoding
liftToEncoding = (a -> Encoding)
-> ([a] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> Either a a
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b) => ToJSON (Either a b) where
toJSON :: Either a b -> Value
toJSON = Either a b -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: Either a b -> Encoding
toEncoding = Either a b -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance ToJSON Void where
toJSON :: Void -> Value
toJSON = Void -> Value
forall a. Void -> a
absurd
{-# INLINE toJSON #-}
toEncoding :: Void -> Encoding
toEncoding = Void -> Encoding
forall a. Void -> a
absurd
{-# INLINE toEncoding #-}
instance ToJSON Bool where
toJSON :: Bool -> Value
toJSON = Bool -> Value
Bool
{-# INLINE toJSON #-}
toEncoding :: Bool -> Encoding
toEncoding = Bool -> Encoding
E.bool
{-# INLINE toEncoding #-}
instance ToJSONKey Bool where
toJSONKey :: ToJSONKeyFunction Bool
toJSONKey = (Bool -> Text) -> ToJSONKeyFunction Bool
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText ((Bool -> Text) -> ToJSONKeyFunction Bool)
-> (Bool -> Text) -> ToJSONKeyFunction Bool
forall a b. (a -> b) -> a -> b
$ \x :: Bool
x -> if Bool
x then "true" else "false"
instance ToJSON Ordering where
toJSON :: Ordering -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (Ordering -> Text) -> Ordering -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ordering -> Text
orderingToText
toEncoding :: Ordering -> Encoding
toEncoding = Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Text -> Encoding) -> (Ordering -> Text) -> Ordering -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ordering -> Text
orderingToText
orderingToText :: Ordering -> T.Text
orderingToText :: Ordering -> Text
orderingToText o :: Ordering
o = case Ordering
o of
LT -> "LT"
EQ -> "EQ"
GT -> "GT"
instance ToJSON () where
toJSON :: () -> Value
toJSON _ = Value
emptyArray
{-# INLINE toJSON #-}
toEncoding :: () -> Encoding
toEncoding _ = Encoding
emptyArray_
{-# INLINE toEncoding #-}
instance ToJSON Char where
toJSON :: Char -> Value
toJSON = Text -> Value
String (Text -> Value) -> (Char -> Text) -> Char -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton
{-# INLINE toJSON #-}
toJSONList :: String -> Value
toJSONList = Text -> Value
String (Text -> Value) -> (String -> Text) -> String -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
{-# INLINE toJSONList #-}
toEncoding :: Char -> Encoding
toEncoding = String -> Encoding
forall a. String -> Encoding' a
E.string (String -> Encoding) -> (Char -> String) -> Char -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> String -> String
forall a. a -> [a] -> [a]
:[])
{-# INLINE toEncoding #-}
toEncodingList :: String -> Encoding
toEncodingList = String -> Encoding
forall a. String -> Encoding' a
E.string
{-# INLINE toEncodingList #-}
instance ToJSON Double where
toJSON :: Double -> Value
toJSON = Double -> Value
forall a. RealFloat a => a -> Value
realFloatToJSON
{-# INLINE toJSON #-}
toEncoding :: Double -> Encoding
toEncoding = Double -> Encoding
E.double
{-# INLINE toEncoding #-}
instance ToJSONKey Double where
toJSONKey :: ToJSONKeyFunction Double
toJSONKey = (Double -> Encoding' Text) -> ToJSONKeyFunction Double
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Double -> Encoding' Text
forall a. Double -> Encoding' a
E.doubleText
{-# INLINE toJSONKey #-}
instance ToJSON Number where
toJSON :: Number -> Value
toJSON (D d :: Double
d) = Double -> Value
forall a. ToJSON a => a -> Value
toJSON Double
d
toJSON (I i :: Integer
i) = Integer -> Value
forall a. ToJSON a => a -> Value
toJSON Integer
i
{-# INLINE toJSON #-}
toEncoding :: Number -> Encoding
toEncoding (D d :: Double
d) = Double -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Double
d
toEncoding (I i :: Integer
i) = Integer -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Integer
i
{-# INLINE toEncoding #-}
instance ToJSON Float where
toJSON :: Float -> Value
toJSON = Float -> Value
forall a. RealFloat a => a -> Value
realFloatToJSON
{-# INLINE toJSON #-}
toEncoding :: Float -> Encoding
toEncoding = Float -> Encoding
E.float
{-# INLINE toEncoding #-}
instance ToJSONKey Float where
toJSONKey :: ToJSONKeyFunction Float
toJSONKey = (Float -> Encoding' Text) -> ToJSONKeyFunction Float
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Float -> Encoding' Text
forall a. Float -> Encoding' a
E.floatText
{-# INLINE toJSONKey #-}
instance (ToJSON a, Integral a) => ToJSON (Ratio a) where
toJSON :: Ratio a -> Value
toJSON r :: Ratio a
r = [Pair] -> Value
object [ "numerator" Text -> a -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ratio a -> a
forall a. Ratio a -> a
numerator Ratio a
r
, "denominator" Text -> a -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ratio a -> a
forall a. Ratio a -> a
denominator Ratio a
r
]
{-# INLINE toJSON #-}
toEncoding :: Ratio a -> Encoding
toEncoding r :: Ratio a
r = Series -> Encoding
E.pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$
"numerator" Text -> a -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ratio a -> a
forall a. Ratio a -> a
numerator Ratio a
r Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<>
"denominator" Text -> a -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ratio a -> a
forall a. Ratio a -> a
denominator Ratio a
r
{-# INLINE toEncoding #-}
instance HasResolution a => ToJSON (Fixed a) where
toJSON :: Fixed a -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value)
-> (Fixed a -> Scientific) -> Fixed a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed a -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toJSON #-}
toEncoding :: Fixed a -> Encoding
toEncoding = Scientific -> Encoding
E.scientific (Scientific -> Encoding)
-> (Fixed a -> Scientific) -> Fixed a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed a -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toEncoding #-}
instance HasResolution a => ToJSONKey (Fixed a) where
toJSONKey :: ToJSONKeyFunction (Fixed a)
toJSONKey = (Fixed a -> Encoding' Text) -> ToJSONKeyFunction (Fixed a)
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc (Scientific -> Encoding' Text
forall a. Scientific -> Encoding' a
E.scientificText (Scientific -> Encoding' Text)
-> (Fixed a -> Scientific) -> Fixed a -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed a -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
{-# INLINE toJSONKey #-}
instance ToJSON Int where
toJSON :: Int -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Int -> Scientific) -> Int -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Int -> Encoding
toEncoding = Int -> Encoding
E.int
{-# INLINE toEncoding #-}
instance ToJSONKey Int where
toJSONKey :: ToJSONKeyFunction Int
toJSONKey = (Int -> Encoding' Text) -> ToJSONKeyFunction Int
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Int -> Encoding' Text
forall a. Int -> Encoding' a
E.intText
{-# INLINE toJSONKey #-}
instance ToJSON Integer where
toJSON :: Integer -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value)
-> (Integer -> Scientific) -> Integer -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Scientific
forall a. Num a => Integer -> a
fromInteger
{-# INLINE toJSON #-}
toEncoding :: Integer -> Encoding
toEncoding = Integer -> Encoding
E.integer
{-# INLINE toEncoding #-}
instance ToJSONKey Integer where
toJSONKey :: ToJSONKeyFunction Integer
toJSONKey = (Integer -> Encoding' Text) -> ToJSONKeyFunction Integer
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Integer -> Encoding' Text
forall a. Integer -> Encoding' a
E.integerText
{-# INLINE toJSONKey #-}
instance ToJSON Natural where
toJSON :: Natural -> Value
toJSON = Integer -> Value
forall a. ToJSON a => a -> Value
toJSON (Integer -> Value) -> (Natural -> Integer) -> Natural -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> Integer
forall a. Integral a => a -> Integer
toInteger
{-# INLINE toJSON #-}
toEncoding :: Natural -> Encoding
toEncoding = Integer -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Integer -> Encoding)
-> (Natural -> Integer) -> Natural -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> Integer
forall a. Integral a => a -> Integer
toInteger
{-# INLINE toEncoding #-}
instance ToJSONKey Natural where
toJSONKey :: ToJSONKeyFunction Natural
toJSONKey = (Natural -> Encoding' Text) -> ToJSONKeyFunction Natural
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc (Integer -> Encoding' Text
forall a. Integer -> Encoding' a
E.integerText (Integer -> Encoding' Text)
-> (Natural -> Integer) -> Natural -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> Integer
forall a. Integral a => a -> Integer
toInteger)
{-# INLINE toJSONKey #-}
instance ToJSON Int8 where
toJSON :: Int8 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Int8 -> Scientific) -> Int8 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int8 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Int8 -> Encoding
toEncoding = Int8 -> Encoding
E.int8
{-# INLINE toEncoding #-}
instance ToJSONKey Int8 where
toJSONKey :: ToJSONKeyFunction Int8
toJSONKey = (Int8 -> Encoding' Text) -> ToJSONKeyFunction Int8
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Int8 -> Encoding' Text
forall a. Int8 -> Encoding' a
E.int8Text
{-# INLINE toJSONKey #-}
instance ToJSON Int16 where
toJSON :: Int16 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Int16 -> Scientific) -> Int16 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int16 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Int16 -> Encoding
toEncoding = Int16 -> Encoding
E.int16
{-# INLINE toEncoding #-}
instance ToJSONKey Int16 where
toJSONKey :: ToJSONKeyFunction Int16
toJSONKey = (Int16 -> Encoding' Text) -> ToJSONKeyFunction Int16
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Int16 -> Encoding' Text
forall a. Int16 -> Encoding' a
E.int16Text
{-# INLINE toJSONKey #-}
instance ToJSON Int32 where
toJSON :: Int32 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Int32 -> Scientific) -> Int32 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Int32 -> Encoding
toEncoding = Int32 -> Encoding
E.int32
{-# INLINE toEncoding #-}
instance ToJSONKey Int32 where
toJSONKey :: ToJSONKeyFunction Int32
toJSONKey = (Int32 -> Encoding' Text) -> ToJSONKeyFunction Int32
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Int32 -> Encoding' Text
forall a. Int32 -> Encoding' a
E.int32Text
{-# INLINE toJSONKey #-}
instance ToJSON Int64 where
toJSON :: Int64 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Int64 -> Scientific) -> Int64 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Int64 -> Encoding
toEncoding = Int64 -> Encoding
E.int64
{-# INLINE toEncoding #-}
instance ToJSONKey Int64 where
toJSONKey :: ToJSONKeyFunction Int64
toJSONKey = (Int64 -> Encoding' Text) -> ToJSONKeyFunction Int64
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Int64 -> Encoding' Text
forall a. Int64 -> Encoding' a
E.int64Text
{-# INLINE toJSONKey #-}
instance ToJSON Word where
toJSON :: Word -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Word -> Scientific) -> Word -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Word -> Encoding
toEncoding = Word -> Encoding
E.word
{-# INLINE toEncoding #-}
instance ToJSONKey Word where
toJSONKey :: ToJSONKeyFunction Word
toJSONKey = (Word -> Encoding' Text) -> ToJSONKeyFunction Word
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Word -> Encoding' Text
forall a. Word -> Encoding' a
E.wordText
{-# INLINE toJSONKey #-}
instance ToJSON Word8 where
toJSON :: Word8 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Word8 -> Scientific) -> Word8 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Word8 -> Encoding
toEncoding = Word8 -> Encoding
E.word8
{-# INLINE toEncoding #-}
instance ToJSONKey Word8 where
toJSONKey :: ToJSONKeyFunction Word8
toJSONKey = (Word8 -> Encoding' Text) -> ToJSONKeyFunction Word8
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Word8 -> Encoding' Text
forall a. Word8 -> Encoding' a
E.word8Text
{-# INLINE toJSONKey #-}
instance ToJSON Word16 where
toJSON :: Word16 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Word16 -> Scientific) -> Word16 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word16 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Word16 -> Encoding
toEncoding = Word16 -> Encoding
E.word16
{-# INLINE toEncoding #-}
instance ToJSONKey Word16 where
toJSONKey :: ToJSONKeyFunction Word16
toJSONKey = (Word16 -> Encoding' Text) -> ToJSONKeyFunction Word16
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Word16 -> Encoding' Text
forall a. Word16 -> Encoding' a
E.word16Text
{-# INLINE toJSONKey #-}
instance ToJSON Word32 where
toJSON :: Word32 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Word32 -> Scientific) -> Word32 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Word32 -> Encoding
toEncoding = Word32 -> Encoding
E.word32
{-# INLINE toEncoding #-}
instance ToJSONKey Word32 where
toJSONKey :: ToJSONKeyFunction Word32
toJSONKey = (Word32 -> Encoding' Text) -> ToJSONKeyFunction Word32
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Word32 -> Encoding' Text
forall a. Word32 -> Encoding' a
E.word32Text
{-# INLINE toJSONKey #-}
instance ToJSON Word64 where
toJSON :: Word64 -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value) -> (Word64 -> Scientific) -> Word64 -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE toJSON #-}
toEncoding :: Word64 -> Encoding
toEncoding = Word64 -> Encoding
E.word64
{-# INLINE toEncoding #-}
instance ToJSONKey Word64 where
toJSONKey :: ToJSONKeyFunction Word64
toJSONKey = (Word64 -> Encoding' Text) -> ToJSONKeyFunction Word64
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Word64 -> Encoding' Text
forall a. Word64 -> Encoding' a
E.word64Text
{-# INLINE toJSONKey #-}
instance ToJSON CTime where
toJSON :: CTime -> Value
toJSON (CTime i :: Int64
i) = Int64 -> Value
forall a. ToJSON a => a -> Value
toJSON Int64
i
{-# INLINE toJSON #-}
toEncoding :: CTime -> Encoding
toEncoding (CTime i :: Int64
i) = Int64 -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Int64
i
{-# INLINE toEncoding #-}
instance ToJSON Text where
toJSON :: Text -> Value
toJSON = Text -> Value
String
{-# INLINE toJSON #-}
toEncoding :: Text -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
E.text
{-# INLINE toEncoding #-}
instance ToJSONKey Text where
toJSONKey :: ToJSONKeyFunction Text
toJSONKey = (Text -> Text) -> ToJSONKeyFunction Text
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText Text -> Text
forall a. a -> a
id
{-# INLINE toJSONKey #-}
instance ToJSON LT.Text where
toJSON :: Text -> Value
toJSON = Text -> Value
String (Text -> Value) -> (Text -> Text) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
LT.toStrict
{-# INLINE toJSON #-}
toEncoding :: Text -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
E.lazyText
{-# INLINE toEncoding #-}
instance ToJSONKey LT.Text where
toJSONKey :: ToJSONKeyFunction Text
toJSONKey = (Text -> Text) -> ToJSONKeyFunction Text
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText Text -> Text
LT.toStrict
instance ToJSON Version where
toJSON :: Version -> Value
toJSON = String -> Value
forall a. ToJSON a => a -> Value
toJSON (String -> Value) -> (Version -> String) -> Version -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> String
showVersion
{-# INLINE toJSON #-}
toEncoding :: Version -> Encoding
toEncoding = String -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (String -> Encoding) -> (Version -> String) -> Version -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> String
showVersion
{-# INLINE toEncoding #-}
instance ToJSONKey Version where
toJSONKey :: ToJSONKeyFunction Version
toJSONKey = (Version -> Text) -> ToJSONKeyFunction Version
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText (String -> Text
T.pack (String -> Text) -> (Version -> String) -> Version -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> String
showVersion)
instance ToJSON1 NonEmpty where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> NonEmpty a -> Value
liftToJSON t :: a -> Value
t _ = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
t ([a] -> Value) -> (NonEmpty a -> [a]) -> NonEmpty a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty a -> [a]
forall a. NonEmpty a -> [a]
NE.toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> NonEmpty a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (NonEmpty a -> [a]) -> NonEmpty a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty a -> [a]
forall a. NonEmpty a -> [a]
NE.toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (NonEmpty a) where
toJSON :: NonEmpty a -> Value
toJSON = NonEmpty a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: NonEmpty a -> Encoding
toEncoding = NonEmpty a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON Scientific where
toJSON :: Scientific -> Value
toJSON = Scientific -> Value
Number
{-# INLINE toJSON #-}
toEncoding :: Scientific -> Encoding
toEncoding = Scientific -> Encoding
E.scientific
{-# INLINE toEncoding #-}
instance ToJSONKey Scientific where
toJSONKey :: ToJSONKeyFunction Scientific
toJSONKey = (Scientific -> Encoding' Text) -> ToJSONKeyFunction Scientific
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Scientific -> Encoding' Text
forall a. Scientific -> Encoding' a
E.scientificText
instance ToJSON1 DList.DList where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> DList a -> Value
liftToJSON t :: a -> Value
t _ = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
t ([a] -> Value) -> (DList a -> [a]) -> DList a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DList a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> DList a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (DList a -> [a]) -> DList a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DList a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (DList.DList a) where
toJSON :: DList a -> Value
toJSON = DList a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: DList a -> Encoding
toEncoding = DList a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Identity where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Identity a -> Value
liftToJSON t :: a -> Value
t _ (Identity a :: a
a) = a -> Value
t a
a
{-# INLINE liftToJSON #-}
liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Identity a] -> Value
liftToJSONList _ tl :: [a] -> Value
tl xs :: [Identity a]
xs = [a] -> Value
tl ((Identity a -> a) -> [Identity a] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Identity a -> a
forall a. Identity a -> a
runIdentity [Identity a]
xs)
{-# INLINE liftToJSONList #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Identity a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Identity a :: a
a) = a -> Encoding
t a
a
{-# INLINE liftToEncoding #-}
liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Identity a] -> Encoding
liftToEncodingList _ tl :: [a] -> Encoding
tl xs :: [Identity a]
xs = [a] -> Encoding
tl ((Identity a -> a) -> [Identity a] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Identity a -> a
forall a. Identity a -> a
runIdentity [Identity a]
xs)
{-# INLINE liftToEncodingList #-}
instance (ToJSON a) => ToJSON (Identity a) where
toJSON :: Identity a -> Value
toJSON = Identity a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toJSONList :: [Identity a] -> Value
toJSONList = (a -> Value) -> ([a] -> Value) -> [Identity a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE toJSONList #-}
toEncoding :: Identity a -> Encoding
toEncoding = Identity a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
toEncodingList :: [Identity a] -> Encoding
toEncodingList = (a -> Encoding) -> ([a] -> Encoding) -> [Identity a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE toEncodingList #-}
instance (ToJSONKey a) => ToJSONKey (Identity a) where
toJSONKey :: ToJSONKeyFunction (Identity a)
toJSONKey = (Identity a -> a)
-> ToJSONKeyFunction a -> ToJSONKeyFunction (Identity a)
forall a b. (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramapToJSONKeyFunction Identity a -> a
forall a. Identity a -> a
runIdentity ToJSONKeyFunction a
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey
toJSONKeyList :: ToJSONKeyFunction [Identity a]
toJSONKeyList = ([Identity a] -> [a])
-> ToJSONKeyFunction [a] -> ToJSONKeyFunction [Identity a]
forall a b. (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramapToJSONKeyFunction ((Identity a -> a) -> [Identity a] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Identity a -> a
forall a. Identity a -> a
runIdentity) ToJSONKeyFunction [a]
forall a. ToJSONKey a => ToJSONKeyFunction [a]
toJSONKeyList
instance (ToJSON1 f, ToJSON1 g) => ToJSON1 (Compose f g) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Compose f g a -> Value
liftToJSON tv :: a -> Value
tv tvl :: [a] -> Value
tvl (Compose x :: f (g a)
x) = (g a -> Value) -> ([g a] -> Value) -> f (g a) -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON g a -> Value
g [g a] -> Value
gl f (g a)
x
where
g :: g a -> Value
g = (a -> Value) -> ([a] -> Value) -> g a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tv [a] -> Value
tvl
gl :: [g a] -> Value
gl = (a -> Value) -> ([a] -> Value) -> [g a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
tv [a] -> Value
tvl
{-# INLINE liftToJSON #-}
liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Compose f g a] -> Value
liftToJSONList te :: a -> Value
te tel :: [a] -> Value
tel xs :: [Compose f g a]
xs = (g a -> Value) -> ([g a] -> Value) -> [f (g a)] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList g a -> Value
g [g a] -> Value
gl ((Compose f g a -> f (g a)) -> [Compose f g a] -> [f (g a)]
forall a b. (a -> b) -> [a] -> [b]
map Compose f g a -> f (g a)
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose [Compose f g a]
xs)
where
g :: g a -> Value
g = (a -> Value) -> ([a] -> Value) -> g a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
te [a] -> Value
tel
gl :: [g a] -> Value
gl = (a -> Value) -> ([a] -> Value) -> [g a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
te [a] -> Value
tel
{-# INLINE liftToJSONList #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Compose f g a -> Encoding
liftToEncoding te :: a -> Encoding
te tel :: [a] -> Encoding
tel (Compose x :: f (g a)
x) = (g a -> Encoding) -> ([g a] -> Encoding) -> f (g a) -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding g a -> Encoding
g [g a] -> Encoding
gl f (g a)
x
where
g :: g a -> Encoding
g = (a -> Encoding) -> ([a] -> Encoding) -> g a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel
gl :: [g a] -> Encoding
gl = (a -> Encoding) -> ([a] -> Encoding) -> [g a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
te [a] -> Encoding
tel
{-# INLINE liftToEncoding #-}
liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Compose f g a] -> Encoding
liftToEncodingList te :: a -> Encoding
te tel :: [a] -> Encoding
tel xs :: [Compose f g a]
xs = (g a -> Encoding) -> ([g a] -> Encoding) -> [f (g a)] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList g a -> Encoding
g [g a] -> Encoding
gl ((Compose f g a -> f (g a)) -> [Compose f g a] -> [f (g a)]
forall a b. (a -> b) -> [a] -> [b]
map Compose f g a -> f (g a)
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose [Compose f g a]
xs)
where
g :: g a -> Encoding
g = (a -> Encoding) -> ([a] -> Encoding) -> g a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel
gl :: [g a] -> Encoding
gl = (a -> Encoding) -> ([a] -> Encoding) -> [g a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
te [a] -> Encoding
tel
{-# INLINE liftToEncodingList #-}
instance (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Compose f g a) where
toJSON :: Compose f g a -> Value
toJSON = Compose f g a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toJSONList :: [Compose f g a] -> Value
toJSONList = (a -> Value) -> ([a] -> Value) -> [Compose f g a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE toJSONList #-}
toEncoding :: Compose f g a -> Encoding
toEncoding = Compose f g a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
toEncodingList :: [Compose f g a] -> Encoding
toEncodingList = (a -> Encoding) -> ([a] -> Encoding) -> [Compose f g a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE toEncodingList #-}
instance (ToJSON1 f, ToJSON1 g) => ToJSON1 (Product f g) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Product f g a -> Value
liftToJSON tv :: a -> Value
tv tvl :: [a] -> Value
tvl (Pair x :: f a
x y :: g a
y) = (f a -> Value)
-> ([f a] -> Value)
-> (g a -> Value)
-> ([g a] -> Value)
-> (f a, g a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 f a -> Value
tx [f a] -> Value
txl g a -> Value
ty [g a] -> Value
tyl (f a
x, g a
y)
where
tx :: f a -> Value
tx = (a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tv [a] -> Value
tvl
txl :: [f a] -> Value
txl = (a -> Value) -> ([a] -> Value) -> [f a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
tv [a] -> Value
tvl
ty :: g a -> Value
ty = (a -> Value) -> ([a] -> Value) -> g a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tv [a] -> Value
tvl
tyl :: [g a] -> Value
tyl = (a -> Value) -> ([a] -> Value) -> [g a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList a -> Value
tv [a] -> Value
tvl
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Product f g a -> Encoding
liftToEncoding te :: a -> Encoding
te tel :: [a] -> Encoding
tel (Pair x :: f a
x y :: g a
y) = (f a -> Encoding)
-> ([f a] -> Encoding)
-> (g a -> Encoding)
-> ([g a] -> Encoding)
-> (f a, g a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 f a -> Encoding
tx [f a] -> Encoding
txl g a -> Encoding
ty [g a] -> Encoding
tyl (f a
x, g a
y)
where
tx :: f a -> Encoding
tx = (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel
txl :: [f a] -> Encoding
txl = (a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
te [a] -> Encoding
tel
ty :: g a -> Encoding
ty = (a -> Encoding) -> ([a] -> Encoding) -> g a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel
tyl :: [g a] -> Encoding
tyl = (a -> Encoding) -> ([a] -> Encoding) -> [g a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList a -> Encoding
te [a] -> Encoding
tel
instance (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Product f g a) where
toJSON :: Product f g a -> Value
toJSON = Product f g a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Product f g a -> Encoding
toEncoding = Product f g a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance (ToJSON1 f, ToJSON1 g) => ToJSON1 (Sum f g) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Sum f g a -> Value
liftToJSON tv :: a -> Value
tv tvl :: [a] -> Value
tvl (InL x :: f a
x) = Object -> Value
Object (Object -> Value) -> Object -> Value
forall a b. (a -> b) -> a -> b
$ Text -> Value -> Object
forall k v. Hashable k => k -> v -> HashMap k v
H.singleton "InL" ((a -> Value) -> ([a] -> Value) -> f a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tv [a] -> Value
tvl f a
x)
liftToJSON tv :: a -> Value
tv tvl :: [a] -> Value
tvl (InR y :: g a
y) = Object -> Value
Object (Object -> Value) -> Object -> Value
forall a b. (a -> b) -> a -> b
$ Text -> Value -> Object
forall k v. Hashable k => k -> v -> HashMap k v
H.singleton "InR" ((a -> Value) -> ([a] -> Value) -> g a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
tv [a] -> Value
tvl g a
y)
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Sum f g a -> Encoding
liftToEncoding te :: a -> Encoding
te tel :: [a] -> Encoding
tel (InL x :: f a
x) = Series -> Encoding
E.pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$ Text -> Encoding -> Series
E.pair "InL" (Encoding -> Series) -> Encoding -> Series
forall a b. (a -> b) -> a -> b
$ (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel f a
x
liftToEncoding te :: a -> Encoding
te tel :: [a] -> Encoding
tel (InR y :: g a
y) = Series -> Encoding
E.pairs (Series -> Encoding) -> Series -> Encoding
forall a b. (a -> b) -> a -> b
$ Text -> Encoding -> Series
E.pair "InR" (Encoding -> Series) -> Encoding -> Series
forall a b. (a -> b) -> a -> b
$ (a -> Encoding) -> ([a] -> Encoding) -> g a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
te [a] -> Encoding
tel g a
y
instance (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Sum f g a) where
toJSON :: Sum f g a -> Value
toJSON = Sum f g a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Sum f g a -> Encoding
toEncoding = Sum f g a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Seq.Seq where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Seq a -> Value
liftToJSON t :: a -> Value
t _ = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
t ([a] -> Value) -> (Seq a -> [a]) -> Seq a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Seq a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (Seq a -> [a]) -> Seq a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (Seq.Seq a) where
toJSON :: Seq a -> Value
toJSON = Seq a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Seq a -> Encoding
toEncoding = Seq a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Set.Set where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Set a -> Value
liftToJSON t :: a -> Value
t _ = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
t ([a] -> Value) -> (Set a -> [a]) -> Set a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
Set.toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Set a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (Set a -> [a]) -> Set a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
Set.toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (Set.Set a) where
toJSON :: Set a -> Value
toJSON = Set a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Set a -> Encoding
toEncoding = Set a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON IntSet.IntSet where
toJSON :: IntSet -> Value
toJSON = [Int] -> Value
forall a. ToJSON a => a -> Value
toJSON ([Int] -> Value) -> (IntSet -> [Int]) -> IntSet -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntSet -> [Int]
IntSet.toList
{-# INLINE toJSON #-}
toEncoding :: IntSet -> Encoding
toEncoding = [Int] -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding ([Int] -> Encoding) -> (IntSet -> [Int]) -> IntSet -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntSet -> [Int]
IntSet.toList
{-# INLINE toEncoding #-}
instance ToJSON1 IntMap.IntMap where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> IntMap a -> Value
liftToJSON t :: a -> Value
t tol :: [a] -> Value
tol = ((Int, a) -> Value) -> ([(Int, a)] -> Value) -> [(Int, a)] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON (Int, a) -> Value
to' [(Int, a)] -> Value
tol' ([(Int, a)] -> Value)
-> (IntMap a -> [(Int, a)]) -> IntMap a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList
where
to' :: (Int, a) -> Value
to' = (Int -> Value)
-> ([Int] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (Int, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 Int -> Value
forall a. ToJSON a => a -> Value
toJSON [Int] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList a -> Value
t [a] -> Value
tol
tol' :: [(Int, a)] -> Value
tol' = (Int -> Value)
-> ([Int] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> [(Int, a)]
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> [f a b]
-> Value
liftToJSONList2 Int -> Value
forall a. ToJSON a => a -> Value
toJSON [Int] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList a -> Value
t [a] -> Value
tol
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> IntMap a -> Encoding
liftToEncoding t :: a -> Encoding
t tol :: [a] -> Encoding
tol = ((Int, a) -> Encoding)
-> ([(Int, a)] -> Encoding) -> [(Int, a)] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding (Int, a) -> Encoding
to' [(Int, a)] -> Encoding
tol' ([(Int, a)] -> Encoding)
-> (IntMap a -> [(Int, a)]) -> IntMap a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap a -> [(Int, a)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList
where
to' :: (Int, a) -> Encoding
to' = (Int -> Encoding)
-> ([Int] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (Int, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 Int -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [Int] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList a -> Encoding
t [a] -> Encoding
tol
tol' :: [(Int, a)] -> Encoding
tol' = (Int -> Encoding)
-> ([Int] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> [(Int, a)]
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> [f a b]
-> Encoding
liftToEncodingList2 Int -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [Int] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList a -> Encoding
t [a] -> Encoding
tol
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (IntMap.IntMap a) where
toJSON :: IntMap a -> Value
toJSON = IntMap a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: IntMap a -> Encoding
toEncoding = IntMap a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSONKey k => ToJSON1 (M.Map k) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Map k a -> Value
liftToJSON g :: a -> Value
g _ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey of
ToJSONKeyText f :: k -> Text
f _ -> Object -> Value
Object (Object -> Value) -> (Map k a -> Object) -> Map k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k -> Text) -> (a -> Value) -> Map k a -> Object
forall k2 k1 v1 v2.
(Eq k2, Hashable k2) =>
(k1 -> k2) -> (v1 -> v2) -> Map k1 v1 -> HashMap k2 v2
mapHashKeyVal k -> Text
f a -> Value
g
ToJSONKeyValue f :: k -> Value
f _ -> Array -> Value
Array (Array -> Value) -> (Map k a -> Array) -> Map k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Value] -> Array
forall a. [a] -> Vector a
V.fromList ([Value] -> Array) -> (Map k a -> [Value]) -> Map k a -> Array
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, a) -> Value) -> [(k, a)] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map ((k -> Value) -> (a -> Value) -> (k, a) -> Value
forall a b. (a -> Value) -> (b -> Value) -> (a, b) -> Value
toJSONPair k -> Value
f a -> Value
g) ([(k, a)] -> [Value])
-> (Map k a -> [(k, a)]) -> Map k a -> [Value]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k a -> [(k, a)]
forall k a. Map k a -> [(k, a)]
M.toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Map k a -> Encoding
liftToEncoding g :: a -> Encoding
g _ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey of
ToJSONKeyText _ f :: k -> Encoding' Text
f -> (k -> Encoding' Text)
-> (a -> Encoding)
-> (forall a. (k -> a -> a -> a) -> a -> Map k a -> a)
-> Map k a
-> Encoding
forall k v m.
(k -> Encoding' Text)
-> (v -> Encoding)
-> (forall a. (k -> v -> a -> a) -> a -> m -> a)
-> m
-> Encoding
dict k -> Encoding' Text
f a -> Encoding
g forall a. (k -> a -> a -> a) -> a -> Map k a -> a
forall k a b. (k -> a -> b -> b) -> b -> Map k a -> b
M.foldrWithKey
ToJSONKeyValue _ f :: k -> Encoding
f -> ((k, a) -> Encoding) -> [(k, a)] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding ((k -> Encoding) -> (k, a) -> Encoding
pairEncoding k -> Encoding
f) ([(k, a)] -> Encoding)
-> (Map k a -> [(k, a)]) -> Map k a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k a -> [(k, a)]
forall k a. Map k a -> [(k, a)]
M.toList
where
pairEncoding :: (k -> Encoding) -> (k, a) -> Encoding
pairEncoding f :: k -> Encoding
f (a :: k
a, b :: a
b) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id [k -> Encoding
f k
a, a -> Encoding
g a
b]
{-# INLINE liftToEncoding #-}
instance (ToJSON v, ToJSONKey k) => ToJSON (M.Map k v) where
toJSON :: Map k v -> Value
toJSON = Map k v -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Map k v -> Encoding
toEncoding = Map k v -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Tree.Tree where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Tree a -> Value
liftToJSON t :: a -> Value
t tol :: [a] -> Value
tol = Tree a -> Value
go
where
go :: Tree a -> Value
go (Tree.Node root :: a
root branches :: Forest a
branches) =
(a -> Value)
-> ([a] -> Value)
-> (Forest a -> Value)
-> ([Forest a] -> Value)
-> (a, Forest a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
t [a] -> Value
tol Forest a -> Value
to' [Forest a] -> Value
tol' (a
root, Forest a
branches)
to' :: Forest a -> Value
to' = (Tree a -> Value) -> (Forest a -> Value) -> Forest a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON Tree a -> Value
go ((Tree a -> Value) -> Forest a -> Value
forall a. (a -> Value) -> [a] -> Value
listValue Tree a -> Value
go)
tol' :: [Forest a] -> Value
tol' = (Tree a -> Value) -> (Forest a -> Value) -> [Forest a] -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToJSONList Tree a -> Value
go ((Tree a -> Value) -> Forest a -> Value
forall a. (a -> Value) -> [a] -> Value
listValue Tree a -> Value
go)
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Tree a -> Encoding
liftToEncoding t :: a -> Encoding
t tol :: [a] -> Encoding
tol = Tree a -> Encoding
go
where
go :: Tree a -> Encoding
go (Tree.Node root :: a
root branches :: Forest a
branches) =
(a -> Encoding)
-> ([a] -> Encoding)
-> (Forest a -> Encoding)
-> ([Forest a] -> Encoding)
-> (a, Forest a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 a -> Encoding
t [a] -> Encoding
tol Forest a -> Encoding
to' [Forest a] -> Encoding
tol' (a
root, Forest a
branches)
to' :: Forest a -> Encoding
to' = (Tree a -> Encoding)
-> (Forest a -> Encoding) -> Forest a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding Tree a -> Encoding
go ((Tree a -> Encoding) -> Forest a -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding Tree a -> Encoding
go)
tol' :: [Forest a] -> Encoding
tol' = (Tree a -> Encoding)
-> (Forest a -> Encoding) -> [Forest a] -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
liftToEncodingList Tree a -> Encoding
go ((Tree a -> Encoding) -> Forest a -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding Tree a -> Encoding
go)
{-# INLINE liftToEncoding #-}
instance (ToJSON v) => ToJSON (Tree.Tree v) where
toJSON :: Tree v -> Value
toJSON = Tree v -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Tree v -> Encoding
toEncoding = Tree v -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON UUID.UUID where
toJSON :: UUID -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (UUID -> Text) -> UUID -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText
toEncoding :: UUID -> Encoding
toEncoding = Builder -> Encoding
forall a. Builder -> Encoding' a
E.unsafeToEncoding (Builder -> Encoding) -> (UUID -> Builder) -> UUID -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Builder
EB.quote (Builder -> Builder) -> (UUID -> Builder) -> UUID -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Builder
B.byteString (ByteString -> Builder) -> (UUID -> ByteString) -> UUID -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> ByteString
UUID.toASCIIBytes
instance ToJSONKey UUID.UUID where
toJSONKey :: ToJSONKeyFunction UUID
toJSONKey = (UUID -> Text)
-> (UUID -> Encoding' Text) -> ToJSONKeyFunction UUID
forall a.
(a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
ToJSONKeyText UUID -> Text
UUID.toText ((UUID -> Encoding' Text) -> ToJSONKeyFunction UUID)
-> (UUID -> Encoding' Text) -> ToJSONKeyFunction UUID
forall a b. (a -> b) -> a -> b
$
Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding (Builder -> Encoding' Text)
-> (UUID -> Builder) -> UUID -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Builder
EB.quote (Builder -> Builder) -> (UUID -> Builder) -> UUID -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Builder
B.byteString (ByteString -> Builder) -> (UUID -> ByteString) -> UUID -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> ByteString
UUID.toASCIIBytes
instance ToJSON1 Vector where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Vector a -> Value
liftToJSON t :: a -> Value
t _ = Array -> Value
Array (Array -> Value) -> (Vector a -> Array) -> Vector a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Value) -> Vector a -> Array
forall a b. (a -> b) -> Vector a -> Vector b
V.map a -> Value
t
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Vector a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (Vector a -> [a]) -> Vector a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector a -> [a]
forall a. Vector a -> [a]
V.toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (Vector a) where
{-# SPECIALIZE instance ToJSON Array #-}
toJSON :: Vector a -> Value
toJSON = Vector a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Vector a -> Encoding
toEncoding = Vector a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
encodeVector :: (ToJSON a, VG.Vector v a) => v a -> Encoding
encodeVector :: v a -> Encoding
encodeVector = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding ([a] -> Encoding) -> (v a -> [a]) -> v a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v a -> [a]
forall (v :: * -> *) a. Vector v a => v a -> [a]
VG.toList
{-# INLINE encodeVector #-}
vectorToJSON :: (VG.Vector v a, ToJSON a) => v a -> Value
vectorToJSON :: v a -> Value
vectorToJSON = Array -> Value
Array (Array -> Value) -> (v a -> Array) -> v a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Value) -> Vector a -> Array
forall a b. (a -> b) -> Vector a -> Vector b
V.map a -> Value
forall a. ToJSON a => a -> Value
toJSON (Vector a -> Array) -> (v a -> Vector a) -> v a -> Array
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v a -> Vector a
forall (v :: * -> *) a (w :: * -> *).
(Vector v a, Vector w a) =>
v a -> w a
V.convert
{-# INLINE vectorToJSON #-}
instance (Storable a, ToJSON a) => ToJSON (VS.Vector a) where
toJSON :: Vector a -> Value
toJSON = Vector a -> Value
forall (v :: * -> *) a. (Vector v a, ToJSON a) => v a -> Value
vectorToJSON
{-# INLINE toJSON #-}
toEncoding :: Vector a -> Encoding
toEncoding = Vector a -> Encoding
forall a (v :: * -> *). (ToJSON a, Vector v a) => v a -> Encoding
encodeVector
{-# INLINE toEncoding #-}
instance (VP.Prim a, ToJSON a) => ToJSON (VP.Vector a) where
toJSON :: Vector a -> Value
toJSON = Vector a -> Value
forall (v :: * -> *) a. (Vector v a, ToJSON a) => v a -> Value
vectorToJSON
{-# INLINE toJSON #-}
toEncoding :: Vector a -> Encoding
toEncoding = Vector a -> Encoding
forall a (v :: * -> *). (ToJSON a, Vector v a) => v a -> Encoding
encodeVector
{-# INLINE toEncoding #-}
instance (VG.Vector VU.Vector a, ToJSON a) => ToJSON (VU.Vector a) where
toJSON :: Vector a -> Value
toJSON = Vector a -> Value
forall (v :: * -> *) a. (Vector v a, ToJSON a) => v a -> Value
vectorToJSON
{-# INLINE toJSON #-}
toEncoding :: Vector a -> Encoding
toEncoding = Vector a -> Encoding
forall a (v :: * -> *). (ToJSON a, Vector v a) => v a -> Encoding
encodeVector
{-# INLINE toEncoding #-}
instance ToJSON1 HashSet.HashSet where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> HashSet a -> Value
liftToJSON t :: a -> Value
t _ = (a -> Value) -> [a] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue a -> Value
t ([a] -> Value) -> (HashSet a -> [a]) -> HashSet a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashSet a -> [a]
forall a. HashSet a -> [a]
HashSet.toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> HashSet a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = (a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding a -> Encoding
t ([a] -> Encoding) -> (HashSet a -> [a]) -> HashSet a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashSet a -> [a]
forall a. HashSet a -> [a]
HashSet.toList
{-# INLINE liftToEncoding #-}
instance (ToJSON a) => ToJSON (HashSet.HashSet a) where
toJSON :: HashSet a -> Value
toJSON = HashSet a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: HashSet a -> Encoding
toEncoding = HashSet a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSONKey k => ToJSON1 (H.HashMap k) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> HashMap k a -> Value
liftToJSON g :: a -> Value
g _ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey of
ToJSONKeyText f :: k -> Text
f _ -> Object -> Value
Object (Object -> Value)
-> (HashMap k a -> Object) -> HashMap k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k -> Text) -> (a -> Value) -> HashMap k a -> Object
forall k2 k1 v1 v2.
(Eq k2, Hashable k2) =>
(k1 -> k2) -> (v1 -> v2) -> HashMap k1 v1 -> HashMap k2 v2
mapKeyVal k -> Text
f a -> Value
g
ToJSONKeyValue f :: k -> Value
f _ -> Array -> Value
Array (Array -> Value) -> (HashMap k a -> Array) -> HashMap k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Value] -> Array
forall a. [a] -> Vector a
V.fromList ([Value] -> Array)
-> (HashMap k a -> [Value]) -> HashMap k a -> Array
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, a) -> Value) -> [(k, a)] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map ((k -> Value) -> (a -> Value) -> (k, a) -> Value
forall a b. (a -> Value) -> (b -> Value) -> (a, b) -> Value
toJSONPair k -> Value
f a -> Value
g) ([(k, a)] -> [Value])
-> (HashMap k a -> [(k, a)]) -> HashMap k a -> [Value]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k a -> [(k, a)]
forall k v. HashMap k v -> [(k, v)]
H.toList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> HashMap k a -> Encoding
liftToEncoding g :: a -> Encoding
g _ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey of
ToJSONKeyText _ f :: k -> Encoding' Text
f -> (k -> Encoding' Text)
-> (a -> Encoding)
-> (forall a. (k -> a -> a -> a) -> a -> HashMap k a -> a)
-> HashMap k a
-> Encoding
forall k v m.
(k -> Encoding' Text)
-> (v -> Encoding)
-> (forall a. (k -> v -> a -> a) -> a -> m -> a)
-> m
-> Encoding
dict k -> Encoding' Text
f a -> Encoding
g forall a. (k -> a -> a -> a) -> a -> HashMap k a -> a
forall k v a. (k -> v -> a -> a) -> a -> HashMap k v -> a
H.foldrWithKey
ToJSONKeyValue _ f :: k -> Encoding
f -> ((k, a) -> Encoding) -> [(k, a)] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
listEncoding ((k -> Encoding) -> (k, a) -> Encoding
pairEncoding k -> Encoding
f) ([(k, a)] -> Encoding)
-> (HashMap k a -> [(k, a)]) -> HashMap k a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k a -> [(k, a)]
forall k v. HashMap k v -> [(k, v)]
H.toList
where
pairEncoding :: (k -> Encoding) -> (k, a) -> Encoding
pairEncoding f :: k -> Encoding
f (a :: k
a, b :: a
b) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id [k -> Encoding
f k
a, a -> Encoding
g a
b]
{-# INLINE liftToEncoding #-}
instance (ToJSON v, ToJSONKey k) => ToJSON (H.HashMap k v) where
{-# SPECIALIZE instance ToJSON Object #-}
toJSON :: HashMap k v -> Value
toJSON = HashMap k v -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: HashMap k v -> Encoding
toEncoding = HashMap k v -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON Value where
toJSON :: Value -> Value
toJSON a :: Value
a = Value
a
{-# INLINE toJSON #-}
toEncoding :: Value -> Encoding
toEncoding = Value -> Encoding
E.value
{-# INLINE toEncoding #-}
instance ToJSON DotNetTime where
toJSON :: DotNetTime -> Value
toJSON = String -> Value
forall a. ToJSON a => a -> Value
toJSON (String -> Value) -> (DotNetTime -> String) -> DotNetTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DotNetTime -> String
dotNetTime
toEncoding :: DotNetTime -> Encoding
toEncoding = String -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (String -> Encoding)
-> (DotNetTime -> String) -> DotNetTime -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DotNetTime -> String
dotNetTime
dotNetTime :: DotNetTime -> String
dotNetTime :: DotNetTime -> String
dotNetTime (DotNetTime t :: UTCTime
t) = String
secs String -> String -> String
forall a. [a] -> [a] -> [a]
++ UTCTime -> String
forall t. FormatTime t => t -> String
formatMillis UTCTime
t String -> String -> String
forall a. [a] -> [a] -> [a]
++ ")/"
where secs :: String
secs = TimeLocale -> String -> UTCTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale "/Date(%s" UTCTime
t
formatMillis :: (FormatTime t) => t -> String
formatMillis :: t -> String
formatMillis = Int -> String -> String
forall a. Int -> [a] -> [a]
take 3 (String -> String) -> (t -> String) -> t -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeLocale -> String -> t -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale "%q"
#if MIN_VERSION_base(4,7,0)
instance ToJSON a => ToJSON (PM.Array a) where
toJSON :: Array a -> Value
toJSON = [a] -> Value
forall a. ToJSON a => a -> Value
toJSON ([a] -> Value) -> (Array a -> [a]) -> Array a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
toEncoding :: Array a -> Encoding
toEncoding = [a] -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding ([a] -> Encoding) -> (Array a -> [a]) -> Array a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
instance ToJSON a => ToJSON (PM.SmallArray a) where
toJSON :: SmallArray a -> Value
toJSON = [a] -> Value
forall a. ToJSON a => a -> Value
toJSON ([a] -> Value) -> (SmallArray a -> [a]) -> SmallArray a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmallArray a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
toEncoding :: SmallArray a -> Encoding
toEncoding = [a] -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding ([a] -> Encoding)
-> (SmallArray a -> [a]) -> SmallArray a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmallArray a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
#if (MIN_VERSION_primitive(0,6,4))
instance (PM.Prim a,ToJSON a) => ToJSON (PM.PrimArray a) where
toJSON :: PrimArray a -> Value
toJSON = [a] -> Value
forall a. ToJSON a => a -> Value
toJSON ([a] -> Value) -> (PrimArray a -> [a]) -> PrimArray a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimArray a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
toEncoding :: PrimArray a -> Encoding
toEncoding = [a] -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding ([a] -> Encoding)
-> (PrimArray a -> [a]) -> PrimArray a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimArray a -> [a]
forall l. IsList l => l -> [Item l]
Exts.toList
#if !MIN_VERSION_primitive(0,7,0)
instance (PM.PrimUnlifted a,ToJSON a) => ToJSON (PM.UnliftedArray a) where
toJSON = toJSON . Exts.toList
toEncoding = toEncoding . Exts.toList
#endif
#endif
#endif
instance ToJSON Day where
toJSON :: Day -> Value
toJSON = Encoding' Text -> Value
stringEncoding (Encoding' Text -> Value)
-> (Day -> Encoding' Text) -> Day -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> Encoding' Text
forall a. Day -> Encoding' a
E.day
toEncoding :: Day -> Encoding
toEncoding = Day -> Encoding
forall a. Day -> Encoding' a
E.day
instance ToJSONKey Day where
toJSONKey :: ToJSONKeyFunction Day
toJSONKey = (Day -> Encoding' Text) -> ToJSONKeyFunction Day
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc Day -> Encoding' Text
forall a. Day -> Encoding' a
E.day
instance ToJSON TimeOfDay where
toJSON :: TimeOfDay -> Value
toJSON = Encoding' Text -> Value
stringEncoding (Encoding' Text -> Value)
-> (TimeOfDay -> Encoding' Text) -> TimeOfDay -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeOfDay -> Encoding' Text
forall a. TimeOfDay -> Encoding' a
E.timeOfDay
toEncoding :: TimeOfDay -> Encoding
toEncoding = TimeOfDay -> Encoding
forall a. TimeOfDay -> Encoding' a
E.timeOfDay
instance ToJSONKey TimeOfDay where
toJSONKey :: ToJSONKeyFunction TimeOfDay
toJSONKey = (TimeOfDay -> Encoding' Text) -> ToJSONKeyFunction TimeOfDay
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc TimeOfDay -> Encoding' Text
forall a. TimeOfDay -> Encoding' a
E.timeOfDay
instance ToJSON LocalTime where
toJSON :: LocalTime -> Value
toJSON = Encoding' Text -> Value
stringEncoding (Encoding' Text -> Value)
-> (LocalTime -> Encoding' Text) -> LocalTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocalTime -> Encoding' Text
forall a. LocalTime -> Encoding' a
E.localTime
toEncoding :: LocalTime -> Encoding
toEncoding = LocalTime -> Encoding
forall a. LocalTime -> Encoding' a
E.localTime
instance ToJSONKey LocalTime where
toJSONKey :: ToJSONKeyFunction LocalTime
toJSONKey = (LocalTime -> Encoding' Text) -> ToJSONKeyFunction LocalTime
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc LocalTime -> Encoding' Text
forall a. LocalTime -> Encoding' a
E.localTime
instance ToJSON ZonedTime where
toJSON :: ZonedTime -> Value
toJSON = Encoding' Text -> Value
stringEncoding (Encoding' Text -> Value)
-> (ZonedTime -> Encoding' Text) -> ZonedTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ZonedTime -> Encoding' Text
forall a. ZonedTime -> Encoding' a
E.zonedTime
toEncoding :: ZonedTime -> Encoding
toEncoding = ZonedTime -> Encoding
forall a. ZonedTime -> Encoding' a
E.zonedTime
instance ToJSONKey ZonedTime where
toJSONKey :: ToJSONKeyFunction ZonedTime
toJSONKey = (ZonedTime -> Encoding' Text) -> ToJSONKeyFunction ZonedTime
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc ZonedTime -> Encoding' Text
forall a. ZonedTime -> Encoding' a
E.zonedTime
instance ToJSON UTCTime where
toJSON :: UTCTime -> Value
toJSON = Encoding' Text -> Value
stringEncoding (Encoding' Text -> Value)
-> (UTCTime -> Encoding' Text) -> UTCTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTCTime -> Encoding' Text
forall a. UTCTime -> Encoding' a
E.utcTime
toEncoding :: UTCTime -> Encoding
toEncoding = UTCTime -> Encoding
forall a. UTCTime -> Encoding' a
E.utcTime
instance ToJSONKey UTCTime where
toJSONKey :: ToJSONKeyFunction UTCTime
toJSONKey = (UTCTime -> Encoding' Text) -> ToJSONKeyFunction UTCTime
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc UTCTime -> Encoding' Text
forall a. UTCTime -> Encoding' a
E.utcTime
stringEncoding :: Encoding' Text -> Value
stringEncoding :: Encoding' Text -> Value
stringEncoding = Text -> Value
String
(Text -> Value)
-> (Encoding' Text -> Text) -> Encoding' Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
T.dropAround (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '"')
(Text -> Text)
-> (Encoding' Text -> Text) -> Encoding' Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
T.decodeLatin1
(ByteString -> Text)
-> (Encoding' Text -> ByteString) -> Encoding' Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
lazyToStrictByteString
(ByteString -> ByteString)
-> (Encoding' Text -> ByteString) -> Encoding' Text -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Encoding' Text -> ByteString
forall a. Encoding' a -> ByteString
E.encodingToLazyByteString
{-# INLINE stringEncoding #-}
instance ToJSON NominalDiffTime where
toJSON :: NominalDiffTime -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value)
-> (NominalDiffTime -> Scientific) -> NominalDiffTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NominalDiffTime -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toJSON #-}
toEncoding :: NominalDiffTime -> Encoding
toEncoding = Scientific -> Encoding
E.scientific (Scientific -> Encoding)
-> (NominalDiffTime -> Scientific) -> NominalDiffTime -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NominalDiffTime -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toEncoding #-}
instance ToJSON DiffTime where
toJSON :: DiffTime -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value)
-> (DiffTime -> Scientific) -> DiffTime -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toJSON #-}
toEncoding :: DiffTime -> Encoding
toEncoding = Scientific -> Encoding
E.scientific (Scientific -> Encoding)
-> (DiffTime -> Scientific) -> DiffTime -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> Scientific
forall a b. (Real a, Fractional b) => a -> b
realToFrac
{-# INLINE toEncoding #-}
instance ToJSON SystemTime where
toJSON :: SystemTime -> Value
toJSON (MkSystemTime secs :: Int64
secs nsecs :: Word32
nsecs) =
Nano -> Value
forall a. ToJSON a => a -> Value
toJSON (Int64 -> Nano
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
secs Nano -> Nano -> Nano
forall a. Num a => a -> a -> a
+ Word32 -> Nano
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
nsecs Nano -> Nano -> Nano
forall a. Fractional a => a -> a -> a
/ 1000000000 :: Nano)
toEncoding :: SystemTime -> Encoding
toEncoding (MkSystemTime secs :: Int64
secs nsecs :: Word32
nsecs) =
Nano -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Int64 -> Nano
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
secs Nano -> Nano -> Nano
forall a. Num a => a -> a -> a
+ Word32 -> Nano
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
nsecs Nano -> Nano -> Nano
forall a. Fractional a => a -> a -> a
/ 1000000000 :: Nano)
instance ToJSON CalendarDiffTime where
toJSON :: CalendarDiffTime -> Value
toJSON (CalendarDiffTime m :: Integer
m nt :: NominalDiffTime
nt) = [Pair] -> Value
object
[ "months" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
m
, "time" Text -> NominalDiffTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= NominalDiffTime
nt
]
toEncoding :: CalendarDiffTime -> Encoding
toEncoding (CalendarDiffTime m :: Integer
m nt :: NominalDiffTime
nt) = Series -> Encoding
E.pairs
("months" Text -> Integer -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
m Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> "time" Text -> NominalDiffTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= NominalDiffTime
nt)
instance ToJSON CalendarDiffDays where
toJSON :: CalendarDiffDays -> Value
toJSON (CalendarDiffDays m :: Integer
m d :: Integer
d) = [Pair] -> Value
object
[ "months" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
m
, "days" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
d
]
toEncoding :: CalendarDiffDays -> Encoding
toEncoding (CalendarDiffDays m :: Integer
m d :: Integer
d) = Series -> Encoding
E.pairs
("months" Text -> Integer -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
m Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> "days" Text -> Integer -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
d)
instance ToJSON DayOfWeek where
toJSON :: DayOfWeek -> Value
toJSON Monday = "monday"
toJSON Tuesday = "tuesday"
toJSON Wednesday = "wednesday"
toJSON Thursday = "thursday"
toJSON Friday = "friday"
toJSON Saturday = "saturday"
toJSON Sunday = "sunday"
toEncodingDayOfWeek :: DayOfWeek -> E.Encoding' Text
toEncodingDayOfWeek :: DayOfWeek -> Encoding' Text
toEncodingDayOfWeek Monday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"monday\""
toEncodingDayOfWeek Tuesday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"tuesday\""
toEncodingDayOfWeek Wednesday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"wednesday\""
toEncodingDayOfWeek Thursday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"thursday\""
toEncodingDayOfWeek Friday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"friday\""
toEncodingDayOfWeek Saturday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"saturday\""
toEncodingDayOfWeek Sunday = Builder -> Encoding' Text
forall a. Builder -> Encoding' a
E.unsafeToEncoding "\"sunday\""
instance ToJSONKey DayOfWeek where
toJSONKey :: ToJSONKeyFunction DayOfWeek
toJSONKey = (DayOfWeek -> Encoding' Text) -> ToJSONKeyFunction DayOfWeek
forall a. (a -> Encoding' Text) -> ToJSONKeyFunction a
toJSONKeyTextEnc DayOfWeek -> Encoding' Text
toEncodingDayOfWeek
instance ToJSON1 Monoid.Dual where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Dual a -> Value
liftToJSON t :: a -> Value
t _ = a -> Value
t (a -> Value) -> (Dual a -> a) -> Dual a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dual a -> a
forall a. Dual a -> a
Monoid.getDual
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Dual a -> Encoding
liftToEncoding t :: a -> Encoding
t _ = a -> Encoding
t (a -> Encoding) -> (Dual a -> a) -> Dual a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dual a -> a
forall a. Dual a -> a
Monoid.getDual
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Monoid.Dual a) where
toJSON :: Dual a -> Value
toJSON = Dual a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Dual a -> Encoding
toEncoding = Dual a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Monoid.First where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> First a -> Value
liftToJSON t :: a -> Value
t to' :: [a] -> Value
to' = (a -> Value) -> ([a] -> Value) -> Maybe a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
t [a] -> Value
to' (Maybe a -> Value) -> (First a -> Maybe a) -> First a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> Maybe a
forall a. First a -> Maybe a
Monoid.getFirst
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> First a -> Encoding
liftToEncoding t :: a -> Encoding
t to' :: [a] -> Encoding
to' = (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
t [a] -> Encoding
to' (Maybe a -> Encoding)
-> (First a -> Maybe a) -> First a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> Maybe a
forall a. First a -> Maybe a
Monoid.getFirst
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Monoid.First a) where
toJSON :: First a -> Value
toJSON = First a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: First a -> Encoding
toEncoding = First a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Monoid.Last where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Last a -> Value
liftToJSON t :: a -> Value
t to' :: [a] -> Value
to' = (a -> Value) -> ([a] -> Value) -> Maybe a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
t [a] -> Value
to' (Maybe a -> Value) -> (Last a -> Maybe a) -> Last a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last a -> Maybe a
forall a. Last a -> Maybe a
Monoid.getLast
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Last a -> Encoding
liftToEncoding t :: a -> Encoding
t to' :: [a] -> Encoding
to' = (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
t [a] -> Encoding
to' (Maybe a -> Encoding) -> (Last a -> Maybe a) -> Last a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last a -> Maybe a
forall a. Last a -> Maybe a
Monoid.getLast
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Monoid.Last a) where
toJSON :: Last a -> Value
toJSON = Last a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Last a -> Encoding
toEncoding = Last a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.Min where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Min a -> Value
liftToJSON t :: a -> Value
t _ (Semigroup.Min x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Min a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Semigroup.Min x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.Min a) where
toJSON :: Min a -> Value
toJSON = Min a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Min a -> Encoding
toEncoding = Min a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.Max where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Max a -> Value
liftToJSON t :: a -> Value
t _ (Semigroup.Max x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Max a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Semigroup.Max x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.Max a) where
toJSON :: Max a -> Value
toJSON = Max a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Max a -> Encoding
toEncoding = Max a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.First where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> First a -> Value
liftToJSON t :: a -> Value
t _ (Semigroup.First x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> First a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Semigroup.First x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.First a) where
toJSON :: First a -> Value
toJSON = First a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: First a -> Encoding
toEncoding = First a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.Last where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Last a -> Value
liftToJSON t :: a -> Value
t _ (Semigroup.Last x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Last a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Semigroup.Last x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.Last a) where
toJSON :: Last a -> Value
toJSON = Last a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Last a -> Encoding
toEncoding = Last a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.WrappedMonoid where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> WrappedMonoid a -> Value
liftToJSON t :: a -> Value
t _ (Semigroup.WrapMonoid x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> WrappedMonoid a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Semigroup.WrapMonoid x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.WrappedMonoid a) where
toJSON :: WrappedMonoid a -> Value
toJSON = WrappedMonoid a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: WrappedMonoid a -> Encoding
toEncoding = WrappedMonoid a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Semigroup.Option where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Option a -> Value
liftToJSON t :: a -> Value
t to' :: [a] -> Value
to' = (a -> Value) -> ([a] -> Value) -> Maybe a -> Value
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSON a -> Value
t [a] -> Value
to' (Maybe a -> Value) -> (Option a -> Maybe a) -> Option a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Option a -> Maybe a
forall a. Option a -> Maybe a
Semigroup.getOption
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Option a -> Encoding
liftToEncoding t :: a -> Encoding
t to' :: [a] -> Encoding
to' = (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding
forall (f :: * -> *) a.
ToJSON1 f =>
(a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncoding a -> Encoding
t [a] -> Encoding
to' (Maybe a -> Encoding)
-> (Option a -> Maybe a) -> Option a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Option a -> Maybe a
forall a. Option a -> Maybe a
Semigroup.getOption
{-# INLINE liftToEncoding #-}
instance ToJSON a => ToJSON (Semigroup.Option a) where
toJSON :: Option a -> Value
toJSON = Option a -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Option a -> Encoding
toEncoding = Option a -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSON1 Proxy where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value
liftToJSON _ _ _ = Value
Null
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding
liftToEncoding _ _ _ = Encoding
E.null_
{-# INLINE liftToEncoding #-}
instance ToJSON (Proxy a) where
toJSON :: Proxy a -> Value
toJSON _ = Value
Null
{-# INLINE toJSON #-}
toEncoding :: Proxy a -> Encoding
toEncoding _ = Encoding
E.null_
{-# INLINE toEncoding #-}
instance ToJSON2 Tagged where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> Tagged a b
-> Value
liftToJSON2 _ _ t :: b -> Value
t _ (Tagged x :: b
x) = b -> Value
t b
x
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> Tagged a b
-> Encoding
liftToEncoding2 _ _ t :: b -> Encoding
t _ (Tagged x :: b
x) = b -> Encoding
t b
x
{-# INLINE liftToEncoding2 #-}
instance ToJSON1 (Tagged a) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> Tagged a a -> Value
liftToJSON t :: a -> Value
t _ (Tagged x :: a
x) = a -> Value
t a
x
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Tagged a a -> Encoding
liftToEncoding t :: a -> Encoding
t _ (Tagged x :: a
x) = a -> Encoding
t a
x
{-# INLINE liftToEncoding #-}
instance ToJSON b => ToJSON (Tagged a b) where
toJSON :: Tagged a b -> Value
toJSON = Tagged a b -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
{-# INLINE toJSON #-}
toEncoding :: Tagged a b -> Encoding
toEncoding = Tagged a b -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
{-# INLINE toEncoding #-}
instance ToJSONKey b => ToJSONKey (Tagged a b) where
toJSONKey :: ToJSONKeyFunction (Tagged a b)
toJSONKey = (Tagged a b -> b)
-> ToJSONKeyFunction b -> ToJSONKeyFunction (Tagged a b)
forall a b. (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramapToJSONKeyFunction Tagged a b -> b
forall k (s :: k) b. Tagged s b -> b
unTagged ToJSONKeyFunction b
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey
toJSONKeyList :: ToJSONKeyFunction [Tagged a b]
toJSONKeyList = ([Tagged a b] -> [b])
-> ToJSONKeyFunction [b] -> ToJSONKeyFunction [Tagged a b]
forall a b. (a -> b) -> ToJSONKeyFunction b -> ToJSONKeyFunction a
contramapToJSONKeyFunction ((Tagged a b -> b) -> [Tagged a b] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tagged a b -> b
forall k (s :: k) b. Tagged s b -> b
unTagged) ToJSONKeyFunction [b]
forall a. ToJSONKey a => ToJSONKeyFunction [a]
toJSONKeyList
instance (ToJSON a, ToJSON b) => ToJSONKey (a,b)
instance (ToJSON a, ToJSON b, ToJSON c) => ToJSONKey (a,b,c)
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSONKey (a,b,c,d)
instance ToJSONKey Char where
toJSONKey :: ToJSONKeyFunction Char
toJSONKey = (Char -> Text)
-> (Char -> Encoding' Text) -> ToJSONKeyFunction Char
forall a.
(a -> Text) -> (a -> Encoding' Text) -> ToJSONKeyFunction a
ToJSONKeyText Char -> Text
T.singleton (String -> Encoding' Text
forall a. String -> Encoding' a
E.string (String -> Encoding' Text)
-> (Char -> String) -> Char -> Encoding' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> String -> String
forall a. a -> [a] -> [a]
:[]))
toJSONKeyList :: ToJSONKeyFunction String
toJSONKeyList = (String -> Text) -> ToJSONKeyFunction String
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText String -> Text
T.pack
instance (ToJSONKey a, ToJSON a) => ToJSONKey [a] where
toJSONKey :: ToJSONKeyFunction [a]
toJSONKey = ToJSONKeyFunction [a]
forall a. ToJSONKey a => ToJSONKeyFunction [a]
toJSONKeyList
instance ToJSON2 (,) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b)
-> Value
liftToJSON2 toA :: a -> Value
toA _ toB :: b -> Value
toB _ (a :: a
a, b :: b
b) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 2
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
toA a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
toB b
b)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b)
-> Encoding
liftToEncoding2 toA :: a -> Encoding
toA _ toB :: b -> Encoding
toB _ (a :: a
a, b :: b
b) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id [a -> Encoding
toA a
a, b -> Encoding
toB b
b]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a) => ToJSON1 ((,) a) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, a) -> Value
liftToJSON = (a -> Value)
-> ([a] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 a -> Value
forall a. ToJSON a => a -> Value
toJSON [a] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> (a, a) -> Encoding
liftToEncoding = (a -> Encoding)
-> ([a] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [a] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b) => ToJSON (a, b) where
toJSON :: (a, b) -> Value
toJSON = (a, b) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b) -> Encoding
toEncoding = (a, b) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a) => ToJSON2 ((,,) a) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, a, b)
-> Value
liftToJSON2 toB :: a -> Value
toB _ toC :: b -> Value
toC _ (a :: a
a, b :: a
b, c :: b
c) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 3
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (a -> Value
toB a
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (b -> Value
toC b
c)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, a, b)
-> Encoding
liftToEncoding2 toB :: a -> Encoding
toB _ toC :: b -> Encoding
toC _ (a :: a
a, b :: a
b, c :: b
c) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, a -> Encoding
toB a
b
, b -> Encoding
toC b
c
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b) => ToJSON1 ((,,) a b) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, a) -> Value
liftToJSON = (b -> Value)
-> ([b] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 b -> Value
forall a. ToJSON a => a -> Value
toJSON [b] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> (a, b, a) -> Encoding
liftToEncoding = (b -> Encoding)
-> ([b] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [b] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) where
toJSON :: (a, b, c) -> Value
toJSON = (a, b, c) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c) -> Encoding
toEncoding = (a, b, c) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b) => ToJSON2 ((,,,) a b) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, a, b)
-> Value
liftToJSON2 toC :: a -> Value
toC _ toD :: b -> Value
toD _ (a :: a
a, b :: b
b, c :: a
c, d :: b
d) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 4
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (a -> Value
toC a
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (b -> Value
toD b
d)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, a, b)
-> Encoding
liftToEncoding2 toC :: a -> Encoding
toC _ toD :: b -> Encoding
toD _ (a :: a
a, b :: b
b, c :: a
c, d :: b
d) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, a -> Encoding
toC a
c
, b -> Encoding
toD b
d
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c) => ToJSON1 ((,,,) a b c) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, c, a) -> Value
liftToJSON = (c -> Value)
-> ([c] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 c -> Value
forall a. ToJSON a => a -> Value
toJSON [c] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> (a, b, c, a) -> Encoding
liftToEncoding = (c -> Encoding)
-> ([c] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [c] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) where
toJSON :: (a, b, c, d) -> Value
toJSON = (a, b, c, d) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d) -> Encoding
toEncoding = (a, b, c, d) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c) => ToJSON2 ((,,,,) a b c) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, a, b)
-> Value
liftToJSON2 toD :: a -> Value
toD _ toE :: b -> Value
toE _ (a :: a
a, b :: b
b, c :: c
c, d :: a
d, e :: b
e) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 5
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (a -> Value
toD a
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (b -> Value
toE b
e)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, a, b)
-> Encoding
liftToEncoding2 toD :: a -> Encoding
toD _ toE :: b -> Encoding
toE _ (a :: a
a, b :: b
b, c :: c
c, d :: a
d, e :: b
e) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, a -> Encoding
toD a
d
, b -> Encoding
toE b
e
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON1 ((,,,,) a b c d) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, c, d, a) -> Value
liftToJSON = (d -> Value)
-> ([d] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 d -> Value
forall a. ToJSON a => a -> Value
toJSON [d] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> (a, b, c, d, a) -> Encoding
liftToEncoding = (d -> Encoding)
-> ([d] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [d] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e) where
toJSON :: (a, b, c, d, e) -> Value
toJSON = (a, b, c, d, e) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e) -> Encoding
toEncoding = (a, b, c, d, e) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON2 ((,,,,,) a b c d) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, a, b)
-> Value
liftToJSON2 toE :: a -> Value
toE _ toF :: b -> Value
toF _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: a
e, f :: b
f) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 6
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (a -> Value
toE a
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (b -> Value
toF b
f)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, a, b)
-> Encoding
liftToEncoding2 toE :: a -> Encoding
toE _ toF :: b -> Encoding
toF _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: a
e, f :: b
f) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, a -> Encoding
toE a
e
, b -> Encoding
toF b
f
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON1 ((,,,,,) a b c d e) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, c, d, e, a) -> Value
liftToJSON = (e -> Value)
-> ([e] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 e -> Value
forall a. ToJSON a => a -> Value
toJSON [e] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> (a, b, c, d, e, a) -> Encoding
liftToEncoding = (e -> Encoding)
-> ([e] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [e] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f) where
toJSON :: (a, b, c, d, e, f) -> Value
toJSON = (a, b, c, d, e, f) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f) -> Encoding
toEncoding = (a, b, c, d, e, f) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON2 ((,,,,,,) a b c d e) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, a, b)
-> Value
liftToJSON2 toF :: a -> Value
toF _ toG :: b -> Value
toG _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: a
f, g :: b
g) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 7
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (a -> Value
toF a
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (b -> Value
toG b
g)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, a, b)
-> Encoding
liftToEncoding2 toF :: a -> Encoding
toF _ toG :: b -> Encoding
toG _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: a
f, g :: b
g) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, a -> Encoding
toF a
f
, b -> Encoding
toG b
g
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON1 ((,,,,,,) a b c d e f) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, c, d, e, f, a) -> Value
liftToJSON = (f -> Value)
-> ([f] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 f -> Value
forall a. ToJSON a => a -> Value
toJSON [f] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> (a, b, c, d, e, f, a) -> Encoding
liftToEncoding = (f -> Encoding)
-> ([f] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [f] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g) where
toJSON :: (a, b, c, d, e, f, g) -> Value
toJSON = (a, b, c, d, e, f, g) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g) -> Encoding
toEncoding = (a, b, c, d, e, f, g) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON2 ((,,,,,,,) a b c d e f) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, a, b)
-> Value
liftToJSON2 toG :: a -> Value
toG _ toH :: b -> Value
toH _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: a
g, h :: b
h) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 8
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (a -> Value
toG a
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (b -> Value
toH b
h)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, a, b)
-> Encoding
liftToEncoding2 toG :: a -> Encoding
toG _ toH :: b -> Encoding
toH _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: a
g, h :: b
h) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, a -> Encoding
toG a
g
, b -> Encoding
toH b
h
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON1 ((,,,,,,,) a b c d e f g) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> (a, b, c, d, e, f, g, a) -> Value
liftToJSON = (g -> Value)
-> ([g] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 g -> Value
forall a. ToJSON a => a -> Value
toJSON [g] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> (a, b, c, d, e, f, g, a) -> Encoding
liftToEncoding = (g -> Encoding)
-> ([g] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [g] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h) -> Value
toJSON = (a, b, c, d, e, f, g, h) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON2 ((,,,,,,,,) a b c d e f g) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, a, b)
-> Value
liftToJSON2 toH :: a -> Value
toH _ toI :: b -> Value
toI _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: a
h, i :: b
i) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 9
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (a -> Value
toH a
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (b -> Value
toI b
i)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, a, b)
-> Encoding
liftToEncoding2 toH :: a -> Encoding
toH _ toI :: b -> Encoding
toI _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: a
h, i :: b
i) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, a -> Encoding
toH a
h
, b -> Encoding
toI b
i
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON1 ((,,,,,,,,) a b c d e f g h) where
liftToJSON :: (a -> Value)
-> ([a] -> Value) -> (a, b, c, d, e, f, g, h, a) -> Value
liftToJSON = (h -> Value)
-> ([h] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 h -> Value
forall a. ToJSON a => a -> Value
toJSON [h] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> (a, b, c, d, e, f, g, h, a) -> Encoding
liftToEncoding = (h -> Encoding)
-> ([h] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [h] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i) -> Value
toJSON = (a, b, c, d, e, f, g, h, i) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON2 ((,,,,,,,,,) a b c d e f g h) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, a, b)
-> Value
liftToJSON2 toI :: a -> Value
toI _ toJ :: b -> Value
toJ _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: a
i, j :: b
j) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 10
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (a -> Value
toI a
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (b -> Value
toJ b
j)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, a, b)
-> Encoding
liftToEncoding2 toI :: a -> Encoding
toI _ toJ :: b -> Encoding
toJ _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: a
i, j :: b
j) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, a -> Encoding
toI a
i
, b -> Encoding
toJ b
j
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON1 ((,,,,,,,,,) a b c d e f g h i) where
liftToJSON :: (a -> Value)
-> ([a] -> Value) -> (a, b, c, d, e, f, g, h, i, a) -> Value
liftToJSON = (i -> Value)
-> ([i] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 i -> Value
forall a. ToJSON a => a -> Value
toJSON [i] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> (a, b, c, d, e, f, g, h, i, a) -> Encoding
liftToEncoding = (i -> Encoding)
-> ([i] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [i] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON2 ((,,,,,,,,,,) a b c d e f g h i) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, i, a, b)
-> Value
liftToJSON2 toJ :: a -> Value
toJ _ toK :: b -> Value
toK _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: a
j, k :: b
k) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 11
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (i -> Value
forall a. ToJSON a => a -> Value
toJSON i
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (a -> Value
toJ a
j)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 10 (b -> Value
toK b
k)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, a, b)
-> Encoding
liftToEncoding2 toJ :: a -> Encoding
toJ _ toK :: b -> Encoding
toK _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: a
j, k :: b
k) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding i
i
, a -> Encoding
toJ a
j
, b -> Encoding
toK b
k
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON1 ((,,,,,,,,,,) a b c d e f g h i j) where
liftToJSON :: (a -> Value)
-> ([a] -> Value) -> (a, b, c, d, e, f, g, h, i, j, a) -> Value
liftToJSON = (j -> Value)
-> ([j] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 j -> Value
forall a. ToJSON a => a -> Value
toJSON [j] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, a)
-> Encoding
liftToEncoding = (j -> Encoding)
-> ([j] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 j -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [j] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j, k) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j, k) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON2 ((,,,,,,,,,,,) a b c d e f g h i j) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, a, b)
-> Value
liftToJSON2 toK :: a -> Value
toK _ toL :: b -> Value
toL _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: a
k, l :: b
l) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 12
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (i -> Value
forall a. ToJSON a => a -> Value
toJSON i
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (j -> Value
forall a. ToJSON a => a -> Value
toJSON j
j)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 10 (a -> Value
toK a
k)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 11 (b -> Value
toL b
l)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, a, b)
-> Encoding
liftToEncoding2 toK :: a -> Encoding
toK _ toL :: b -> Encoding
toL _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: a
k, l :: b
l) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding i
i
, j -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding j
j
, a -> Encoding
toK a
k
, b -> Encoding
toL b
l
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON1 ((,,,,,,,,,,,) a b c d e f g h i j k) where
liftToJSON :: (a -> Value)
-> ([a] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, a) -> Value
liftToJSON = (k -> Value)
-> ([k] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 k -> Value
forall a. ToJSON a => a -> Value
toJSON [k] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, a)
-> Encoding
liftToEncoding = (k -> Encoding)
-> ([k] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 k -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [k] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j, k, l) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON2 ((,,,,,,,,,,,,) a b c d e f g h i j k) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, a, b)
-> Value
liftToJSON2 toL :: a -> Value
toL _ toM :: b -> Value
toM _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: a
l, m :: b
m) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 13
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (i -> Value
forall a. ToJSON a => a -> Value
toJSON i
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (j -> Value
forall a. ToJSON a => a -> Value
toJSON j
j)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 10 (k -> Value
forall a. ToJSON a => a -> Value
toJSON k
k)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 11 (a -> Value
toL a
l)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 12 (b -> Value
toM b
m)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, a, b)
-> Encoding
liftToEncoding2 toL :: a -> Encoding
toL _ toM :: b -> Encoding
toM _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: a
l, m :: b
m) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding i
i
, j -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding j
j
, k -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding k
k
, a -> Encoding
toL a
l
, b -> Encoding
toM b
m
]
{-# INLINE liftToEncoding2 #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON1 ((,,,,,,,,,,,,) a b c d e f g h i j k l) where
liftToJSON :: (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a)
-> Value
liftToJSON = (l -> Value)
-> ([l] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 l -> Value
forall a. ToJSON a => a -> Value
toJSON [l] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a)
-> Encoding
liftToEncoding = (l -> Encoding)
-> ([l] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 l -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [l] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON2 ((,,,,,,,,,,,,,) a b c d e f g h i j k l) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a, b)
-> Value
liftToJSON2 toM :: a -> Value
toM _ toN :: b -> Value
toN _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: l
l, m :: a
m, n :: b
n) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 14
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (i -> Value
forall a. ToJSON a => a -> Value
toJSON i
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (j -> Value
forall a. ToJSON a => a -> Value
toJSON j
j)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 10 (k -> Value
forall a. ToJSON a => a -> Value
toJSON k
k)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 11 (l -> Value
forall a. ToJSON a => a -> Value
toJSON l
l)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 12 (a -> Value
toM a
m)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 13 (b -> Value
toN b
n)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, a, b)
-> Encoding
liftToEncoding2 toM :: a -> Encoding
toM _ toN :: b -> Encoding
toN _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: l
l, m :: a
m, n :: b
n) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding i
i
, j -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding j
j
, k -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding k
k
, l -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding l
l
, a -> Encoding
toM a
m
, b -> Encoding
toN b
n
]
{-# INLINE liftToEncoding2 #-}
instance (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) => ToJSON1 ((,,,,,,,,,,,,,) a b c d e f g h i j k l m) where
liftToJSON :: (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a)
-> Value
liftToJSON = (m -> Value)
-> ([m] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 m -> Value
forall a. ToJSON a => a -> Value
toJSON [m] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a)
-> Encoding
liftToEncoding = (m -> Encoding)
-> ([m] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 m -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [m] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
instance (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) => ToJSON2 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m) where
liftToJSON2 :: (a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a, b)
-> Value
liftToJSON2 toN :: a -> Value
toN _ toO :: b -> Value
toO _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: l
l, m :: m
m, n :: a
n, o :: b
o) = Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (MVector s Value)) -> Array
forall a. (forall s. ST s (MVector s a)) -> Vector a
V.create ((forall s. ST s (MVector s Value)) -> Array)
-> (forall s. ST s (MVector s Value)) -> Array
forall a b. (a -> b) -> a -> b
$ do
MVector s Value
mv <- Int -> ST s (MVector (PrimState (ST s)) Value)
forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (MVector (PrimState m) a)
VM.unsafeNew 15
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 0 (a -> Value
forall a. ToJSON a => a -> Value
toJSON a
a)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 1 (b -> Value
forall a. ToJSON a => a -> Value
toJSON b
b)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 2 (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
c)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 3 (d -> Value
forall a. ToJSON a => a -> Value
toJSON d
d)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 4 (e -> Value
forall a. ToJSON a => a -> Value
toJSON e
e)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 5 (f -> Value
forall a. ToJSON a => a -> Value
toJSON f
f)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 6 (g -> Value
forall a. ToJSON a => a -> Value
toJSON g
g)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 7 (h -> Value
forall a. ToJSON a => a -> Value
toJSON h
h)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 8 (i -> Value
forall a. ToJSON a => a -> Value
toJSON i
i)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 9 (j -> Value
forall a. ToJSON a => a -> Value
toJSON j
j)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 10 (k -> Value
forall a. ToJSON a => a -> Value
toJSON k
k)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 11 (l -> Value
forall a. ToJSON a => a -> Value
toJSON l
l)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 12 (m -> Value
forall a. ToJSON a => a -> Value
toJSON m
m)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 13 (a -> Value
toN a
n)
MVector (PrimState (ST s)) Value -> Int -> Value -> ST s ()
forall (m :: * -> *) a.
PrimMonad m =>
MVector (PrimState m) a -> Int -> a -> m ()
VM.unsafeWrite MVector s Value
MVector (PrimState (ST s)) Value
mv 14 (b -> Value
toO b
o)
MVector s Value -> ST s (MVector s Value)
forall (m :: * -> *) a. Monad m => a -> m a
return MVector s Value
mv
{-# INLINE liftToJSON2 #-}
liftToEncoding2 :: (a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, a, b)
-> Encoding
liftToEncoding2 toN :: a -> Encoding
toN _ toO :: b -> Encoding
toO _ (a :: a
a, b :: b
b, c :: c
c, d :: d
d, e :: e
e, f :: f
f, g :: g
g, h :: h
h, i :: i
i, j :: j
j, k :: k
k, l :: l
l, m :: m
m, n :: a
n, o :: b
o) = (Encoding -> Encoding) -> [Encoding] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list Encoding -> Encoding
forall a. a -> a
id
[ a -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding a
a
, b -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding b
b
, c -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding c
c
, d -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding d
d
, e -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding e
e
, f -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding f
f
, g -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding g
g
, h -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding h
h
, i -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding i
i
, j -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding j
j
, k -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding k
k
, l -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding l
l
, m -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding m
m
, a -> Encoding
toN a
n
, b -> Encoding
toO b
o
]
{-# INLINE liftToEncoding2 #-}
instance (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) => ToJSON1 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n) where
liftToJSON :: (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a)
-> Value
liftToJSON = (n -> Value)
-> ([n] -> Value)
-> (a -> Value)
-> ([a] -> Value)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a)
-> Value
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Value)
-> ([a] -> Value)
-> (b -> Value)
-> ([b] -> Value)
-> f a b
-> Value
liftToJSON2 n -> Value
forall a. ToJSON a => a -> Value
toJSON [n] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList
{-# INLINE liftToJSON #-}
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a)
-> Encoding
liftToEncoding = (n -> Encoding)
-> ([n] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 n -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding [n] -> Encoding
forall a. ToJSON a => [a] -> Encoding
toEncodingList
{-# INLINE liftToEncoding #-}
instance (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) where
toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value
toJSON = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Value
toJSON2
{-# INLINE toJSON #-}
toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding
toEncoding = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding
forall (f :: * -> * -> *) a b.
(ToJSON2 f, ToJSON a, ToJSON b) =>
f a b -> Encoding
toEncoding2
{-# INLINE toEncoding #-}
{-# INLINE lazyToStrictByteString #-}
lazyToStrictByteString :: L.ByteString -> S.ByteString
#if MIN_VERSION_bytestring(0,10,0)
lazyToStrictByteString :: ByteString -> ByteString
lazyToStrictByteString = ByteString -> ByteString
L.toStrict
#else
lazyToStrictByteString = packChunks
packChunks :: L.ByteString -> S.ByteString
packChunks lbs =
S.unsafeCreate (fromIntegral $ L.length lbs) (copyChunks lbs)
where
copyChunks L.Empty _pf = return ()
copyChunks (L.Chunk (S.PS fpbuf o l) lbs') pf = do
withForeignPtr fpbuf $ \pbuf ->
copyBytes pf (pbuf `plusPtr` o) l
copyChunks lbs' (pf `plusPtr` l)
#endif
class Monoid pairs => FromPairs enc pairs | enc -> pairs where
fromPairs :: pairs -> enc
instance (a ~ Value) => FromPairs (Encoding' a) Series where
fromPairs :: Series -> Encoding' a
fromPairs = Series -> Encoding' a
Series -> Encoding
E.pairs
instance FromPairs Value (DList Pair) where
fromPairs :: DList Pair -> Value
fromPairs = [Pair] -> Value
object ([Pair] -> Value) -> (DList Pair -> [Pair]) -> DList Pair -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DList Pair -> [Pair]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
class Monoid kv => KeyValuePair v kv where
pair :: String -> v -> kv
instance (v ~ Value) => KeyValuePair v (DList Pair) where
pair :: String -> v -> DList Pair
pair k :: String
k v :: v
v = Pair -> DList Pair
forall a. a -> DList a
DList.singleton (String -> Text
pack String
k Text -> v -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= v
v)
instance (e ~ Encoding) => KeyValuePair e Series where
pair :: String -> e -> Series
pair = String -> e -> Series
String -> Encoding -> Series
E.pairStr