Skip to content

Instantly share code, notes, and snippets.

@kana-sama

kana-sama/Q.hs

Last active Sep 2, 2020
Embed
What would you like to do?
th [poly/nonpoly]
16.5s / 20s
generic [poly/nonpoly]
20.6s / 28.2s
eot nonpoly
38s (-2s for own decoder module)
sop nonpoly
13.8s
{-# LANGUAGE DeriveGeneric, StandaloneDeriving, TemplateHaskell #-}
module Main where
import Data.Aeson
import GHC.Generics (Generic)
import qualified Q
data A = A { a0 :: Int, a1 :: Int, a2 :: Int, a3 :: Int, a4 :: Int, a5 :: Int, a6 :: Int, a7 :: Int, a8 :: Int, a9 :: Int, a10 :: Int, a11 :: Int, a12 :: Int, a13 :: Int, a14 :: Int, a15 :: Int, a16 :: Int, a17 :: Int, a18 :: Int, a19 :: Int, a20 :: Int, a21 :: Int, a22 :: Int, a23 :: Int, a24 :: Int, a25 :: Int, a26 :: Int, a27 :: Int, a28 :: Int, a29 :: Int, a30 :: Int, a31 :: Int, a32 :: Int, a33 :: Int, a34 :: Int, a35 :: Int, a36 :: Int, a37 :: Int, a38 :: Int, a39 :: Int, a40 :: Int, a41 :: Int, a42 :: Int, a43 :: Int, a44 :: Int, a45 :: Int, a46 :: Int, a47 :: Int, a48 :: Int, a49 :: Int, a50 :: Int }
data B = B { b0 :: Int, b1 :: Int, b2 :: Int, b3 :: Int, b4 :: Int, b5 :: Int, b6 :: Int, b7 :: Int, b8 :: Int, b9 :: Int, b10 :: Int, b11 :: Int, b12 :: Int, b13 :: Int, b14 :: Int, b15 :: Int, b16 :: Int, b17 :: Int, b18 :: Int, b19 :: Int, b20 :: Int, b21 :: Int, b22 :: Int, b23 :: Int, b24 :: Int, b25 :: Int, b26 :: Int, b27 :: Int, b28 :: Int, b29 :: Int, b30 :: Int, b31 :: Int, b32 :: Int, b33 :: Int, b34 :: Int, b35 :: Int, b36 :: Int, b37 :: Int, b38 :: Int, b39 :: Int, b40 :: Int, b41 :: Int, b42 :: Int, b43 :: Int, b44 :: Int, b45 :: Int, b46 :: Int, b47 :: Int, b48 :: Int, b49 :: Int, b50 :: Int }
data C = C { c0 :: Int, c1 :: Int, c2 :: Int, c3 :: Int, c4 :: Int, c5 :: Int, c6 :: Int, c7 :: Int, c8 :: Int, c9 :: Int, c10 :: Int, c11 :: Int, c12 :: Int, c13 :: Int, c14 :: Int, c15 :: Int, c16 :: Int, c17 :: Int, c18 :: Int, c19 :: Int, c20 :: Int, c21 :: Int, c22 :: Int, c23 :: Int, c24 :: Int, c25 :: Int, c26 :: Int, c27 :: Int, c28 :: Int, c29 :: Int, c30 :: Int, c31 :: Int, c32 :: Int, c33 :: Int, c34 :: Int, c35 :: Int, c36 :: Int, c37 :: Int, c38 :: Int, c39 :: Int, c40 :: Int, c41 :: Int, c42 :: Int, c43 :: Int, c44 :: Int, c45 :: Int, c46 :: Int, c47 :: Int, c48 :: Int, c49 :: Int, c50 :: Int }
data D = D { d0 :: Int, d1 :: Int, d2 :: Int, d3 :: Int, d4 :: Int, d5 :: Int, d6 :: Int, d7 :: Int, d8 :: Int, d9 :: Int, d10 :: Int, d11 :: Int, d12 :: Int, d13 :: Int, d14 :: Int, d15 :: Int, d16 :: Int, d17 :: Int, d18 :: Int, d19 :: Int, d20 :: Int, d21 :: Int, d22 :: Int, d23 :: Int, d24 :: Int, d25 :: Int, d26 :: Int, d27 :: Int, d28 :: Int, d29 :: Int, d30 :: Int, d31 :: Int, d32 :: Int, d33 :: Int, d34 :: Int, d35 :: Int, d36 :: Int, d37 :: Int, d38 :: Int, d39 :: Int, d40 :: Int, d41 :: Int, d42 :: Int, d43 :: Int, d44 :: Int, d45 :: Int, d46 :: Int, d47 :: Int, d48 :: Int, d49 :: Int, d50 :: Int }
data E = E { e0 :: Int, e1 :: Int, e2 :: Int, e3 :: Int, e4 :: Int, e5 :: Int, e6 :: Int, e7 :: Int, e8 :: Int, e9 :: Int, e10 :: Int, e11 :: Int, e12 :: Int, e13 :: Int, e14 :: Int, e15 :: Int, e16 :: Int, e17 :: Int, e18 :: Int, e19 :: Int, e20 :: Int, e21 :: Int, e22 :: Int, e23 :: Int, e24 :: Int, e25 :: Int, e26 :: Int, e27 :: Int, e28 :: Int, e29 :: Int, e30 :: Int, e31 :: Int, e32 :: Int, e33 :: Int, e34 :: Int, e35 :: Int, e36 :: Int, e37 :: Int, e38 :: Int, e39 :: Int, e40 :: Int, e41 :: Int, e42 :: Int, e43 :: Int, e44 :: Int, e45 :: Int, e46 :: Int, e47 :: Int, e48 :: Int, e49 :: Int, e50 :: Int }
deriving instance Generic A
deriving instance Generic B
deriving instance Generic C
deriving instance Generic D
deriving instance Generic E
instance FromJSON A where parseJSON = Q.genericDecode Q.defaultOptions
instance FromJSON B where parseJSON = Q.genericDecode Q.defaultOptions
instance FromJSON C where parseJSON = Q.genericDecode Q.defaultOptions
instance FromJSON D where parseJSON = Q.genericDecode Q.defaultOptions
instance FromJSON E where parseJSON = Q.genericDecode Q.defaultOptions
instance ToJSON A where toJSON = Q.genericEncode Q.defaultOptions
instance ToJSON B where toJSON = Q.genericEncode Q.defaultOptions
instance ToJSON C where toJSON = Q.genericEncode Q.defaultOptions
instance ToJSON D where toJSON = Q.genericEncode Q.defaultOptions
instance ToJSON E where toJSON = Q.genericEncode Q.defaultOptions
main = pure ()
{-# LANGUAGE DeriveGeneric, StandaloneDeriving #-}
module Main where
import GHC.Generics (Generic)
import Data.Aeson
data A = A { a0 :: Int, a1 :: Int, a2 :: Int, a3 :: Int, a4 :: Int, a5 :: Int, a6 :: Int, a7 :: Int, a8 :: Int, a9 :: Int, a10 :: Int, a11 :: Int, a12 :: Int, a13 :: Int, a14 :: Int, a15 :: Int, a16 :: Int, a17 :: Int, a18 :: Int, a19 :: Int, a20 :: Int, a21 :: Int, a22 :: Int, a23 :: Int, a24 :: Int, a25 :: Int, a26 :: Int, a27 :: Int, a28 :: Int, a29 :: Int, a30 :: Int, a31 :: Int, a32 :: Int, a33 :: Int, a34 :: Int, a35 :: Int, a36 :: Int, a37 :: Int, a38 :: Int, a39 :: Int, a40 :: Int, a41 :: Int, a42 :: Int, a43 :: Int, a44 :: Int, a45 :: Int, a46 :: Int, a47 :: Int, a48 :: Int, a49 :: Int, a50 :: Int }
data B = B { b0 :: Int, b1 :: Int, b2 :: Int, b3 :: Int, b4 :: Int, b5 :: Int, b6 :: Int, b7 :: Int, b8 :: Int, b9 :: Int, b10 :: Int, b11 :: Int, b12 :: Int, b13 :: Int, b14 :: Int, b15 :: Int, b16 :: Int, b17 :: Int, b18 :: Int, b19 :: Int, b20 :: Int, b21 :: Int, b22 :: Int, b23 :: Int, b24 :: Int, b25 :: Int, b26 :: Int, b27 :: Int, b28 :: Int, b29 :: Int, b30 :: Int, b31 :: Int, b32 :: Int, b33 :: Int, b34 :: Int, b35 :: Int, b36 :: Int, b37 :: Int, b38 :: Int, b39 :: Int, b40 :: Int, b41 :: Int, b42 :: Int, b43 :: Int, b44 :: Int, b45 :: Int, b46 :: Int, b47 :: Int, b48 :: Int, b49 :: Int, b50 :: Int }
data C = C { c0 :: Int, c1 :: Int, c2 :: Int, c3 :: Int, c4 :: Int, c5 :: Int, c6 :: Int, c7 :: Int, c8 :: Int, c9 :: Int, c10 :: Int, c11 :: Int, c12 :: Int, c13 :: Int, c14 :: Int, c15 :: Int, c16 :: Int, c17 :: Int, c18 :: Int, c19 :: Int, c20 :: Int, c21 :: Int, c22 :: Int, c23 :: Int, c24 :: Int, c25 :: Int, c26 :: Int, c27 :: Int, c28 :: Int, c29 :: Int, c30 :: Int, c31 :: Int, c32 :: Int, c33 :: Int, c34 :: Int, c35 :: Int, c36 :: Int, c37 :: Int, c38 :: Int, c39 :: Int, c40 :: Int, c41 :: Int, c42 :: Int, c43 :: Int, c44 :: Int, c45 :: Int, c46 :: Int, c47 :: Int, c48 :: Int, c49 :: Int, c50 :: Int }
data D = D { d0 :: Int, d1 :: Int, d2 :: Int, d3 :: Int, d4 :: Int, d5 :: Int, d6 :: Int, d7 :: Int, d8 :: Int, d9 :: Int, d10 :: Int, d11 :: Int, d12 :: Int, d13 :: Int, d14 :: Int, d15 :: Int, d16 :: Int, d17 :: Int, d18 :: Int, d19 :: Int, d20 :: Int, d21 :: Int, d22 :: Int, d23 :: Int, d24 :: Int, d25 :: Int, d26 :: Int, d27 :: Int, d28 :: Int, d29 :: Int, d30 :: Int, d31 :: Int, d32 :: Int, d33 :: Int, d34 :: Int, d35 :: Int, d36 :: Int, d37 :: Int, d38 :: Int, d39 :: Int, d40 :: Int, d41 :: Int, d42 :: Int, d43 :: Int, d44 :: Int, d45 :: Int, d46 :: Int, d47 :: Int, d48 :: Int, d49 :: Int, d50 :: Int }
data E = E { e0 :: Int, e1 :: Int, e2 :: Int, e3 :: Int, e4 :: Int, e5 :: Int, e6 :: Int, e7 :: Int, e8 :: Int, e9 :: Int, e10 :: Int, e11 :: Int, e12 :: Int, e13 :: Int, e14 :: Int, e15 :: Int, e16 :: Int, e17 :: Int, e18 :: Int, e19 :: Int, e20 :: Int, e21 :: Int, e22 :: Int, e23 :: Int, e24 :: Int, e25 :: Int, e26 :: Int, e27 :: Int, e28 :: Int, e29 :: Int, e30 :: Int, e31 :: Int, e32 :: Int, e33 :: Int, e34 :: Int, e35 :: Int, e36 :: Int, e37 :: Int, e38 :: Int, e39 :: Int, e40 :: Int, e41 :: Int, e42 :: Int, e43 :: Int, e44 :: Int, e45 :: Int, e46 :: Int, e47 :: Int, e48 :: Int, e49 :: Int, e50 :: Int }
deriving instance Generic A
deriving instance Generic B
deriving instance Generic C
deriving instance Generic D
deriving instance Generic E
instance FromJSON A
instance FromJSON B
instance FromJSON C
instance FromJSON D
instance FromJSON E
instance ToJSON A
instance ToJSON B
instance ToJSON C
instance ToJSON D
instance ToJSON E
main = pure ()
{-# LANGUAGE TemplateHaskell, DataKinds, TypeFamilies #-}
module Main where
import Data.Aeson (FromJSON(..), ToJSON(..))
import Generics.SOP.TH (deriveGeneric)
import Generics.SOP.JSON (gtoJSON, gparseJSON, defaultJsonOptions)
data A = A { a0 :: Int, a1 :: Int, a2 :: Int, a3 :: Int, a4 :: Int, a5 :: Int, a6 :: Int, a7 :: Int, a8 :: Int, a9 :: Int, a10 :: Int, a11 :: Int, a12 :: Int, a13 :: Int, a14 :: Int, a15 :: Int, a16 :: Int, a17 :: Int, a18 :: Int, a19 :: Int, a20 :: Int, a21 :: Int, a22 :: Int, a23 :: Int, a24 :: Int, a25 :: Int, a26 :: Int, a27 :: Int, a28 :: Int, a29 :: Int, a30 :: Int, a31 :: Int, a32 :: Int, a33 :: Int, a34 :: Int, a35 :: Int, a36 :: Int, a37 :: Int, a38 :: Int, a39 :: Int, a40 :: Int, a41 :: Int, a42 :: Int, a43 :: Int, a44 :: Int, a45 :: Int, a46 :: Int, a47 :: Int, a48 :: Int, a49 :: Int, a50 :: Int }
data B = B { b0 :: Int, b1 :: Int, b2 :: Int, b3 :: Int, b4 :: Int, b5 :: Int, b6 :: Int, b7 :: Int, b8 :: Int, b9 :: Int, b10 :: Int, b11 :: Int, b12 :: Int, b13 :: Int, b14 :: Int, b15 :: Int, b16 :: Int, b17 :: Int, b18 :: Int, b19 :: Int, b20 :: Int, b21 :: Int, b22 :: Int, b23 :: Int, b24 :: Int, b25 :: Int, b26 :: Int, b27 :: Int, b28 :: Int, b29 :: Int, b30 :: Int, b31 :: Int, b32 :: Int, b33 :: Int, b34 :: Int, b35 :: Int, b36 :: Int, b37 :: Int, b38 :: Int, b39 :: Int, b40 :: Int, b41 :: Int, b42 :: Int, b43 :: Int, b44 :: Int, b45 :: Int, b46 :: Int, b47 :: Int, b48 :: Int, b49 :: Int, b50 :: Int }
data C = C { c0 :: Int, c1 :: Int, c2 :: Int, c3 :: Int, c4 :: Int, c5 :: Int, c6 :: Int, c7 :: Int, c8 :: Int, c9 :: Int, c10 :: Int, c11 :: Int, c12 :: Int, c13 :: Int, c14 :: Int, c15 :: Int, c16 :: Int, c17 :: Int, c18 :: Int, c19 :: Int, c20 :: Int, c21 :: Int, c22 :: Int, c23 :: Int, c24 :: Int, c25 :: Int, c26 :: Int, c27 :: Int, c28 :: Int, c29 :: Int, c30 :: Int, c31 :: Int, c32 :: Int, c33 :: Int, c34 :: Int, c35 :: Int, c36 :: Int, c37 :: Int, c38 :: Int, c39 :: Int, c40 :: Int, c41 :: Int, c42 :: Int, c43 :: Int, c44 :: Int, c45 :: Int, c46 :: Int, c47 :: Int, c48 :: Int, c49 :: Int, c50 :: Int }
data D = D { d0 :: Int, d1 :: Int, d2 :: Int, d3 :: Int, d4 :: Int, d5 :: Int, d6 :: Int, d7 :: Int, d8 :: Int, d9 :: Int, d10 :: Int, d11 :: Int, d12 :: Int, d13 :: Int, d14 :: Int, d15 :: Int, d16 :: Int, d17 :: Int, d18 :: Int, d19 :: Int, d20 :: Int, d21 :: Int, d22 :: Int, d23 :: Int, d24 :: Int, d25 :: Int, d26 :: Int, d27 :: Int, d28 :: Int, d29 :: Int, d30 :: Int, d31 :: Int, d32 :: Int, d33 :: Int, d34 :: Int, d35 :: Int, d36 :: Int, d37 :: Int, d38 :: Int, d39 :: Int, d40 :: Int, d41 :: Int, d42 :: Int, d43 :: Int, d44 :: Int, d45 :: Int, d46 :: Int, d47 :: Int, d48 :: Int, d49 :: Int, d50 :: Int }
data E = E { e0 :: Int, e1 :: Int, e2 :: Int, e3 :: Int, e4 :: Int, e5 :: Int, e6 :: Int, e7 :: Int, e8 :: Int, e9 :: Int, e10 :: Int, e11 :: Int, e12 :: Int, e13 :: Int, e14 :: Int, e15 :: Int, e16 :: Int, e17 :: Int, e18 :: Int, e19 :: Int, e20 :: Int, e21 :: Int, e22 :: Int, e23 :: Int, e24 :: Int, e25 :: Int, e26 :: Int, e27 :: Int, e28 :: Int, e29 :: Int, e30 :: Int, e31 :: Int, e32 :: Int, e33 :: Int, e34 :: Int, e35 :: Int, e36 :: Int, e37 :: Int, e38 :: Int, e39 :: Int, e40 :: Int, e41 :: Int, e42 :: Int, e43 :: Int, e44 :: Int, e45 :: Int, e46 :: Int, e47 :: Int, e48 :: Int, e49 :: Int, e50 :: Int }
$(fmap concat $
sequence
[ deriveGeneric ''A
, deriveGeneric ''B
, deriveGeneric ''C
, deriveGeneric ''D
, deriveGeneric ''E
])
instance FromJSON A where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON B where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON C where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON D where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON E where parseJSON = gparseJSON defaultJsonOptions
instance ToJSON A where toJSON = gtoJSON defaultJsonOptions
instance ToJSON B where toJSON = gtoJSON defaultJsonOptions
instance ToJSON C where toJSON = gtoJSON defaultJsonOptions
instance ToJSON D where toJSON = gtoJSON defaultJsonOptions
instance ToJSON E where toJSON = gtoJSON defaultJsonOptions
main = pure ()
{-# LANGUAGE TemplateHaskell, DataKinds, TypeFamilies #-}
module Main where
import Data.Aeson (FromJSON(..), ToJSON(..))
import Generics.SOP.TH (deriveGeneric)
import Generics.SOP.JSON (gtoJSON, gparseJSON, defaultJsonOptions)
data A = A { a0 :: Int, a1 :: Int, a2 :: Int, a3 :: Int, a4 :: Int, a5 :: Int, a6 :: Int, a7 :: Int, a8 :: Int, a9 :: Int, a10 :: Int, a11 :: Int, a12 :: Int, a13 :: Int, a14 :: Int, a15 :: Int, a16 :: Int, a17 :: Int, a18 :: Int, a19 :: Int, a20 :: Int, a21 :: Int, a22 :: Int, a23 :: Int, a24 :: Int, a25 :: Int, a26 :: Int, a27 :: Int, a28 :: Int, a29 :: Int, a30 :: Int, a31 :: Int, a32 :: Int, a33 :: Int, a34 :: Int, a35 :: Int, a36 :: Int, a37 :: Int, a38 :: Int, a39 :: Int, a40 :: Int, a41 :: Int, a42 :: Int, a43 :: Int, a44 :: Int, a45 :: Int, a46 :: Int, a47 :: Int, a48 :: Int, a49 :: Int, a50 :: Int }
data B = B { b0 :: Int, b1 :: Int, b2 :: Int, b3 :: Int, b4 :: Int, b5 :: Int, b6 :: Int, b7 :: Int, b8 :: Int, b9 :: Int, b10 :: Int, b11 :: Int, b12 :: Int, b13 :: Int, b14 :: Int, b15 :: Int, b16 :: Int, b17 :: Int, b18 :: Int, b19 :: Int, b20 :: Int, b21 :: Int, b22 :: Int, b23 :: Int, b24 :: Int, b25 :: Int, b26 :: Int, b27 :: Int, b28 :: Int, b29 :: Int, b30 :: Int, b31 :: Int, b32 :: Int, b33 :: Int, b34 :: Int, b35 :: Int, b36 :: Int, b37 :: Int, b38 :: Int, b39 :: Int, b40 :: Int, b41 :: Int, b42 :: Int, b43 :: Int, b44 :: Int, b45 :: Int, b46 :: Int, b47 :: Int, b48 :: Int, b49 :: Int, b50 :: Int }
data C = C { c0 :: Int, c1 :: Int, c2 :: Int, c3 :: Int, c4 :: Int, c5 :: Int, c6 :: Int, c7 :: Int, c8 :: Int, c9 :: Int, c10 :: Int, c11 :: Int, c12 :: Int, c13 :: Int, c14 :: Int, c15 :: Int, c16 :: Int, c17 :: Int, c18 :: Int, c19 :: Int, c20 :: Int, c21 :: Int, c22 :: Int, c23 :: Int, c24 :: Int, c25 :: Int, c26 :: Int, c27 :: Int, c28 :: Int, c29 :: Int, c30 :: Int, c31 :: Int, c32 :: Int, c33 :: Int, c34 :: Int, c35 :: Int, c36 :: Int, c37 :: Int, c38 :: Int, c39 :: Int, c40 :: Int, c41 :: Int, c42 :: Int, c43 :: Int, c44 :: Int, c45 :: Int, c46 :: Int, c47 :: Int, c48 :: Int, c49 :: Int, c50 :: Int }
data D = D { d0 :: Int, d1 :: Int, d2 :: Int, d3 :: Int, d4 :: Int, d5 :: Int, d6 :: Int, d7 :: Int, d8 :: Int, d9 :: Int, d10 :: Int, d11 :: Int, d12 :: Int, d13 :: Int, d14 :: Int, d15 :: Int, d16 :: Int, d17 :: Int, d18 :: Int, d19 :: Int, d20 :: Int, d21 :: Int, d22 :: Int, d23 :: Int, d24 :: Int, d25 :: Int, d26 :: Int, d27 :: Int, d28 :: Int, d29 :: Int, d30 :: Int, d31 :: Int, d32 :: Int, d33 :: Int, d34 :: Int, d35 :: Int, d36 :: Int, d37 :: Int, d38 :: Int, d39 :: Int, d40 :: Int, d41 :: Int, d42 :: Int, d43 :: Int, d44 :: Int, d45 :: Int, d46 :: Int, d47 :: Int, d48 :: Int, d49 :: Int, d50 :: Int }
data E = E { e0 :: Int, e1 :: Int, e2 :: Int, e3 :: Int, e4 :: Int, e5 :: Int, e6 :: Int, e7 :: Int, e8 :: Int, e9 :: Int, e10 :: Int, e11 :: Int, e12 :: Int, e13 :: Int, e14 :: Int, e15 :: Int, e16 :: Int, e17 :: Int, e18 :: Int, e19 :: Int, e20 :: Int, e21 :: Int, e22 :: Int, e23 :: Int, e24 :: Int, e25 :: Int, e26 :: Int, e27 :: Int, e28 :: Int, e29 :: Int, e30 :: Int, e31 :: Int, e32 :: Int, e33 :: Int, e34 :: Int, e35 :: Int, e36 :: Int, e37 :: Int, e38 :: Int, e39 :: Int, e40 :: Int, e41 :: Int, e42 :: Int, e43 :: Int, e44 :: Int, e45 :: Int, e46 :: Int, e47 :: Int, e48 :: Int, e49 :: Int, e50 :: Int }
deriveGeneric ''A
deriveGeneric ''B
deriveGeneric ''C
deriveGeneric ''D
deriveGeneric ''E
instance FromJSON A where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON B where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON C where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON D where parseJSON = gparseJSON defaultJsonOptions
instance FromJSON E where parseJSON = gparseJSON defaultJsonOptions
instance ToJSON A where toJSON = gtoJSON defaultJsonOptions
instance ToJSON B where toJSON = gtoJSON defaultJsonOptions
instance ToJSON C where toJSON = gtoJSON defaultJsonOptions
instance ToJSON D where toJSON = gtoJSON defaultJsonOptions
instance ToJSON E where toJSON = gtoJSON defaultJsonOptions
main = pure ()
{-# LANGUAGE DeriveGeneric, StandaloneDeriving, TemplateHaskell #-}
module Main where
-- import GHC.Generics (Generic)
import Data.Aeson
import Data.Aeson.TH
data A = A { a0 :: Int, a1 :: Int, a2 :: Int, a3 :: Int, a4 :: Int, a5 :: Int, a6 :: Int, a7 :: Int, a8 :: Int, a9 :: Int, a10 :: Int, a11 :: Int, a12 :: Int, a13 :: Int, a14 :: Int, a15 :: Int, a16 :: Int, a17 :: Int, a18 :: Int, a19 :: Int, a20 :: Int, a21 :: Int, a22 :: Int, a23 :: Int, a24 :: Int, a25 :: Int, a26 :: Int, a27 :: Int, a28 :: Int, a29 :: Int, a30 :: Int, a31 :: Int, a32 :: Int, a33 :: Int, a34 :: Int, a35 :: Int, a36 :: Int, a37 :: Int, a38 :: Int, a39 :: Int, a40 :: Int, a41 :: Int, a42 :: Int, a43 :: Int, a44 :: Int, a45 :: Int, a46 :: Int, a47 :: Int, a48 :: Int, a49 :: Int, a50 :: Int }
data B = B { b0 :: Int, b1 :: Int, b2 :: Int, b3 :: Int, b4 :: Int, b5 :: Int, b6 :: Int, b7 :: Int, b8 :: Int, b9 :: Int, b10 :: Int, b11 :: Int, b12 :: Int, b13 :: Int, b14 :: Int, b15 :: Int, b16 :: Int, b17 :: Int, b18 :: Int, b19 :: Int, b20 :: Int, b21 :: Int, b22 :: Int, b23 :: Int, b24 :: Int, b25 :: Int, b26 :: Int, b27 :: Int, b28 :: Int, b29 :: Int, b30 :: Int, b31 :: Int, b32 :: Int, b33 :: Int, b34 :: Int, b35 :: Int, b36 :: Int, b37 :: Int, b38 :: Int, b39 :: Int, b40 :: Int, b41 :: Int, b42 :: Int, b43 :: Int, b44 :: Int, b45 :: Int, b46 :: Int, b47 :: Int, b48 :: Int, b49 :: Int, b50 :: Int }
data C = C { c0 :: Int, c1 :: Int, c2 :: Int, c3 :: Int, c4 :: Int, c5 :: Int, c6 :: Int, c7 :: Int, c8 :: Int, c9 :: Int, c10 :: Int, c11 :: Int, c12 :: Int, c13 :: Int, c14 :: Int, c15 :: Int, c16 :: Int, c17 :: Int, c18 :: Int, c19 :: Int, c20 :: Int, c21 :: Int, c22 :: Int, c23 :: Int, c24 :: Int, c25 :: Int, c26 :: Int, c27 :: Int, c28 :: Int, c29 :: Int, c30 :: Int, c31 :: Int, c32 :: Int, c33 :: Int, c34 :: Int, c35 :: Int, c36 :: Int, c37 :: Int, c38 :: Int, c39 :: Int, c40 :: Int, c41 :: Int, c42 :: Int, c43 :: Int, c44 :: Int, c45 :: Int, c46 :: Int, c47 :: Int, c48 :: Int, c49 :: Int, c50 :: Int }
data D = D { d0 :: Int, d1 :: Int, d2 :: Int, d3 :: Int, d4 :: Int, d5 :: Int, d6 :: Int, d7 :: Int, d8 :: Int, d9 :: Int, d10 :: Int, d11 :: Int, d12 :: Int, d13 :: Int, d14 :: Int, d15 :: Int, d16 :: Int, d17 :: Int, d18 :: Int, d19 :: Int, d20 :: Int, d21 :: Int, d22 :: Int, d23 :: Int, d24 :: Int, d25 :: Int, d26 :: Int, d27 :: Int, d28 :: Int, d29 :: Int, d30 :: Int, d31 :: Int, d32 :: Int, d33 :: Int, d34 :: Int, d35 :: Int, d36 :: Int, d37 :: Int, d38 :: Int, d39 :: Int, d40 :: Int, d41 :: Int, d42 :: Int, d43 :: Int, d44 :: Int, d45 :: Int, d46 :: Int, d47 :: Int, d48 :: Int, d49 :: Int, d50 :: Int }
data E = E { e0 :: Int, e1 :: Int, e2 :: Int, e3 :: Int, e4 :: Int, e5 :: Int, e6 :: Int, e7 :: Int, e8 :: Int, e9 :: Int, e10 :: Int, e11 :: Int, e12 :: Int, e13 :: Int, e14 :: Int, e15 :: Int, e16 :: Int, e17 :: Int, e18 :: Int, e19 :: Int, e20 :: Int, e21 :: Int, e22 :: Int, e23 :: Int, e24 :: Int, e25 :: Int, e26 :: Int, e27 :: Int, e28 :: Int, e29 :: Int, e30 :: Int, e31 :: Int, e32 :: Int, e33 :: Int, e34 :: Int, e35 :: Int, e36 :: Int, e37 :: Int, e38 :: Int, e39 :: Int, e40 :: Int, e41 :: Int, e42 :: Int, e43 :: Int, e44 :: Int, e45 :: Int, e46 :: Int, e47 :: Int, e48 :: Int, e49 :: Int, e50 :: Int }
$(deriveJSON defaultOptions ''A)
$(deriveJSON defaultOptions ''B)
$(deriveJSON defaultOptions ''C)
$(deriveJSON defaultOptions ''D)
$(deriveJSON defaultOptions ''E)
main = pure ()
{-# LANGUAGE DeriveGeneric, StandaloneDeriving #-}
module Main where
import GHC.Generics (Generic)
import Data.Aeson
data A a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 = A { a0 :: a0, a1 :: a1, a2 :: a2, a3 :: a3, a4 :: a4, a5 :: a5, a6 :: a6, a7 :: a7, a8 :: a8, a9 :: a9, a10 :: a10, a11 :: a11, a12 :: a12, a13 :: a13, a14 :: a14, a15 :: a15, a16 :: a16, a17 :: a17, a18 :: a18, a19 :: a19, a20 :: a20, a21 :: a21, a22 :: a22, a23 :: a23, a24 :: a24, a25 :: a25, a26 :: a26, a27 :: a27, a28 :: a28, a29 :: a29, a30 :: a30, a31 :: a31, a32 :: a32, a33 :: a33, a34 :: a34, a35 :: a35, a36 :: a36, a37 :: a37, a38 :: a38, a39 :: a39, a40 :: a40, a41 :: a41, a42 :: a42, a43 :: a43, a44 :: a44, a45 :: a45, a46 :: a46, a47 :: a47, a48 :: a48, a49 :: a49, a50 :: a50 }
data B b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25 b26 b27 b28 b29 b30 b31 b32 b33 b34 b35 b36 b37 b38 b39 b40 b41 b42 b43 b44 b45 b46 b47 b48 b49 b50 = B { b0 :: b0, b1 :: b1, b2 :: b2, b3 :: b3, b4 :: b4, b5 :: b5, b6 :: b6, b7 :: b7, b8 :: b8, b9 :: b9, b10 :: b10, b11 :: b11, b12 :: b12, b13 :: b13, b14 :: b14, b15 :: b15, b16 :: b16, b17 :: b17, b18 :: b18, b19 :: b19, b20 :: b20, b21 :: b21, b22 :: b22, b23 :: b23, b24 :: b24, b25 :: b25, b26 :: b26, b27 :: b27, b28 :: b28, b29 :: b29, b30 :: b30, b31 :: b31, b32 :: b32, b33 :: b33, b34 :: b34, b35 :: b35, b36 :: b36, b37 :: b37, b38 :: b38, b39 :: b39, b40 :: b40, b41 :: b41, b42 :: b42, b43 :: b43, b44 :: b44, b45 :: b45, b46 :: b46, b47 :: b47, b48 :: b48, b49 :: b49, b50 :: b50 }
data C c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 = C { c0 :: c0, c1 :: c1, c2 :: c2, c3 :: c3, c4 :: c4, c5 :: c5, c6 :: c6, c7 :: c7, c8 :: c8, c9 :: c9, c10 :: c10, c11 :: c11, c12 :: c12, c13 :: c13, c14 :: c14, c15 :: c15, c16 :: c16, c17 :: c17, c18 :: c18, c19 :: c19, c20 :: c20, c21 :: c21, c22 :: c22, c23 :: c23, c24 :: c24, c25 :: c25, c26 :: c26, c27 :: c27, c28 :: c28, c29 :: c29, c30 :: c30, c31 :: c31, c32 :: c32, c33 :: c33, c34 :: c34, c35 :: c35, c36 :: c36, c37 :: c37, c38 :: c38, c39 :: c39, c40 :: c40, c41 :: c41, c42 :: c42, c43 :: c43, c44 :: c44, c45 :: c45, c46 :: c46, c47 :: c47, c48 :: c48, c49 :: c49, c50 :: c50 }
data D d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 d32 d33 d34 d35 d36 d37 d38 d39 d40 d41 d42 d43 d44 d45 d46 d47 d48 d49 d50 = D { d0 :: d0, d1 :: d1, d2 :: d2, d3 :: d3, d4 :: d4, d5 :: d5, d6 :: d6, d7 :: d7, d8 :: d8, d9 :: d9, d10 :: d10, d11 :: d11, d12 :: d12, d13 :: d13, d14 :: d14, d15 :: d15, d16 :: d16, d17 :: d17, d18 :: d18, d19 :: d19, d20 :: d20, d21 :: d21, d22 :: d22, d23 :: d23, d24 :: d24, d25 :: d25, d26 :: d26, d27 :: d27, d28 :: d28, d29 :: d29, d30 :: d30, d31 :: d31, d32 :: d32, d33 :: d33, d34 :: d34, d35 :: d35, d36 :: d36, d37 :: d37, d38 :: d38, d39 :: d39, d40 :: d40, d41 :: d41, d42 :: d42, d43 :: d43, d44 :: d44, d45 :: d45, d46 :: d46, d47 :: d47, d48 :: d48, d49 :: d49, d50 :: d50 }
data E e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38 e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50 = E { e0 :: e0, e1 :: e1, e2 :: e2, e3 :: e3, e4 :: e4, e5 :: e5, e6 :: e6, e7 :: e7, e8 :: e8, e9 :: e9, e10 :: e10, e11 :: e11, e12 :: e12, e13 :: e13, e14 :: e14, e15 :: e15, e16 :: e16, e17 :: e17, e18 :: e18, e19 :: e19, e20 :: e20, e21 :: e21, e22 :: e22, e23 :: e23, e24 :: e24, e25 :: e25, e26 :: e26, e27 :: e27, e28 :: e28, e29 :: e29, e30 :: e30, e31 :: e31, e32 :: e32, e33 :: e33, e34 :: e34, e35 :: e35, e36 :: e36, e37 :: e37, e38 :: e38, e39 :: e39, e40 :: e40, e41 :: e41, e42 :: e42, e43 :: e43, e44 :: e44, e45 :: e45, e46 :: e46, e47 :: e47, e48 :: e48, e49 :: e49, e50 :: e50 }
deriving instance Generic (A a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50)
deriving instance Generic (B b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25 b26 b27 b28 b29 b30 b31 b32 b33 b34 b35 b36 b37 b38 b39 b40 b41 b42 b43 b44 b45 b46 b47 b48 b49 b50)
deriving instance Generic (C c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50)
deriving instance Generic (D d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 d32 d33 d34 d35 d36 d37 d38 d39 d40 d41 d42 d43 d44 d45 d46 d47 d48 d49 d50)
deriving instance Generic (E e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38 e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50)
instance (FromJSON a0, FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7, FromJSON a8, FromJSON a9, FromJSON a10, FromJSON a11, FromJSON a12, FromJSON a13, FromJSON a14, FromJSON a15, FromJSON a16, FromJSON a17, FromJSON a18, FromJSON a19, FromJSON a20, FromJSON a21, FromJSON a22, FromJSON a23, FromJSON a24, FromJSON a25, FromJSON a26, FromJSON a27, FromJSON a28, FromJSON a29, FromJSON a30, FromJSON a31, FromJSON a32, FromJSON a33, FromJSON a34, FromJSON a35, FromJSON a36, FromJSON a37, FromJSON a38, FromJSON a39, FromJSON a40, FromJSON a41, FromJSON a42, FromJSON a43, FromJSON a44, FromJSON a45, FromJSON a46, FromJSON a47, FromJSON a48, FromJSON a49, FromJSON a50) => FromJSON (A a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50)
instance (FromJSON b0, FromJSON b1, FromJSON b2, FromJSON b3, FromJSON b4, FromJSON b5, FromJSON b6, FromJSON b7, FromJSON b8, FromJSON b9, FromJSON b10, FromJSON b11, FromJSON b12, FromJSON b13, FromJSON b14, FromJSON b15, FromJSON b16, FromJSON b17, FromJSON b18, FromJSON b19, FromJSON b20, FromJSON b21, FromJSON b22, FromJSON b23, FromJSON b24, FromJSON b25, FromJSON b26, FromJSON b27, FromJSON b28, FromJSON b29, FromJSON b30, FromJSON b31, FromJSON b32, FromJSON b33, FromJSON b34, FromJSON b35, FromJSON b36, FromJSON b37, FromJSON b38, FromJSON b39, FromJSON b40, FromJSON b41, FromJSON b42, FromJSON b43, FromJSON b44, FromJSON b45, FromJSON b46, FromJSON b47, FromJSON b48, FromJSON b49, FromJSON b50) => FromJSON (B b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25 b26 b27 b28 b29 b30 b31 b32 b33 b34 b35 b36 b37 b38 b39 b40 b41 b42 b43 b44 b45 b46 b47 b48 b49 b50)
instance (FromJSON c0, FromJSON c1, FromJSON c2, FromJSON c3, FromJSON c4, FromJSON c5, FromJSON c6, FromJSON c7, FromJSON c8, FromJSON c9, FromJSON c10, FromJSON c11, FromJSON c12, FromJSON c13, FromJSON c14, FromJSON c15, FromJSON c16, FromJSON c17, FromJSON c18, FromJSON c19, FromJSON c20, FromJSON c21, FromJSON c22, FromJSON c23, FromJSON c24, FromJSON c25, FromJSON c26, FromJSON c27, FromJSON c28, FromJSON c29, FromJSON c30, FromJSON c31, FromJSON c32, FromJSON c33, FromJSON c34, FromJSON c35, FromJSON c36, FromJSON c37, FromJSON c38, FromJSON c39, FromJSON c40, FromJSON c41, FromJSON c42, FromJSON c43, FromJSON c44, FromJSON c45, FromJSON c46, FromJSON c47, FromJSON c48, FromJSON c49, FromJSON c50) => FromJSON (C c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50)
instance (FromJSON d0, FromJSON d1, FromJSON d2, FromJSON d3, FromJSON d4, FromJSON d5, FromJSON d6, FromJSON d7, FromJSON d8, FromJSON d9, FromJSON d10, FromJSON d11, FromJSON d12, FromJSON d13, FromJSON d14, FromJSON d15, FromJSON d16, FromJSON d17, FromJSON d18, FromJSON d19, FromJSON d20, FromJSON d21, FromJSON d22, FromJSON d23, FromJSON d24, FromJSON d25, FromJSON d26, FromJSON d27, FromJSON d28, FromJSON d29, FromJSON d30, FromJSON d31, FromJSON d32, FromJSON d33, FromJSON d34, FromJSON d35, FromJSON d36, FromJSON d37, FromJSON d38, FromJSON d39, FromJSON d40, FromJSON d41, FromJSON d42, FromJSON d43, FromJSON d44, FromJSON d45, FromJSON d46, FromJSON d47, FromJSON d48, FromJSON d49, FromJSON d50) => FromJSON (D d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 d32 d33 d34 d35 d36 d37 d38 d39 d40 d41 d42 d43 d44 d45 d46 d47 d48 d49 d50)
instance (FromJSON e0, FromJSON e1, FromJSON e2, FromJSON e3, FromJSON e4, FromJSON e5, FromJSON e6, FromJSON e7, FromJSON e8, FromJSON e9, FromJSON e10, FromJSON e11, FromJSON e12, FromJSON e13, FromJSON e14, FromJSON e15, FromJSON e16, FromJSON e17, FromJSON e18, FromJSON e19, FromJSON e20, FromJSON e21, FromJSON e22, FromJSON e23, FromJSON e24, FromJSON e25, FromJSON e26, FromJSON e27, FromJSON e28, FromJSON e29, FromJSON e30, FromJSON e31, FromJSON e32, FromJSON e33, FromJSON e34, FromJSON e35, FromJSON e36, FromJSON e37, FromJSON e38, FromJSON e39, FromJSON e40, FromJSON e41, FromJSON e42, FromJSON e43, FromJSON e44, FromJSON e45, FromJSON e46, FromJSON e47, FromJSON e48, FromJSON e49, FromJSON e50) => FromJSON (E e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38 e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50)
instance (ToJSON a0, ToJSON a1, ToJSON a2, ToJSON a3, ToJSON a4, ToJSON a5, ToJSON a6, ToJSON a7, ToJSON a8, ToJSON a9, ToJSON a10, ToJSON a11, ToJSON a12, ToJSON a13, ToJSON a14, ToJSON a15, ToJSON a16, ToJSON a17, ToJSON a18, ToJSON a19, ToJSON a20, ToJSON a21, ToJSON a22, ToJSON a23, ToJSON a24, ToJSON a25, ToJSON a26, ToJSON a27, ToJSON a28, ToJSON a29, ToJSON a30, ToJSON a31, ToJSON a32, ToJSON a33, ToJSON a34, ToJSON a35, ToJSON a36, ToJSON a37, ToJSON a38, ToJSON a39, ToJSON a40, ToJSON a41, ToJSON a42, ToJSON a43, ToJSON a44, ToJSON a45, ToJSON a46, ToJSON a47, ToJSON a48, ToJSON a49, ToJSON a50) => ToJSON (A a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50)
instance (ToJSON b0, ToJSON b1, ToJSON b2, ToJSON b3, ToJSON b4, ToJSON b5, ToJSON b6, ToJSON b7, ToJSON b8, ToJSON b9, ToJSON b10, ToJSON b11, ToJSON b12, ToJSON b13, ToJSON b14, ToJSON b15, ToJSON b16, ToJSON b17, ToJSON b18, ToJSON b19, ToJSON b20, ToJSON b21, ToJSON b22, ToJSON b23, ToJSON b24, ToJSON b25, ToJSON b26, ToJSON b27, ToJSON b28, ToJSON b29, ToJSON b30, ToJSON b31, ToJSON b32, ToJSON b33, ToJSON b34, ToJSON b35, ToJSON b36, ToJSON b37, ToJSON b38, ToJSON b39, ToJSON b40, ToJSON b41, ToJSON b42, ToJSON b43, ToJSON b44, ToJSON b45, ToJSON b46, ToJSON b47, ToJSON b48, ToJSON b49, ToJSON b50) => ToJSON (B b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25 b26 b27 b28 b29 b30 b31 b32 b33 b34 b35 b36 b37 b38 b39 b40 b41 b42 b43 b44 b45 b46 b47 b48 b49 b50)
instance (ToJSON c0, ToJSON c1, ToJSON c2, ToJSON c3, ToJSON c4, ToJSON c5, ToJSON c6, ToJSON c7, ToJSON c8, ToJSON c9, ToJSON c10, ToJSON c11, ToJSON c12, ToJSON c13, ToJSON c14, ToJSON c15, ToJSON c16, ToJSON c17, ToJSON c18, ToJSON c19, ToJSON c20, ToJSON c21, ToJSON c22, ToJSON c23, ToJSON c24, ToJSON c25, ToJSON c26, ToJSON c27, ToJSON c28, ToJSON c29, ToJSON c30, ToJSON c31, ToJSON c32, ToJSON c33, ToJSON c34, ToJSON c35, ToJSON c36, ToJSON c37, ToJSON c38, ToJSON c39, ToJSON c40, ToJSON c41, ToJSON c42, ToJSON c43, ToJSON c44, ToJSON c45, ToJSON c46, ToJSON c47, ToJSON c48, ToJSON c49, ToJSON c50) => ToJSON (C c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50)
instance (ToJSON d0, ToJSON d1, ToJSON d2, ToJSON d3, ToJSON d4, ToJSON d5, ToJSON d6, ToJSON d7, ToJSON d8, ToJSON d9, ToJSON d10, ToJSON d11, ToJSON d12, ToJSON d13, ToJSON d14, ToJSON d15, ToJSON d16, ToJSON d17, ToJSON d18, ToJSON d19, ToJSON d20, ToJSON d21, ToJSON d22, ToJSON d23, ToJSON d24, ToJSON d25, ToJSON d26, ToJSON d27, ToJSON d28, ToJSON d29, ToJSON d30, ToJSON d31, ToJSON d32, ToJSON d33, ToJSON d34, ToJSON d35, ToJSON d36, ToJSON d37, ToJSON d38, ToJSON d39, ToJSON d40, ToJSON d41, ToJSON d42, ToJSON d43, ToJSON d44, ToJSON d45, ToJSON d46, ToJSON d47, ToJSON d48, ToJSON d49, ToJSON d50) => ToJSON (D d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 d32 d33 d34 d35 d36 d37 d38 d39 d40 d41 d42 d43 d44 d45 d46 d47 d48 d49 d50)
instance (ToJSON e0, ToJSON e1, ToJSON e2, ToJSON e3, ToJSON e4, ToJSON e5, ToJSON e6, ToJSON e7, ToJSON e8, ToJSON e9, ToJSON e10, ToJSON e11, ToJSON e12, ToJSON e13, ToJSON e14, ToJSON e15, ToJSON e16, ToJSON e17, ToJSON e18, ToJSON e19, ToJSON e20, ToJSON e21, ToJSON e22, ToJSON e23, ToJSON e24, ToJSON e25, ToJSON e26, ToJSON e27, ToJSON e28, ToJSON e29, ToJSON e30, ToJSON e31, ToJSON e32, ToJSON e33, ToJSON e34, ToJSON e35, ToJSON e36, ToJSON e37, ToJSON e38, ToJSON e39, ToJSON e40, ToJSON e41, ToJSON e42, ToJSON e43, ToJSON e44, ToJSON e45, ToJSON e46, ToJSON e47, ToJSON e48, ToJSON e49, ToJSON e50) => ToJSON (E e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38 e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50)
main = pure ()
{-# LANGUAGE DeriveGeneric, StandaloneDeriving, TemplateHaskell #-}
module Main where
-- import GHC.Generics (Generic)
import Data.Aeson
import Data.Aeson.TH
data A a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 = A { a0 :: a0, a1 :: a1, a2 :: a2, a3 :: a3, a4 :: a4, a5 :: a5, a6 :: a6, a7 :: a7, a8 :: a8, a9 :: a9, a10 :: a10, a11 :: a11, a12 :: a12, a13 :: a13, a14 :: a14, a15 :: a15, a16 :: a16, a17 :: a17, a18 :: a18, a19 :: a19, a20 :: a20, a21 :: a21, a22 :: a22, a23 :: a23, a24 :: a24, a25 :: a25, a26 :: a26, a27 :: a27, a28 :: a28, a29 :: a29, a30 :: a30, a31 :: a31, a32 :: a32, a33 :: a33, a34 :: a34, a35 :: a35, a36 :: a36, a37 :: a37, a38 :: a38, a39 :: a39, a40 :: a40, a41 :: a41, a42 :: a42, a43 :: a43, a44 :: a44, a45 :: a45, a46 :: a46, a47 :: a47, a48 :: a48, a49 :: a49, a50 :: a50 }
data B b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25 b26 b27 b28 b29 b30 b31 b32 b33 b34 b35 b36 b37 b38 b39 b40 b41 b42 b43 b44 b45 b46 b47 b48 b49 b50 = B { b0 :: b0, b1 :: b1, b2 :: b2, b3 :: b3, b4 :: b4, b5 :: b5, b6 :: b6, b7 :: b7, b8 :: b8, b9 :: b9, b10 :: b10, b11 :: b11, b12 :: b12, b13 :: b13, b14 :: b14, b15 :: b15, b16 :: b16, b17 :: b17, b18 :: b18, b19 :: b19, b20 :: b20, b21 :: b21, b22 :: b22, b23 :: b23, b24 :: b24, b25 :: b25, b26 :: b26, b27 :: b27, b28 :: b28, b29 :: b29, b30 :: b30, b31 :: b31, b32 :: b32, b33 :: b33, b34 :: b34, b35 :: b35, b36 :: b36, b37 :: b37, b38 :: b38, b39 :: b39, b40 :: b40, b41 :: b41, b42 :: b42, b43 :: b43, b44 :: b44, b45 :: b45, b46 :: b46, b47 :: b47, b48 :: b48, b49 :: b49, b50 :: b50 }
data C c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 = C { c0 :: c0, c1 :: c1, c2 :: c2, c3 :: c3, c4 :: c4, c5 :: c5, c6 :: c6, c7 :: c7, c8 :: c8, c9 :: c9, c10 :: c10, c11 :: c11, c12 :: c12, c13 :: c13, c14 :: c14, c15 :: c15, c16 :: c16, c17 :: c17, c18 :: c18, c19 :: c19, c20 :: c20, c21 :: c21, c22 :: c22, c23 :: c23, c24 :: c24, c25 :: c25, c26 :: c26, c27 :: c27, c28 :: c28, c29 :: c29, c30 :: c30, c31 :: c31, c32 :: c32, c33 :: c33, c34 :: c34, c35 :: c35, c36 :: c36, c37 :: c37, c38 :: c38, c39 :: c39, c40 :: c40, c41 :: c41, c42 :: c42, c43 :: c43, c44 :: c44, c45 :: c45, c46 :: c46, c47 :: c47, c48 :: c48, c49 :: c49, c50 :: c50 }
data D d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 d32 d33 d34 d35 d36 d37 d38 d39 d40 d41 d42 d43 d44 d45 d46 d47 d48 d49 d50 = D { d0 :: d0, d1 :: d1, d2 :: d2, d3 :: d3, d4 :: d4, d5 :: d5, d6 :: d6, d7 :: d7, d8 :: d8, d9 :: d9, d10 :: d10, d11 :: d11, d12 :: d12, d13 :: d13, d14 :: d14, d15 :: d15, d16 :: d16, d17 :: d17, d18 :: d18, d19 :: d19, d20 :: d20, d21 :: d21, d22 :: d22, d23 :: d23, d24 :: d24, d25 :: d25, d26 :: d26, d27 :: d27, d28 :: d28, d29 :: d29, d30 :: d30, d31 :: d31, d32 :: d32, d33 :: d33, d34 :: d34, d35 :: d35, d36 :: d36, d37 :: d37, d38 :: d38, d39 :: d39, d40 :: d40, d41 :: d41, d42 :: d42, d43 :: d43, d44 :: d44, d45 :: d45, d46 :: d46, d47 :: d47, d48 :: d48, d49 :: d49, d50 :: d50 }
data E e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e24 e25 e26 e27 e28 e29 e30 e31 e32 e33 e34 e35 e36 e37 e38 e39 e40 e41 e42 e43 e44 e45 e46 e47 e48 e49 e50 = E { e0 :: e0, e1 :: e1, e2 :: e2, e3 :: e3, e4 :: e4, e5 :: e5, e6 :: e6, e7 :: e7, e8 :: e8, e9 :: e9, e10 :: e10, e11 :: e11, e12 :: e12, e13 :: e13, e14 :: e14, e15 :: e15, e16 :: e16, e17 :: e17, e18 :: e18, e19 :: e19, e20 :: e20, e21 :: e21, e22 :: e22, e23 :: e23, e24 :: e24, e25 :: e25, e26 :: e26, e27 :: e27, e28 :: e28, e29 :: e29, e30 :: e30, e31 :: e31, e32 :: e32, e33 :: e33, e34 :: e34, e35 :: e35, e36 :: e36, e37 :: e37, e38 :: e38, e39 :: e39, e40 :: e40, e41 :: e41, e42 :: e42, e43 :: e43, e44 :: e44, e45 :: e45, e46 :: e46, e47 :: e47, e48 :: e48, e49 :: e49, e50 :: e50 }
$(deriveJSON defaultOptions ''A)
$(deriveJSON defaultOptions ''B)
$(deriveJSON defaultOptions ''C)
$(deriveJSON defaultOptions ''D)
$(deriveJSON defaultOptions ''E)
main = pure ()
{-# LANGUAGE ConstraintKinds, PatternSynonyms #-}
{-# LANGUAGE TypeApplications, TupleSections, ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances, RankNTypes, DerivingStrategies,
FlexibleInstances, FlexibleContexts, TypeFamilies, DeriveGeneric,
GeneralizedNewtypeDeriving, DeriveTraversable, OverloadedStrings #-}
module Q
( defaultOptions,
genericDecode,
genericEncode,
-- decodeJSON,
-- encodeJSON,
-- genericDecodeJSON,
-- genericEncodeJSON,
-- GEncodable,
-- GDecodable,
-- FromJSONArg (..),
-- parseJSONBareRecord,
-- ToJSONArg (..),
-- toJSONBareRecord,
-- GenericDecode,
-- GenericEncode,
)
where
import Prelude hiding (fail, String, show)
import qualified Prelude
import Control.Monad.Except (Except, throwError)
import qualified Data.Aeson as Aeson
import Data.Aeson (FromJSON(..), ToJSON(..), Value(..), (.!=), (.:), (.:?), (.=), (<?>))
import qualified Data.Aeson.Types as Aeson
import Data.Aeson.Types (JSONPathElement (Index, Key))
import qualified Data.ByteString.Lazy
import Data.Char
import Data.Maybe
import qualified Data.Text as T
import qualified Data.Text.Encoding
import GHC.Generics (Generic, Rep)
import Generics.Eot
import qualified Data.Char as Char
import qualified Data.Text as Text
import Data.Text (Text)
import qualified Data.Foldable
import qualified Control.Monad.Fail as Fail
type String = T.Text
show :: Show a => a -> String
show = T.pack . Prelude.show
fromHaskellString = T.pack
toHaskellString = T.unpack
fromFoldable :: forall f a. Foldable f => f a -> List a
fromFoldable = foldr Cons Nil . Data.Foldable.toList
data List a = Nil | Cons a (List a)
deriving (Show, Eq, Ord)
instance Semigroup (List a) where
Nil <> l2 = l2
Cons a1 l1 <> l2 = Cons a1 (l1 <> l2)
instance Monoid (List a) where
mempty = Nil
mappend = (<>)
instance Functor List where
fmap f Nil = Nil
fmap f (Cons a l) = Cons (f a) (fmap f l)
instance Foldable List where
foldr k z = go
where
go Nil = z
go (Cons y ys) = y `k` go ys
decodeField :: Text -> Text
decodeField s =
if "____" `Text.isPrefixOf` s
then Text.pack (go (Prelude.drop 4 (Text.unpack s)))
else s
where
go ('_' : xs) =
Prelude.toEnum (Prelude.read (Prelude.takeWhile Char.isDigit xs))
: go (Prelude.drop 1 (Prelude.dropWhile Char.isDigit xs))
go (c : xs) = c : go xs
go [] = []
data NonEmpty f a = NonEmpty a (f a)
deriving (Eq, Ord, Show, Foldable, Functor, Traversable)
pattern (:|) :: a -> f a -> NonEmpty f a
pattern (:|) a fa = NonEmpty a fa
newtype NonEmptyList a = NonEmptyList (NonEmpty List a) deriving (Show)
type MultipleErrors = NonEmptyList ForeignError
data ForeignError
= ForeignError T.Text
| TypeMismatch T.Text T.Text
| ErrorAtIndex Int ForeignError
| ErrorAtProperty T.Text ForeignError
| JSONError T.Text
deriving (Eq, Ord, Show)
newtype FError = FError T.Text
deriving stock (Eq, Generic)
deriving newtype (Show)
-- In PS this is "type F = Except MultipleErrors", but the only thing we do
-- with errors is use Show on them. So 'ForeignError' is not needed and
-- 'FError' is fine.
type F = Except FError
type Foreign = Value
readString :: HasDecodeFail f => Foreign -> f T.Text
readString = fromParser . parseJSON
renderForeignError :: ForeignError -> String
renderForeignError (ForeignError msg) = msg
renderForeignError (ErrorAtIndex i e) = "Error at array index " <> show i <> ": " <> renderForeignError e
renderForeignError (ErrorAtProperty prop e) = "Error at property " <> show prop <> ": " <> renderForeignError e
renderForeignError (TypeMismatch exp act) = "Type mismatch: expected " <> exp <> ", found " <> act
data Options = Options
{ ____sumEncoding :: SumEncoding,
____unwrapSingleConstructors :: Bool,
____unwrapSingleArguments :: Bool,
____fieldTransform :: String -> String
} deriving (Generic)
-- | The encoding of sum types for your type.
-- | `TaggedObject`s will be encoded in the form `{ [tagFieldName]: "ConstructorTag", [contentsFieldName]: "Contents"}`.
-- | `constructorTagTransform` can be provided to transform the constructor tag to a form you use, e.g. `toLower`/`toUpper`.
data SumEncoding = TaggedObject
{ ____tagFieldName :: String,
____contentsFieldName :: String,
____constructorTagTransform :: String -> String
}
fail :: Fail.MonadFail m => T.Text -> m a
fail = Fail.fail . toHaskellString
class Applicative f => HasDecodeFail f where
decodeFail :: T.Text -> f a
fromParser :: Aeson.Parser a -> f a
instance HasDecodeFail Aeson.Parser where
decodeFail = fail
fromParser = id
instance (a ~ FError) => HasDecodeFail (Except a) where
decodeFail = throwError . FError
fromParser = either (throwError . FError . fromHaskellString) pure . Aeson.parseEither id
-- | Default decoding/encoding options:
-- |
-- | - Represent sum types as records with `tag` and `contents` fields
-- | - Unwrap single arguments
-- | - Don't unwrap single constructors
-- | - Use the constructor names as-is
-- | - Use the field names as-is
defaultOptions :: Options
defaultOptions =
Options
{ ____sumEncoding =
TaggedObject
{ ____tagFieldName = "tag",
____contentsFieldName = "contents",
____constructorTagTransform = id
},
____unwrapSingleConstructors = False,
____unwrapSingleArguments = True,
____fieldTransform = id
}
-- | Read a value which has a `Generic` type.
genericDecode ::
forall a f.
(HasEot a, GDecode (Eot a), HasDecodeFail f) =>
Options ->
Foreign ->
f a
genericDecode opts val =
let d = datatype (Proxy @a)
in fromEot <$> fromParser (gDecode opts d val)
-- | Generate a `Foreign` value compatible with the `readGeneric` function.
genericEncode ::
forall a.
(HasEot a, GEncode (Eot a)) =>
Options ->
a ->
Foreign
genericEncode opts =
let d = datatype (Proxy @a)
in gEncode opts d (constructors d) . toEot
-- | Decode a JSON string using a `Decode` instance.
decodeJSON ::
(HasDecodeFail f, Aeson.FromJSON a) =>
T.Text ->
f a
decodeJSON s =
case Aeson.eitherDecode (Data.ByteString.Lazy.fromStrict (Data.Text.Encoding.encodeUtf8 s)) of
Left err -> decodeFail $ T.pack err
Right val -> fromParser (Aeson.parseJSON val)
-- | Encode a JSON string using an `Encode` instance.
encodeJSON ::
Aeson.ToJSON a =>
a ->
T.Text
encodeJSON =
Data.Text.Encoding.decodeUtf8
. Data.ByteString.Lazy.toStrict
. Aeson.encode
-- | Read a value which has a `Generic` type from a JSON String
genericDecodeJSON ::
(HasDecodeFail f, HasEot a, GDecode (Eot a)) =>
Options ->
String ->
f a
genericDecodeJSON opts s =
case Aeson.eitherDecode (Data.ByteString.Lazy.fromStrict (Data.Text.Encoding.encodeUtf8 s)) of
Left err -> decodeFail $ T.pack err
Right val -> fromParser (genericDecode opts val)
-- | Write a value which has a `Generic` type as a JSON String
genericEncodeJSON ::
(HasEot a, GEncode (Eot a)) =>
Options ->
a ->
String
genericEncodeJSON opts =
-- TODO: can be made faster by using Encoding
Data.Text.Encoding.decodeUtf8
. Data.ByteString.Lazy.toStrict
. Aeson.encode
. genericEncode opts
----------------------------------------------------------------------------
-- Synonyms
----------------------------------------------------------------------------
type GEncodable a = (Generic a, HasEot a, GEncode (Eot a))
type GDecodable a = (Generic a, HasEot a, GDecode (Eot a))
----------------------------------------------------------------------------
-- Handling bare records
----------------------------------------------------------------------------
-- Bare records wrapped into newtypes should be handled differently. In
-- PureScript, "type Foo = {...}; newtype Bar = Bar Foo" is encoded the same
-- way as "data Bar = Bar {...}". So we need to distinguish bare records in
-- data types from other records.
class FromJSONArg a where
parseJSONArg :: Options -> (Aeson.Value -> Aeson.Parser a)
instance {-# OVERLAPPABLE #-} FromJSON a => FromJSONArg a where
parseJSONArg _ = parseJSON
-- | Parse a bare record
parseJSONBareRecord :: GDecodable a => Options -> (Aeson.Value -> Aeson.Parser a)
parseJSONBareRecord o = genericDecode o {____unwrapSingleConstructors = True}
class ToJSONArg a where
toJSONArg :: Options -> a -> Aeson.Value
instance {-# OVERLAPPABLE #-} ToJSON a => ToJSONArg a where
toJSONArg _ = toJSON
-- | Render a bare record
toJSONBareRecord :: GEncodable a => Options -> a -> Aeson.Value
toJSONBareRecord o = genericEncode o {____unwrapSingleConstructors = True}
----------------------------------------------------------------------------
-- Generic encoding
----------------------------------------------------------------------------
class GEncode a where
gEncode :: Options -> Datatype -> [Constructor] -> a -> Aeson.Value
instance GEncode Void where
gEncode _ _ _ val = absurd val
instance (EncodeFields a, GEncode b) => GEncode (Either a b) where
gEncode o d (c : cs) (Left val) =
let contents = gEncodeContents o (fields c) val
in case (____unwrapSingleConstructors o, constructors d) of
(True, [_]) ->
fromMaybe (Aeson.object []) contents
_ ->
Aeson.object $
[ (____tagFieldName (____sumEncoding o))
.= ____constructorTagTransform
(____sumEncoding o)
(T.pack (constructorName c))
]
++ [ (____contentsFieldName (____sumEncoding o)) .= x
| Just x <- [contents]
]
gEncode o d (c : cs) (Right val) = gEncode o d cs val
class EncodeFields a where
encodeFields :: Options -> a -> [Aeson.Value]
instance EncodeFields () where
encodeFields _ () = []
instance (ToJSONArg a, EncodeFields b) => EncodeFields (a, b) where
encodeFields o (a, b) = toJSONArg o a : encodeFields o b
gEncodeContents :: EncodeFields a => Options -> Fields -> a -> Maybe Aeson.Value
gEncodeContents o fs a = case (fs, ____unwrapSingleArguments o, encodeFields o a) of
(NoFields, _, _) ->
Nothing
(Selectors names, True, xs) ->
Just $ Aeson.object
$ map (uncurry (.=))
-- TODO: the Null filtering should only happen for NullOrUndefined
$ filter (\(k, v) -> v /= Aeson.Null)
$ zip (map (____fieldTransform o . decodeField . T.pack) names) xs
(Selectors names, False, xs) ->
Just $ Aeson.toJSON $ (: [])
$ Aeson.object
$ map (uncurry (.=))
-- TODO: the Null filtering should only happen for NullOrUndefined
$ filter (\(k, v) -> v /= Aeson.Null)
$ zip (map (____fieldTransform o . decodeField . T.pack) names) xs
(NoSelectors 1, True, [x]) ->
Just $ Aeson.toJSON x
(NoSelectors _, _, xs) ->
Just $ Aeson.toJSON xs
----------------------------------------------------------------------------
-- Generic decoding
----------------------------------------------------------------------------
gDecode :: GDecode a => Options -> Datatype -> (Aeson.Value -> Aeson.Parser a)
gDecode o d =
case (____unwrapSingleConstructors o, constructors d) of
(True, [_]) ->
\val -> gDecodeContents o (constructors d) Nothing val
_ -> Aeson.withObject (datatypeName d) $ \val' -> do
let tagName = ____tagFieldName (____sumEncoding o)
contentsName = ____contentsFieldName (____sumEncoding o)
tag <-
(val' .: tagName) <?> Key tagName
contents <-
(val' .:? contentsName .!= Aeson.object []) <?> Key contentsName
gDecodeContents o (constructors d) (Just tag) contents
class GDecode a where
gDecodeContents ::
Options -> [Constructor] -> Maybe String -> (Aeson.Value -> Aeson.Parser a)
instance GDecode Void where
gDecodeContents _ _ Nothing = \_ -> fail "decoding error"
gDecodeContents _ _ (Just tag) = \_ -> fail ("unknown tag " <> show tag)
instance (DecodeFields a, GDecode b) => GDecode (Either a b) where
gDecodeContents o (c : cs) mbTag = \val -> do
let expectedTag =
____constructorTagTransform
(____sumEncoding o)
(T.pack (constructorName c))
case mbTag of
Nothing -> Left <$> (decodeFields o =<< extractFields o (fields c) val)
Just tag ->
if tag == expectedTag
then Left <$> (decodeFields o =<< extractFields o (fields c) val)
else Right <$> gDecodeContents o cs mbTag val
extractFields ::
Options -> Fields -> Aeson.Value -> Aeson.Parser [(JSONPathElement, Aeson.Value)]
extractFields o fs val =
case (fs, ____unwrapSingleArguments o) of
(NoFields, _) ->
-- Note: the canonical encoding for an empty constructor is {},
-- but PS doesn't care if it sees anything else - parsing will
-- still succeed. Therefore we don't have to do a check here.
pure []
(Selectors names, True) -> do
val' <- Aeson.parseJSON val
mapM
(\k -> (Key k,) <$> (val' .:? k .!= Aeson.Null))
(map (____fieldTransform o . decodeField . T.pack) names)
(Selectors names, False) -> do
[val'] <- Aeson.parseJSON val
mapM
(\k -> (Key k,) <$> (val' .:? k .!= Aeson.Null))
(map (____fieldTransform o . decodeField . T.pack) names)
(NoSelectors 1, True) ->
(\x -> [(Key "", x)]) <$> Aeson.parseJSON val
(NoSelectors _, _) ->
map (Key "",) <$> Aeson.parseJSON val
class DecodeFields a where
decodeFields :: Options -> [(JSONPathElement, Aeson.Value)] -> Aeson.Parser a
instance DecodeFields () where
decodeFields _ _ = pure ()
instance (FromJSONArg a, DecodeFields b) => DecodeFields (a, b) where
decodeFields o ((k, a) : bs) =
(,)
<$> (parseJSONArg o a <?> k)
<*> decodeFields o bs
decodeFields _ [] = fail "not enough array elements"
type GenericDecode a = GDecodable a
type GenericEncode a = GEncodable a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.