basvandijk avatar basvandijk committed 66c686d

Use the dlist package instead of using our own DList type

Comments (0)

Files changed (2)

Data/Aeson/Types/Generic.hs

 import Data.Aeson.Types.Class
 import Data.Aeson.Types.Internal
 import Data.Text (pack, unpack)
+import Data.DList (DList, toList)
+import Data.Monoid (mappend)
 import GHC.Generics
 import qualified Data.HashMap.Strict as H
 import qualified Data.Text as T
     gRecordToPairs :: f a -> DList Pair
 
 instance (GRecordToPairs a, GRecordToPairs b) => GRecordToPairs (a :*: b) where
-    gRecordToPairs (a :*: b) = gRecordToPairs a `append` gRecordToPairs b
+    gRecordToPairs (a :*: b) = gRecordToPairs a `mappend` gRecordToPairs b
     {-# INLINE gRecordToPairs #-}
 
 instance (Selector s, GToJSON a) => GRecordToPairs (S1 s a) where
-    gRecordToPairs m1 = singleton (pack (selName m1), gToJSON (unM1 m1))
+    gRecordToPairs m1 = pure (pack (selName m1), gToJSON (unM1 m1))
     {-# INLINE gRecordToPairs #-}
 
 --------------------------------------------------------------------------------
     gProductToValues :: f a -> DList Value
 
 instance (GProductToValues a, GProductToValues b) => GProductToValues (a :*: b) where
-    gProductToValues (a :*: b) = gProductToValues a `append` gProductToValues b
+    gProductToValues (a :*: b) = gProductToValues a `mappend` gProductToValues b
     {-# INLINE gProductToValues #-}
 
 instance (GToJSON a) => GProductToValues a where
-    gProductToValues = singleton . gToJSON
+    gProductToValues = pure . gToJSON
     {-# INLINE gProductToValues #-}
 
 --------------------------------------------------------------------------------
 instance IsRecord U1 False
 
 --------------------------------------------------------------------------------
-
-type DList a = [a] -> [a]
-
-toList :: DList a -> [a]
-toList = ($ [])
-{-# INLINE toList #-}
-
-singleton :: a -> DList a
-singleton = (:)
-{-# INLINE singleton #-}
-
-append :: DList a -> DList a -> DList a
-append = (.)
-{-# INLINE append #-}
-
---------------------------------------------------------------------------------
 
   if impl(ghc >= 7.2.1)
     cpp-options: -DGENERICS
-    build-depends: ghc-prim >= 0.2
+    build-depends: ghc-prim >= 0.2, dlist >= 0.2
     other-modules:
       Data.Aeson.Types.Generic
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.