X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FOrphanInstances.hs;h=333e162cdf5075bb1230059ddc723c13d5bb927a;hp=47db98b7dee176f73da96f3ac9e79556c53fdc0f;hb=b7d905bb9034a4f21fa3889e83abff918c43cb58;hpb=9be2b946657c536a4363a076235f70728be087c4 diff --git a/Network/HTTP/Lucu/OrphanInstances.hs b/Network/HTTP/Lucu/OrphanInstances.hs index 47db98b..333e162 100644 --- a/Network/HTTP/Lucu/OrphanInstances.hs +++ b/Network/HTTP/Lucu/OrphanInstances.hs @@ -1,10 +1,9 @@ {-# LANGUAGE FlexibleContexts , FlexibleInstances - , OverlappingInstances , RecordWildCards + , ScopedTypeVariables , TemplateHaskell - , UndecidableInstances , UnicodeSyntax #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -22,6 +21,7 @@ import Data.CaseInsensitive (CI, FoldCase) import qualified Data.CaseInsensitive as CI import Data.Collections import Data.Collections.BaseInstances () +import qualified Data.Map as M import Data.Ratio import Data.Text (Text) import qualified Data.Text as T @@ -49,12 +49,15 @@ instance (Lift s, FoldCase s) ⇒ Lift (CI s) where instance Lift Text where lift t = [| T.pack $(litE ∘ stringL $ T.unpack t) |] -instance (Lift k, Lift v, Collection c (k, v)) ⇒ Lift c where - lift c - | null c = [| empty |] - | otherwise = [| fromList $(liftPairs (fromFoldable c)) |] +instance (Lift k, Lift v) ⇒ Lift (M.Map k v) where + lift m + | null m = [| empty |] + | otherwise = [| fromAscList $(liftPairs (M.toAscList m)) |] where - liftPairs = listE ∘ (liftPair <$>) + liftPairs ∷ [(k, v)] → Q Exp + liftPairs = listE ∘ (liftPair <$>) + + liftPair ∷ (k, v) → Q Exp liftPair (k, v) = tupE [lift k, lift v] instance Lift UTCTime where