on master help sign in
Use the dlist package instead of using our own DList type
commit7b87363cd7f56264673b821a9f4e8c51b49c2541 authorBas van Dijk <v.dijk.bas@gmail.com> dateWed 23 Nov 2011, 16:23 (15 years ago) parent464e34c
2 files changed+7−21
Data/Aeson/Types/Generic.hs+6−20 aeson.cabal+1−1
Data/Aeson/Types/Generic.hs+6−20
@@ -30,6 +30,8 @@ import Data.Bits (shiftR)
3030import Data.Aeson.Types.Class
3131import Data.Aeson.Types.Internal
3232import Data.Text (pack, unpack)
33+import Data.DList (DList, toList)
34+import Data.Monoid (mappend)
3335import GHC.Generics
3436import qualified Data.HashMap.Strict as H
3537import qualified Data.Text as T
@@ -88,11 +90,11 @@ class GRecordToPairs f where
8890 gRecordToPairs :: f a -> DList Pair
8991
9092instance (GRecordToPairs a, GRecordToPairs b) => GRecordToPairs (a :*: b) where
91− gRecordToPairs (a :*: b) = gRecordToPairs a `append` gRecordToPairs b
93+ gRecordToPairs (a :*: b) = gRecordToPairs a `mappend` gRecordToPairs b
9294 {-# INLINE gRecordToPairs #-}
9395
9496instance (Selector s, GToJSON a) => GRecordToPairs (S1 s a) where
95− gRecordToPairs m1 = singleton (pack (selName m1), gToJSON (unM1 m1))
97+ gRecordToPairs m1 = pure (pack (selName m1), gToJSON (unM1 m1))
9698 {-# INLINE gRecordToPairs #-}
9799
98100--------------------------------------------------------------------------------
@@ -101,11 +103,11 @@ class GProductToValues f where
101103 gProductToValues :: f a -> DList Value
102104
103105instance (GProductToValues a, GProductToValues b) => GProductToValues (a :*: b) where
104− gProductToValues (a :*: b) = gProductToValues a `append` gProductToValues b
106+ gProductToValues (a :*: b) = gProductToValues a `mappend` gProductToValues b
105107 {-# INLINE gProductToValues #-}
106108
107109instance (GToJSON a) => GProductToValues a where
108− gProductToValues = singleton . gToJSON
110+ gProductToValues = pure . gToJSON
109111 {-# INLINE gProductToValues #-}
110112
111113--------------------------------------------------------------------------------
@@ -267,19 +269,3 @@ instance IsRecord (K1 i c) True
267269instance IsRecord U1 False
268270
269271--------------------------------------------------------------------------------
270−
271−type DList a = [a] -> [a]
272−
273−toList :: DList a -> [a]
274−toList = ($ [])
275−{-# INLINE toList #-}
276−
277−singleton :: a -> DList a
278−singleton = (:)
279−{-# INLINE singleton #-}
280−
281−append :: DList a -> DList a -> DList a
282−append = (.)
283−{-# INLINE append #-}
284−
285−--------------------------------------------------------------------------------
aeson.cabal+1−1
@@ -121,7 +121,7 @@ library
121121
122122 if impl(ghc >= 7.2.1)
123123 cpp-options: -DGENERICS
124− build-depends: ghc-prim >= 0.2
124+ build-depends: ghc-prim >= 0.2, dlist >= 0.2
125125 other-modules:
126126 Data.Aeson.Types.Generic
127127