registry 0.1.7.0 → 0.1.7.1
raw patch · 12 files changed
+25/−32 lines, 12 filesdep ~hashabledep ~semigroupsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hashable, semigroups
API changes (from Hackage documentation)
- Data.Registry.Lift: class CNumArgs (numArgs :: Nat) (arrows :: *)
+ Data.Registry.Lift: class CNumArgs (numArgs :: Nat) (arrows :: Type)
- Data.Registry.Lift: data NumArgs :: Nat -> * -> *
+ Data.Registry.Lift: data NumArgs :: Nat -> Type -> Type
- Data.Registry.Lift: type family Apply (f :: * -> *) (n :: Nat) (arrows :: *) :: *
+ Data.Registry.Lift: type family Apply (f :: Type -> Type) (n :: Nat) (arrows :: Type) :: Type
- Data.Registry.Registry: class PathToTypeReps (path :: [*])
+ Data.Registry.Registry: class PathToTypeReps (path :: [Type])
- Data.Registry.Registry: data Registry (inputs :: [*]) (outputs :: [*])
+ Data.Registry.Registry: data Registry (inputs :: [Type]) (outputs :: [Type])
- Data.Registry.Registry: newtype MemoizeRegistry (todo :: [*]) (ins :: [*]) (out :: [*])
+ Data.Registry.Registry: newtype MemoizeRegistry (todo :: [Type]) (ins :: [Type]) (out :: [Type])
- Data.Registry.Solver: class IsSubset (ins :: [*]) (out :: [*])
+ Data.Registry.Solver: class IsSubset (ins :: [Type]) (out :: [Type])
- Data.Registry.Solver: class Solvable (ins :: [*]) (out :: [*])
+ Data.Registry.Solver: class Solvable (ins :: [Type]) (out :: [Type])
- Data.Registry.Solver: type family Normalized (as :: [*]) :: [*]
+ Data.Registry.Solver: type family Normalized (as :: [Type]) :: [Type]
Files
- registry.cabal +6/−6
- src/Data/Registry/Internal/Cache.hs +0/−1
- src/Data/Registry/Internal/Make.hs +0/−1
- src/Data/Registry/Internal/Reflection.hs +1/−2
- src/Data/Registry/Lift.hs +4/−4
- src/Data/Registry/Make.hs +0/−1
- src/Data/Registry/Registry.hs +3/−5
- src/Data/Registry/Solver.hs +7/−7
- test/Test/Data/Registry/SmallExample.hs +0/−1
- test/Test/Tutorial/Application.hs +0/−1
- test/Test/Tutorial/Exercise5.hs +1/−2
- test/Test/Tutorial/Exercise8.hs +3/−1
registry.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: fcba2812a0ecc52110acade5e9fed0482c1c6ea5b50047c57cb08713dc4c9a42+-- hash: 4b8f95b17c048f77ecc40758d76c80db69f8e112fbc915ca1e9dc61da09a464d name: registry-version: 0.1.7.0+version: 0.1.7.1 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.@@ -53,7 +53,7 @@ base >=4.7 && <5 , containers >=0.5 && <0.7 , exceptions >=0.8 && <0.11- , hashable >=1.2 && <1.3+ , hashable >=1.2 && <1.4 , mmorph >=1.0 && <2 , mtl >=2.0 && <3 , protolude >=0.2 && <0.3@@ -115,7 +115,7 @@ , directory <1.4 , exceptions >=0.8 && <0.11 , generic-lens <2- , hashable >=1.2 && <1.3+ , hashable >=1.2 && <1.4 , hedgehog >=1.0 && <2.0 , io-memoize <1.2 , mmorph >=1.0 && <2@@ -126,7 +126,7 @@ , registry , resourcet >=1.1 && <1.3 , semigroupoids >=5.0 && <5.4- , semigroups <0.19+ , semigroups <0.20 , tasty <1.3 , tasty-discover <4.3 , tasty-hedgehog >=1.0 && <1.1
src/Data/Registry/Internal/Cache.hs view
@@ -10,7 +10,6 @@ import Data.Map.Strict import Data.Registry.Internal.Types (SpecializationPath)-import Data.Typeable (Typeable) import Protolude as P -- | A thread-safe write-once cache. If you need more functionality,
src/Data/Registry/Internal/Make.hs view
@@ -21,7 +21,6 @@ import Data.Registry.Internal.Registry import Data.Registry.Internal.Stack import Data.Registry.Internal.Types-import Data.Text as T (unlines) import qualified Data.Text as T import Protolude as P hiding (Constructor) import Type.Reflection
src/Data/Registry/Internal/Reflection.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeInType #-} @@ -10,7 +9,7 @@ import Data.Semigroup import Data.Text as T-import Data.Typeable (tyConModule, tyConName, splitTyConApp)+import Data.Typeable (splitTyConApp) import Protolude as P hiding (intercalate, TypeRep, isPrefixOf, (<>)) import Type.Reflection import GHC.Exts
src/Data/Registry/Lift.hs view
@@ -78,15 +78,15 @@ -- It uses an auxiliary typeclass to count the arguments of a function data Nat = Z | S Nat -data NumArgs :: Nat -> * -> * where+data NumArgs :: Nat -> Type -> Type where NAZ :: NumArgs Z a NAS :: NumArgs n b -> NumArgs (S n) (a -> b) -type family CountArgs (f :: *) :: Nat where+type family CountArgs (f :: Type) :: Nat where CountArgs (a -> b) = S (CountArgs b) CountArgs result = Z -class CNumArgs (numArgs :: Nat) (arrows :: *) where+class CNumArgs (numArgs :: Nat) (arrows :: Type) where getNA :: NumArgs numArgs arrows instance CNumArgs Z a where@@ -95,7 +95,7 @@ instance CNumArgs n b => CNumArgs (S n) (a -> b) where getNA = NAS getNA -type family Apply (f :: * -> *) (n :: Nat) (arrows :: *) :: * where+type family Apply (f :: Type -> Type) (n :: Nat) (arrows :: Type) :: Type where Apply f (S n) (a -> b) = a -> Apply f n b Apply f Z a = f a
src/Data/Registry/Make.hs view
@@ -34,7 +34,6 @@ import Data.Registry.Internal.Types import Data.Registry.Registry import Data.Registry.Solver-import Data.Typeable (Typeable) import qualified Prelude (error) import Protolude as P hiding (Constructor) import Type.Reflection
src/Data/Registry/Registry.hs view
@@ -45,8 +45,6 @@ import Data.Registry.Solver import Data.Dynamic import Data.Semigroup ((<>))-import Data.Text as T (unlines)-import Data.Typeable (Typeable) import qualified Prelude (show) import Protolude as P hiding ((<>)) import Type.Reflection@@ -54,7 +52,7 @@ -- | Container for a list of functions or values -- Internally all functions and values are stored as 'Dynamic' values -- so that we can access their representation-data Registry (inputs :: [*]) (outputs :: [*]) =+data Registry (inputs :: [Type]) (outputs :: [Type]) = Registry { _values :: Values , _functions :: Functions@@ -271,7 +269,7 @@ modifiers -- | Typeclass for extracting type representations out of a list of types-class PathToTypeReps (path :: [*]) where+class PathToTypeReps (path :: [Type]) where someTypeReps :: Proxy path -> NonEmpty SomeTypeRep instance {-# OVERLAPPING #-} (Typeable a) => PathToTypeReps '[a] where@@ -329,7 +327,7 @@ memoizeAll r = _unMemoizeRegistry <$> memoizeActions (startMemoizeRegistry r) -newtype MemoizeRegistry (todo :: [*]) (ins :: [*]) (out :: [*]) = MemoizeRegistry { _unMemoizeRegistry :: Registry ins out }+newtype MemoizeRegistry (todo :: [Type]) (ins :: [Type]) (out :: [Type]) = MemoizeRegistry { _unMemoizeRegistry :: Registry ins out } startMemoizeRegistry :: Registry ins out -> MemoizeRegistry out ins out startMemoizeRegistry = MemoizeRegistry
src/Data/Registry/Solver.hs view
@@ -18,17 +18,17 @@ import GHC.TypeLits -- | Compute the list of input types for a function-type family Inputs f :: [*] where+type family Inputs f :: [Type] where Inputs (i -> o) = i ': Inputs o Inputs x = '[] -- | Compute the output type for a function-type family Output f :: * where+type family Output f :: Type where Output (i -> o) = Output o Output x = x -- | Compute if a type is contained in a list of types-type family Contains (a :: *) (els :: [*]) :: Constraint where+type family Contains (a :: Type) (els :: [Type]) :: Constraint where Contains a '[] = TypeError (Text "No element of type " ':<>: 'ShowType a ':<>: 'Text " can be built out of the registry") Contains a (a ': els) = () Contains a (b ': els) = Contains a els@@ -38,13 +38,13 @@ -- | Compute if each element of a list of types is contained in -- another list-class IsSubset (ins :: [*]) (out :: [*])+class IsSubset (ins :: [Type]) (out :: [Type]) instance IsSubset '[] out instance (Contains a out, IsSubset els out) => IsSubset (a ': els) out -- | From the list of all the input types and outputs types of a registry -- Can we create all the output types?-class Solvable (ins :: [*]) (out :: [*])+class Solvable (ins :: [Type]) (out :: [Type]) instance (IsSubset ins out) => Solvable ins out @@ -57,12 +57,12 @@ (x ': xs) :++ ys = x ': (xs :++ ys) -- | Return '[a] only if it is not already in the list of types-type family FindUnique (a :: *) (as :: [*]) :: [*] where+type family FindUnique (a :: Type) (as :: [Type]) :: [Type] where FindUnique a '[] = '[a] FindUnique a (a ': rest) = '[] FindUnique a (b ': rest) = FindUnique a rest -type family Normalized (as :: [*]) :: [*] where+type family Normalized (as :: [Type]) :: [Type] where Normalized '[] = '[] Normalized '[a] = '[a] Normalized (a ': rest) = FindUnique a rest :++ Normalized rest
test/Test/Data/Registry/SmallExample.hs view
@@ -11,7 +11,6 @@ import Data.Registry import Data.Text (splitOn)-import Data.Typeable (Typeable) import Protolude as P import Test.Tasty.Extensions hiding (run)
test/Test/Tutorial/Application.hs view
@@ -3,7 +3,6 @@ module Test.Tutorial.Application where import qualified Data.ByteString.Char8 as BS8-import Data.Text.Encoding (decodeUtf8) import Protolude import System.Directory (doesFileExist) import System.Random
test/Test/Tutorial/Exercise5.hs view
@@ -6,7 +6,6 @@ import qualified Data.ByteString.Char8 as BS8 import Data.Registry-import Data.Text.Encoding (decodeUtf8) import Protolude import System.Directory (doesFileExist) import Test.Tutorial.Application@@ -16,7 +15,7 @@ exists <- doesFileExist (toS path) if not exists then fileDoesNotExist else pure () pure SecretReader {- readSecret = do+ readSecret = if exists then Just . decodeUtf8 <$> BS8.readFile (toS path) else fileDoesNotExist $> Nothing }
test/Test/Tutorial/Exercise8.hs view
@@ -21,8 +21,10 @@ $(return []) +{- -- this does not compile--- checkedIncorrectRegistry = $(checkRegistry 'incorrectRegistry)+checkedIncorrectRegistry = $(checkRegistry 'incorrectRegistry)+-} newErasedApp :: App newErasedApp = makeUnsafe @App erasedRegistry