)
where
import Control.Applicative hiding (empty)
+import Control.Arrow
import Control.Monad.Unicode
import Data.Collections
import Data.Collections.BaseInstances ()
= return (wrapperTy, deriveFoldable)
| classTy ≡ ''Collection
= return (wrapperTy, deriveCollection)
+ | classTy ≡ ''SortingCollection
+ = return (wrapperTy, deriveSortingCollection)
inspectInstance (AppT (AppT (AppT (ConT classTy) wrapperTy) _) _)
| classTy ≡ ''Indexed
= return (wrapperTy, deriveIndexed)
= [| (($wrap ∘) ∘) ∘ (∘ $unwrap) ∘ accum |]
| otherwise
= fail $ "deriveIndexed: unknown method: " ⧺ pprint name
+
+deriveSortingCollection ∷ Q Cxt → Q Type → Q Exp → Q Exp → Q Dec
+deriveSortingCollection c ty wrap unwrap
+ = do names ← methodNames ''SortingCollection
+ instanceD c ty $ concatMap (pointfreeMethod exp) names
+ where
+ exp ∷ Name → Q Exp
+ exp name
+ | name ≡ 'minView
+ = [| (second $wrap <$>) ∘ minView ∘ $unwrap |]
+ | otherwise
+ = fail $ "deriveSortingCollection: unknown method: " ⧺ pprint name
)
where
import Control.Applicative hiding (empty)
-import Control.Arrow
import Control.Monad hiding (mapM)
import Control.Monad.Unicode
import Data.Ascii (Ascii, CIAscii, AsciiBuilder)
instance Foldable MIMEParams (CIAscii, Text)
instance Collection MIMEParams (CIAscii, Text)
instance Indexed MIMEParams CIAscii Text
+ -- instance Map MIMEParams CIAscii Text
+ instance SortingCollection MIMEParams (CIAscii, Text)
|]
-- FIXME: auto-derive
isProperSubmapBy f (MIMEParams α) (MIMEParams β)
= isProperSubmapBy f α β
--- FIXME: auto-derive
-instance SortingCollection MIMEParams (CIAscii, Text) where
- {-# INLINE minView #-}
- minView (MIMEParams m) = second MIMEParams <$> minView m
-
-- |Convert MIME parameter values to an 'AsciiBuilder'.
printMIMEParams ∷ MIMEParams → AsciiBuilder
{-# INLINEABLE printMIMEParams #-}