registry 0.3.0.3 → 0.3.0.4
raw patch · 5 files changed
+31/−28 lines, 5 filesdep ~basedep ~tasty-hedgehog
Dependency ranges changed: base, tasty-hedgehog
Files
- registry.cabal +5/−5
- src/Data/Registry/Internal/Reflection.hs +1/−6
- src/Data/Registry/TH.hs +11/−0
- test/Test/Data/Registry/Internal/TypesSpec.hs +8/−13
- test/Test/Tasty/Extensions.hs +6/−4
registry.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: caf52cc0099401e13a94d7a23616a310eec3c3e030a0334cd374a74f75693fea+-- hash: 1a8c9c072c763ae2ddd435d72d7da1fbaab8c70197bf52bc957716c0f1a5b132 name: registry-version: 0.3.0.3+version: 0.3.0.4 synopsis: data structure for assembling components description: This library provides a "Registry" which is a data structure containing a list of functions and values representing dependencies in a directed acyclic graph. A `make` function can then be used to create a value of a specific type out of the registry. You can start with the [README](https://github.com/etorreborre/registry/blob/master/README.md) for a full description of the library.@@ -79,7 +79,7 @@ TypeOperators ghc-options: -Wall -Wcompat -Wincomplete-record-updates -fhide-source-paths -fprint-potential-instances -optP-Wno-nonportable-include-path -Wincomplete-uni-patterns build-depends:- base >=4.7 && <5+ base >=4.14 && <5 , containers >=0.5 && <0.7 , exceptions >=0.8 && <0.11 , hashable >=1.2 && <1.5@@ -164,7 +164,7 @@ build-depends: MonadRandom <0.6 , async <2.3- , base >=4.7 && <5+ , base >=4.14 && <5 , bytestring <0.12 , containers >=0.5 && <0.7 , directory <1.4@@ -184,7 +184,7 @@ , semigroups <0.30 , tasty <1.5 , tasty-discover <4.3- , tasty-hedgehog >=1.0 && <2.0+ , tasty-hedgehog >=1.2 && <2.0 , tasty-th <0.2 , template-haskell >=2.13 && <3.0 , text <2
src/Data/Registry/Internal/Reflection.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeInType #-} @@ -9,11 +8,7 @@ import Data.Semigroup import Data.Text as T import Data.Typeable (splitTyConApp)-#if MIN_VERSION_GLASGOW_HASKELL(8,10,1,0)-import Protolude as P hiding (intercalate, TypeRep, isPrefixOf, (<>), typeOf)-#else-import Protolude as P hiding (intercalate, TypeRep, isPrefixOf, (<>))-#endif+import Protolude as P hiding (intercalate, TypeRep, isPrefixOf, (<>)) import GHC.Exts import Type.Reflection as Reflection
src/Data/Registry/TH.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Data.Registry.TH ( TypeclassOptions, makeTypeclass,@@ -62,7 +63,11 @@ qReport True ("can only generate a typeclass for a record of functions, got: " <> show other) pure [] +#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0) createTypeclass :: (Text -> Text) -> (Text -> Text) -> Name -> [TyVarBndr ()] -> [VarBangType] -> [Dec]+#else+createTypeclass :: (Text -> Text) -> (Text -> Text) -> Name -> [TyVarBndr] -> [VarBangType] -> [Dec]+#endif createTypeclass typeclassNameMaker functionNameMaker name typeVars types = let typeclassName = modifyName typeclassNameMaker (dropQualified name) functions = fmap (makeFunctionDeclaration functionNameMaker) types@@ -70,9 +75,15 @@ -- | Create an instance definition using a ReaderT instance -- instance WithLogger (ReaderT (Logger m) m) where ...+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0) createReadertInstance :: (Text -> Text) -> (Text -> Text) -> Name -> [TyVarBndr ()] -> [VarBangType] -> DecsQ createReadertInstance typeclassNameMaker functionNameMaker name [tvar] types = let tvarName = case tvar of PlainTV v _ -> v; KindedTV v _ _ -> v+#else+createReadertInstance :: (Text -> Text) -> (Text -> Text) -> Name -> [TyVarBndr] -> [VarBangType] -> DecsQ+createReadertInstance typeclassNameMaker functionNameMaker name [tvar] types =+ let tvarName = case tvar of PlainTV v -> v; KindedTV v _ -> v+#endif typeclassName = modifyName typeclassNameMaker (dropQualified name) functions = fmap (makeFunctionInstance functionNameMaker (mkName "ReaderT")) types typeclassT = ConT typeclassName
test/Test/Data/Registry/Internal/TypesSpec.hs view
@@ -1,18 +1,13 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-} module Test.Data.Registry.Internal.TypesSpec where import Data.List.NonEmpty import Data.Registry.Internal.Types-#if MIN_VERSION_GLASGOW_HASKELL(8,10,1,0)-import Protolude as P hiding (typeOf)-#else-import Protolude as P-#endif+import qualified Type.Reflection as R+import Protolude as P import Test.Tasty.Extensions-import Type.Reflection test_specialized_context_order = prop "there are preferrable specializations than other in a given context" $ do let c1 = Context (fmap (\t -> (t, Nothing)) $ [f, e, d, c, b, a])@@ -44,14 +39,14 @@ data F = F deriving (Eq, Show) -a = someTypeRep $ typeOf A+a = R.someTypeRep $ R.typeOf A -b = someTypeRep $ typeOf B+b = R.someTypeRep $ R.typeOf B -c = someTypeRep $ typeOf C+c = R.someTypeRep $ R.typeOf C -d = someTypeRep $ typeOf D+d = R.someTypeRep $ R.typeOf D -e = someTypeRep $ typeOf E+e = R.someTypeRep $ R.typeOf E -f = someTypeRep $ typeOf F+f = R.someTypeRep $ R.typeOf F
test/Test/Tasty/Extensions.hs view
@@ -29,8 +29,9 @@ import Data.MultiMap import GHC.Stack-import Hedgehog as Hedgehog hiding (test)+import Hedgehog hiding (test) import Hedgehog.Gen as Hedgehog hiding (discard, print)+import Hedgehog.Internal.Property (PropertyName (..)) import Protolude hiding (empty, toList, (.&.)) import System.Environment import Test.Tasty as Tasty@@ -38,14 +39,15 @@ import Test.Tasty.Options as Tasty import Test.Tasty.Providers as Tasty (singleTest) import Test.Tasty.Runners as Tasty (TestTree (..), foldSingle, foldTestTree, trivialFold)-import qualified Prelude as Prelude+import qualified Prelude -- | Create a Tasty test from a Hedgehog property prop :: HasCallStack => TestName -> PropertyT IO () -> TestTree prop name p = let aModuleName = getModuleName- in withFrozenCallStack $ localOption (ModuleName (toS aModuleName)) $- testProperty name (Hedgehog.property p)+ in withFrozenCallStack $+ localOption (ModuleName (toS aModuleName)) $+ testPropertyNamed name (PropertyName name) (Hedgehog.property p) -- | Create a Tasty test from a Hedgehog property called only once test :: HasCallStack => TestName -> PropertyT IO () -> TestTree