th-reify-many 0.1.2 → 0.1.3
raw patch · 5 files changed
+56/−5 lines, 5 filesdep +th-reify-manydep ~basedep ~template-haskelldep ~th-expand-synssetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: th-reify-many
Dependency ranges changed: base, template-haskell, th-expand-syns
API changes (from Hackage documentation)
Files
- Setup.hs +1/−0
- src/Language/Haskell/TH/ReifyMany.hs +3/−3
- src/Language/Haskell/TH/ReifyMany/Internal.hs +11/−0
- tests/Main.hs +29/−0
- th-reify-many.cabal +12/−2
Setup.hs view
@@ -1,2 +1,3 @@ import Distribution.Simple+main :: IO () main = defaultMain
src/Language/Haskell/TH/ReifyMany.hs view
@@ -90,8 +90,8 @@ -- > return [] -- > ) reifyManyTyCons :: ((Name, Dec) -> Q (Bool, [Name]))- -> [Name]- -> Q [(Name, Info)]+ -> [Name]+ -> Q [(Name, Info)] reifyManyTyCons recurse = reifyMany recurse' where recurse' (name, TyConI dec) = recurse (name, dec)@@ -136,7 +136,7 @@ -- typeclass. -- -- FIXME: this code is disabled because "isInstance" doesn't do any--- recursive instance resolution. For exsample, it yields 'True' when+-- recursive instance resolution. For example, it yields 'True' when -- asked if the instance (Show [Int -> Int]) exists, since one exists -- for lists. {-
src/Language/Haskell/TH/ReifyMany/Internal.hs view
@@ -1,5 +1,9 @@+{-# LANGUAGE CPP #-} module Language.Haskell.TH.ReifyMany.Internal where +#if !(MIN_VERSION_template_haskell(2,7,0))+import Data.List (foldl')+#endif import Data.Maybe (catMaybes) import Language.Haskell.TH import Language.Haskell.TH.ExpandSyns (expandSyns)@@ -62,10 +66,17 @@ ClassI _ xs -> fmap catMaybes $ mapM convertDec xs _ -> fail $ "Error in getInstances: " ++ show clz ++ " isn't a class" where+#if MIN_VERSION_template_haskell(2,7,0) convertDec (InstanceD ctxt typ decs) = do typ' <- expandSyns typ return $ Just (TypeclassInstance ctxt typ' decs) convertDec _ = return Nothing+#else+ convertDec (ClassInstance _ _ ctxt _ typs) = do+ let typ = foldl' AppT (ConT clz) typs+ typ' <- expandSyns typ+ return $ Just (TypeclassInstance ctxt typ' [])+#endif -- | Returns the first 'TypeclassInstance' where 'instanceMatches' -- returns true.
+ tests/Main.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE MultiParamTypeClasses #-}++-- | The test works if it builds!+module Main where++import Control.Monad+import Language.Haskell.TH.ReifyMany++class C a b where+ method :: b -> a++data A = A B (Maybe B)++data B = B Int++-- Tests support of type synonym instances.+type B' = B++instance C B' Int where method _ = B 0++$(do ns <- reifyManyWithoutInstances ''C [''A] (const True)+ when (ns /= [''A, ''Maybe]) $ fail "Didn't get expected list of datatypes."+ return []+ )++main :: IO ()+main = putStrLn "worked!"
th-reify-many.cabal view
@@ -1,5 +1,5 @@ name: th-reify-many-version: 0.1.2+version: 0.1.3 synopsis: Recurseively reify template haskell datatype info description: @th-reify-many@ provides functions for recursively reifying top@@ -14,7 +14,7 @@ bug-reports: http://github.com/mgsloan/th-reify-many/issues category: Template Haskell stability: Experimental-cabal-version: >= 1.8+cabal-version: >= 1.10 build-type: Simple source-repository head type: git@@ -34,3 +34,13 @@ , safe , template-haskell >= 2.5.0.0 , th-expand-syns+ default-language: Haskell2010++test-suite test+ type: exitcode-stdio-1.0+ hs-source-dirs: tests+ main-is: Main.hs+ build-depends: base,+ th-reify-many,+ template-haskell+ default-language: Haskell2010