@@ -925,22 +925,28 @@ class GToJSON f where
926instance (GToJSON a) => GToJSON (M1 i c a) where
926instance (GToJSON a) => GToJSON (M1 i c a) where
927 gToJSON = gToJSON . unM1
927 gToJSON = gToJSON . unM1
928+ {-# INLINE gToJSON #-}
929instance (ToJSON a) => GToJSON (K1 i a) where
930instance (ToJSON a) => GToJSON (K1 i a) where
930 gToJSON = toJSON . unK1
931 gToJSON = toJSON . unK1
932+ {-# INLINE gToJSON #-}
932instance GToJSON U1 where
934instance GToJSON U1 where
933 gToJSON _ = emptyArray
935 gToJSON _ = emptyArray
936+ {-# INLINE gToJSON #-}
935instance (ConsToJSON a) => GToJSON (C1 c a) where
938instance (ConsToJSON a) => GToJSON (C1 c a) where
936 gToJSON = consToJSON . unM1
939 gToJSON = consToJSON . unM1
940+ {-# INLINE gToJSON #-}
938instance (GProductToValues a, GProductToValues b) => GToJSON (a :*: b) where
942instance (GProductToValues a, GProductToValues b) => GToJSON (a :*: b) where
939 gToJSON = toJSON . toList . gProductToValues
943 gToJSON = toJSON . toList . gProductToValues
944+ {-# INLINE gToJSON #-}
941instance (GObject a, GObject b) => GToJSON (a :+: b) where
946instance (GObject a, GObject b) => GToJSON (a :+: b) where
942 gToJSON (L1 x) = Object $ gObject x
947 gToJSON (L1 x) = Object $ gObject x
943 gToJSON (R1 x) = Object $ gObject x
948 gToJSON (R1 x) = Object $ gObject x
949+ {-# INLINE gToJSON #-}
945--------------------------------------------------------------------------------
951--------------------------------------------------------------------------------
@@ -949,12 +955,15 @@ class ConsToJSON' b f where consToJSON' :: Tagged b (f a -> Value)
950instance (IsRecord f b, ConsToJSON' b f) => ConsToJSON f where
956instance (IsRecord f b, ConsToJSON' b f) => ConsToJSON f where
951 consToJSON = unTagged (consToJSON' :: Tagged b (f a -> Value))
957 consToJSON = unTagged (consToJSON' :: Tagged b (f a -> Value))
958+ {-# INLINE consToJSON #-}
953instance (GRecordToObject f) => ConsToJSON' True f where
960instance (GRecordToObject f) => ConsToJSON' True f where
954 consToJSON' = Tagged (Object . gRecordToObject)
961 consToJSON' = Tagged (Object . gRecordToObject)
962+ {-# INLINE consToJSON' #-}
956instance GToJSON f => ConsToJSON' False f where
964instance GToJSON f => ConsToJSON' False f where
957 consToJSON' = Tagged gToJSON
965 consToJSON' = Tagged gToJSON
966+ {-# INLINE consToJSON' #-}
959--------------------------------------------------------------------------------
968--------------------------------------------------------------------------------
@@ -963,9 +972,11 @@ class GRecordToObject f where
964instance (GRecordToObject a, GRecordToObject b) => GRecordToObject (a :*: b) where
973instance (GRecordToObject a, GRecordToObject b) => GRecordToObject (a :*: b) where
965 gRecordToObject (a :*: b) = gRecordToObject a `M.union` gRecordToObject b
974 gRecordToObject (a :*: b) = gRecordToObject a `M.union` gRecordToObject b
975+ {-# INLINE gRecordToObject #-}
967instance (Selector s, GToJSON a) => GRecordToObject (S1 s a) where
977instance (Selector s, GToJSON a) => GRecordToObject (S1 s a) where
968 gRecordToObject m1 = M.singleton (pack (selName m1)) (gToJSON (unM1 m1))
978 gRecordToObject m1 = M.singleton (pack (selName m1)) (gToJSON (unM1 m1))
979+ {-# INLINE gRecordToObject #-}
970--------------------------------------------------------------------------------
981--------------------------------------------------------------------------------
@@ -974,9 +985,11 @@ class GProductToValues f where
975instance (GProductToValues a, GProductToValues b) => GProductToValues (a :*: b) where
986instance (GProductToValues a, GProductToValues b) => GProductToValues (a :*: b) where
976 gProductToValues (a :*: b) = gProductToValues a `append` gProductToValues b
987 gProductToValues (a :*: b) = gProductToValues a `append` gProductToValues b
988+ {-# INLINE gProductToValues #-}
978instance (GToJSON a) => GProductToValues a where
990instance (GToJSON a) => GProductToValues a where
979 gProductToValues = singleton . gToJSON
991 gProductToValues = singleton . gToJSON
992+ {-# INLINE gProductToValues #-}
981--------------------------------------------------------------------------------
994--------------------------------------------------------------------------------
@@ -986,9 +999,11 @@ class GObject f where
986instance (GObject a, GObject b) => GObject (a :+: b) where
999instance (GObject a, GObject b) => GObject (a :+: b) where
987 gObject (L1 x) = gObject x
1000 gObject (L1 x) = gObject x
988 gObject (R1 x) = gObject x
1001 gObject (R1 x) = gObject x
1002+ {-# INLINE gObject #-}
990instance (Constructor c, GToJSON a, ConsToJSON a) => GObject (C1 c a) where
1004instance (Constructor c, GToJSON a, ConsToJSON a) => GObject (C1 c a) where
991 gObject m1 = M.singleton (pack (conName m1)) (gToJSON m1)
1005 gObject m1 = M.singleton (pack (conName m1)) (gToJSON m1)
1006+ {-# INLINE gObject #-}
993--------------------------------------------------------------------------------
1008--------------------------------------------------------------------------------
994-- Generic parseJSON
1009-- Generic parseJSON
@@ -998,25 +1013,31 @@ class GFromJSON f where
999instance (GFromJSON a) => GFromJSON (M1 i c a) where
1014instance (GFromJSON a) => GFromJSON (M1 i c a) where
1000 gParseJSON = fmap M1 . gParseJSON
1015 gParseJSON = fmap M1 . gParseJSON
1016+ {-# INLINE gParseJSON #-}
1002instance (FromJSON a) => GFromJSON (K1 i a) where
1018instance (FromJSON a) => GFromJSON (K1 i a) where
1003 gParseJSON = fmap K1 . parseJSON
1019 gParseJSON = fmap K1 . parseJSON
1020+ {-# INLINE gParseJSON #-}
1005instance GFromJSON U1 where
1022instance GFromJSON U1 where
1006 gParseJSON v
1023 gParseJSON v
1007 | isEmptyArray v = pure U1
1024 | isEmptyArray v = pure U1
1008 | otherwise = typeMismatch "unit constructor (U1)" v
1025 | otherwise = typeMismatch "unit constructor (U1)" v
1026+ {-# INLINE gParseJSON #-}
1010instance (ConsFromJSON a) => GFromJSON (C1 c a) where
1028instance (ConsFromJSON a) => GFromJSON (C1 c a) where
1011 gParseJSON = fmap M1 . consParseJSON
1029 gParseJSON = fmap M1 . consParseJSON
1030+ {-# INLINE gParseJSON #-}
1013instance (GFromProduct a, GFromProduct b) => GFromJSON (a :*: b) where
1032instance (GFromProduct a, GFromProduct b) => GFromJSON (a :*: b) where
1014 gParseJSON (Array arr) = gParseProduct arr
1033 gParseJSON (Array arr) = gParseProduct arr
1015 gParseJSON v = typeMismatch "product (:*:)" v
1034 gParseJSON v = typeMismatch "product (:*:)" v
1035+ {-# INLINE gParseJSON #-}
1017instance (GFromSum a, GFromSum b) => GFromJSON (a :+: b) where
1037instance (GFromSum a, GFromSum b) => GFromJSON (a :+: b) where
1018 gParseJSON (Object (M.toList -> [keyVal])) = gParseSum keyVal
1038 gParseJSON (Object (M.toList -> [keyVal])) = gParseSum keyVal
1019 gParseJSON v = typeMismatch "sum (:+:)" v
1039 gParseJSON v = typeMismatch "sum (:+:)" v
1040+ {-# INLINE gParseJSON #-}
1021--------------------------------------------------------------------------------
1042--------------------------------------------------------------------------------
@@ -1025,15 +1046,18 @@ class ConsFromJSON' b f where consParseJSON' :: Tagged b (Value -> Parser (f a))
1026instance (IsRecord f b, ConsFromJSON' b f) => ConsFromJSON f where
1047instance (IsRecord f b, ConsFromJSON' b f) => ConsFromJSON f where
1027 consParseJSON = unTagged (consParseJSON' :: Tagged b (Value -> Parser (f a)))
1048 consParseJSON = unTagged (consParseJSON' :: Tagged b (Value -> Parser (f a)))
1049+ {-# INLINE consParseJSON #-}
1029instance (GFromRecord f) => ConsFromJSON' True f where
1051instance (GFromRecord f) => ConsFromJSON' True f where
1030 consParseJSON' = Tagged parseRecord
1052 consParseJSON' = Tagged parseRecord
1032 parseRecord (Object obj) = gParseRecord obj
1054 parseRecord (Object obj) = gParseRecord obj
1033 parseRecord v = typeMismatch "record (:*:)" v
1055 parseRecord v = typeMismatch "record (:*:)" v
1056+ {-# INLINE consParseJSON' #-}
1035instance (GFromJSON f) => ConsFromJSON' False f where
1058instance (GFromJSON f) => ConsFromJSON' False f where
1036 consParseJSON' = Tagged gParseJSON
1059 consParseJSON' = Tagged gParseJSON
1060+ {-# INLINE consParseJSON' #-}
1038--------------------------------------------------------------------------------
1062--------------------------------------------------------------------------------
@@ -1042,6 +1066,7 @@ class GFromRecord f where
1043instance (GFromRecord a, GFromRecord b) => GFromRecord (a :*: b) where
1067instance (GFromRecord a, GFromRecord b) => GFromRecord (a :*: b) where
1044 gParseRecord obj = (:*:) <$> gParseRecord obj <*> gParseRecord obj
1068 gParseRecord obj = (:*:) <$> gParseRecord obj <*> gParseRecord obj
1069+ {-# INLINE gParseRecord #-}
1046instance (Selector s, GFromJSON a) => GFromRecord (S1 s a) where
1071instance (Selector s, GFromJSON a) => GFromRecord (S1 s a) where
1047 gParseRecord obj = case M.lookup (T.pack key) obj of
1072 gParseRecord obj = case M.lookup (T.pack key) obj of
@@ -1049,6 +1074,7 @@ instance (Selector s, GFromJSON a) => GFromRecord (S1 s a) where
1049 Just v -> gParseJSON v
1074 Just v -> gParseJSON v
1051 key = selName (undefined :: t s a p)
1076 key = selName (undefined :: t s a p)
1077+ {-# INLINE gParseRecord #-}
1053--------------------------------------------------------------------------------
1079--------------------------------------------------------------------------------
@@ -1059,10 +1085,12 @@ instance (GFromProduct a, GFromProduct b) => GFromProduct (a :*: b) where
1059 gParseProduct arr = (:*:) <$> gParseProduct arrL <*> gParseProduct arrR
1085 gParseProduct arr = (:*:) <$> gParseProduct arrL <*> gParseProduct arrR
1061 (arrL, arrR) = V.splitAt (V.length arr `div` 2) arr
1087 (arrL, arrR) = V.splitAt (V.length arr `div` 2) arr
1088+ {-# INLINE gParseProduct #-}
1063instance (GFromJSON a) => GFromProduct a where
1090instance (GFromJSON a) => GFromProduct a where
1064 gParseProduct ((!? 0) -> Just v) = gParseJSON v
1091 gParseProduct ((!? 0) -> Just v) = gParseJSON v
1065 gParseProduct _ = fail "Array to small"
1092 gParseProduct _ = fail "Array to small"
1093+ {-# INLINE gParseProduct #-}
1067--------------------------------------------------------------------------------
1095--------------------------------------------------------------------------------
@@ -1071,11 +1099,13 @@ class GFromSum f where
1072instance (GFromSum a, GFromSum b) => GFromSum (a :+: b) where
1100instance (GFromSum a, GFromSum b) => GFromSum (a :+: b) where
1073 gParseSum keyVal = (L1 <$> gParseSum keyVal) <|> (R1 <$> gParseSum keyVal)
1101 gParseSum keyVal = (L1 <$> gParseSum keyVal) <|> (R1 <$> gParseSum keyVal)
1102+ {-# INLINE gParseSum #-}
1075instance (Constructor c, GFromJSON a, ConsFromJSON a) => GFromSum (C1 c a) where
1104instance (Constructor c, GFromJSON a, ConsFromJSON a) => GFromSum (C1 c a) where
1076 gParseSum (key, value)
1105 gParseSum (key, value)
1077 | key == pack (conName (undefined :: t c a p)) = gParseJSON value
1106 | key == pack (conName (undefined :: t c a p)) = gParseJSON value
1078 | otherwise = notFound $ unpack key
1107 | otherwise = notFound $ unpack key
1108+ {-# INLINE gParseSum #-}
1080notFound :: String -> Parser a
1110notFound :: String -> Parser a
1081notFound key = fail $ "The key \"" ++ key ++ "\" was not found"
1111notFound key = fail $ "The key \"" ++ key ++ "\" was not found"
@@ -1101,12 +1131,15 @@ type DList a = [a] -> [a]
1102toList :: DList a -> [a]
1132toList :: DList a -> [a]
1103toList = ($ [])
1133toList = ($ [])
1134+{-# INLINE toList #-}
1105singleton :: a -> DList a
1136singleton :: a -> DList a
1106singleton = (:)
1137singleton = (:)
1138+{-# INLINE singleton #-}
1108append :: DList a -> DList a -> DList a
1140append :: DList a -> DList a -> DList a
1109append = (.)
1141append = (.)
1142+{-# INLINE append #-}
1111--------------------------------------------------------------------------------
1144--------------------------------------------------------------------------------