constraints-extras 0.2.3.3 → 0.2.3.4
raw patch · 3 files changed
+14/−11 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- ChangeLog.md +6/−0
- constraints-extras.cabal +2/−1
- src/Data/Constraint/Extras/TH.hs +6/−10
+ ChangeLog.md view
@@ -0,0 +1,6 @@+# Revision history for constraints-extras++## 0.2.3.4 - 2019-03-22++* Added ChangeLog.md+* Replaced some occurrences of <> in Data.Constraint.Extras.TH with ++ so that the module will hopefully build with GHC 8.0.2 and 8.2.2 without needing to import Data.Semigroup.
constraints-extras.cabal view
@@ -1,5 +1,5 @@ name: constraints-extras-version: 0.2.3.3+version: 0.2.3.4 synopsis: Utility package for constraints description: Convenience functions and TH for working with constraints. See <https://github.com/obsidiansystems/constraints-extras/blob/develop/README.md README.md> for example usage. category: Constraints@@ -11,6 +11,7 @@ build-type: Simple cabal-version: >=2.0 extra-source-files: README.md+ ChangeLog.md library exposed-modules: Data.Constraint.Extras
src/Data/Constraint/Extras/TH.hs view
@@ -4,24 +4,20 @@ module Data.Constraint.Extras.TH (deriveArgDict, deriveArgDictV, gadtIndices) where import Data.Constraint.Extras-import Control.Monad import Data.Constraint+import Data.Either import Data.Maybe+import Control.Monad import Language.Haskell.TH -import Data.Either deriveArgDict :: Name -> Q [Dec] deriveArgDict n = do ts <- gadtIndices n c <- newName "c"- g <- newName "g" let xs = flip map ts $ \case Left t -> AppT (AppT (ConT ''ConstraintsFor) t) (VarT c) Right t -> (AppT (VarT c) t)- xs' = flip map ts $ \case- Left t -> AppT (AppT (AppT (ConT ''ConstraintsFor') t) (VarT c)) (VarT g)- Right t -> AppT (VarT c) (AppT (VarT g) t) l = length xs constraints = foldl AppT (TupleT l) xs arity <- tyConArity n@@ -62,8 +58,8 @@ in [Match (ConP name pat) (NormalB $ AppE (VarE argDictName) (VarE v)) []] ForallC _ _ (GadtC [name] _ _) -> return $ [Match (RecP name []) (NormalB $ ConE 'Dict) []]- a -> error $ "deriveArgDict matches: Unmatched 'Dec': " <> show a- a -> error $ "deriveArgDict matches: Unmatched 'Info': " <> show a+ a -> error $ "deriveArgDict matches: Unmatched 'Dec': " ++ show a+ a -> error $ "deriveArgDict matches: Unmatched 'Info': " ++ show a kindArity :: Kind -> Int kindArity = \case@@ -76,7 +72,7 @@ tyConArity :: Name -> Q Int tyConArity n = reify n >>= return . \case TyConI (DataD _ _ ts mk _ _) -> fromMaybe 0 (fmap kindArity mk) + length ts- _ -> error $ "tyConArity: Supplied name reified to something other than a data declaration: " <> show n+ _ -> error $ "tyConArity: Supplied name reified to something other than a data declaration: " ++ show n gadtIndices :: Name -> Q [Either Type Type] gadtIndices n = reify n >>= \case@@ -89,4 +85,4 @@ _ -> return [] ForallC _ _ (GadtC _ _ (AppT _ typ)) -> return [Right typ] _ -> return []- a -> error $ "gadtResults: Unmatched 'Info': " <> show a+ a -> error $ "gadtResults: Unmatched 'Info': " ++ show a