packages feed

registry 0.6.3.0 → 0.6.3.1

raw patch · 3 files changed

+90/−6 lines, 3 filesdep ~containersdep ~hashablePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: containers, hashable

API changes (from Hackage documentation)

Files

registry.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack  name:           registry-version:        0.6.3.0+version:        0.6.3.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.@@ -62,9 +62,9 @@   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.14 && <5-    , containers >=0.5 && <0.7+    , containers >=0.5 && <1.0     , exceptions >=0.8 && <0.11-    , hashable >=1.2 && <1.5+    , hashable >=1.2 && <2.0     , mmorph >=1.0 && <2     , mtl >=2.0 && <3     , multimap >=1.0 && <2@@ -104,6 +104,8 @@       Test.Data.Registry.THSpec       Test.Tasty.Extensions       Test.Tutorial.Application+      Test.Tutorial.DatabaseLogger+      Test.Tutorial.DatabaseLoggerExample       Test.Tutorial.Exercise1       Test.Tutorial.Exercise2       Test.Tutorial.Exercise3@@ -133,11 +135,11 @@     , async <2.3     , base >=4.14 && <5     , bytestring <0.13-    , containers >=0.5 && <0.7+    , containers >=0.5 && <1.0     , directory <1.4     , exceptions >=0.8 && <0.11     , generic-lens >=1.0 && <3.0-    , hashable >=1.2 && <1.5+    , hashable >=1.2 && <2.0     , hedgehog >=1.0 && <3.0     , io-memoize <1.2     , mmorph >=1.0 && <2
+ test/Test/Tutorial/DatabaseLogger.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE StrictData #-}+{-# LANGUAGE OverloadedStrings #-}++module Test.Tutorial.DatabaseLogger where++import Protolude hiding (log)++-- | A Logger interface+data Logger = Logger+  { log :: Text -> Severity -> IO ()+  }++data Severity = Info | Error | Fatal+  deriving (Eq, Ord, Show)++-- | The production implementation+newLogger :: Logger+newLogger = Logger (\t s -> print ("[" <> show s <> "] " <> t))++-- | 2 different ways to limit the severity for a Logger+limitSeverity :: Severity -> Logger -> Logger+limitSeverity at (Logger p) =+  Logger (\t s ->+    if s >= at then p t s+    else pure ())++newLimitedLogger :: Severity -> Logger+newLimitedLogger at = limitSeverity at newLogger++-- | This Logger doesn't log anything+noLogger :: Logger+noLogger = Logger (\_ _ -> pure ())++-- | A database interface+data Database = Database+  { executeQuery :: Text -> IO ()+  }++-- | A production database using a Logger+newDatabase :: Logger -> Database+newDatabase logger = Database {..} where+  executeQuery :: Text -> IO ()+  executeQuery q = do+    log logger ("executing query " <> q) Info+    print "do it"
+ test/Test/Tutorial/DatabaseLoggerExample.hs view
@@ -0,0 +1,36 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE PartialTypeSignatures #-}+{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}++module Test.Tutorial.DatabaseLoggerExample where++import Data.Registry+import Test.Tutorial.DatabaseLogger++prodRegistry =+     fun newDatabase+  <: fun newLogger++prodDatabase = make @Database prodRegistry++-- Don't log anything for those tests+testRegistry1 =+     fun noLogger+  <: prodRegistry++testDatabase1 = make @Database testRegistry1++-- Only log some messages for those tests+testRegistry2 =+  tweak @Logger (limitSeverity Info) prodRegistry++testDatabase2 = make @Database testRegistry2++-- Only log some messages for those tests+-- Specify the severity as a separate value+testRegistry3 =+     fun newLimitedLogger+  <: val Info+  <: prodRegistry++testDatabase3 = make @Database testRegistry3