packages feed

nat-optics 1.0.0.1 → 1.0.0.2

raw patch · 5 files changed

+86/−46 lines, 5 filesdep −hedgehogdep ~basedep ~textPVP ok

version bump matches the API change (PVP)

Dependencies removed: hedgehog

Dependency ranges changed: base, text

API changes (from Hackage documentation)

Files

changelog.txt view
@@ -1,2 +1,3 @@ v1 - Initial release v1.0.0.1 - Added tests, added a few examples to the docs+v1.0.0.2 - Support GHC 9.2 and text-2.0, drop hedgehog dependency
nat-optics.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: nat-optics-version: 1.0.0.1+version: 1.0.0.2 category: Numeric, Optics  synopsis:@@ -44,16 +44,14 @@                       , TypeApplications  common dependencies-    build-depends:      base        ^>= 4.14 || ^>= 4.15-                      , text        ^>= 1.2.3+    build-depends:      base        ^>= 4.14  || ^>= 4.15 || ^>= 4.16+                      , text        ^>= 1.2.3 || ^>= 2.0                       , optics-core ^>= 0.4  common test     import:             language                       , dependencies-    default-extensions: TemplateHaskell-    build-depends:      hedgehog ^>= 1.0.4-                      , nat-optics+    build-depends:      nat-optics     other-modules:      TestPrelude  library
test/NonNegative.hs view
@@ -4,25 +4,36 @@ import TestPrelude  main :: IO ()-main =-  do-    okay <- checkParallel $$(discover)-    when (not okay) exitFailure--prop_examples :: Property-prop_examples = withTests 1 $ property $-  do-    evalMaybe (preview (stringPrism @Int32) "0") >>= \n ->-      do-        review refine      n === 0-        review stringPrism n === "0"--    evalMaybe (preview (stringPrism @Int32) "57") >>= \n ->-      do-        review refine      n === 57-        review stringPrism n === "57"+main = main' failures -    traverse_-        (\x -> preview (stringPrism @Int32) x === Nothing )+failures :: [Failure]+failures =+    case preview (stringPrism @Int32) "0" of+        Nothing -> fail' "preview (stringPrism @Int32) \"0\" = Nothing"+        Just n ->+            case review refine n of+                0 -> okay+                result -> fail' $ "review refine" ! show' n ! "=" ! show result+            <>+            case review stringPrism n of+                "0" -> okay+                result -> fail' $ "review stringPrism" ! show' n ! "=" ! show result+    <>+    case preview (stringPrism @Int32) "57" of+        Nothing -> fail' "preview (stringPrism @Int32) \"57\" = Nothing"+        Just n ->+            case review refine n of+                57 -> okay+                result -> fail' $ "review refine" ! show' n ! "=" ! show result+            <>+            case review stringPrism n of+                "57" -> okay+                result -> fail' $ "review stringPrism" ! show' n ! "=" ! show result+    <>+    foldMap+        (\x -> case preview (stringPrism @Int32) x of+            Nothing -> okay+            result -> fail' $ "preview (stringPrism @Int32)" ! show' x ! "=" ! show result+        )         [ "-0", "-1", "00", "𝟝𝟟", "57 ", "057"         , "9999999999999999999999999999" ]
test/Positive.hs view
@@ -4,25 +4,36 @@ import TestPrelude  main :: IO ()-main =-  do-    okay <- checkParallel $$(discover)-    when (not okay) exitFailure--prop_examples :: Property-prop_examples = withTests 1 $ property $-  do-    evalMaybe (preview (stringPrism @Int16) "1") >>= \n ->-      do-        review refine      n === 1-        review stringPrism n === "1"--    evalMaybe (preview (stringPrism @Int16) "57") >>= \n ->-      do-        review refine      n === 57-        review stringPrism n === "57"+main = main' failures -    traverse_-        (\x -> preview (stringPrism @Int16) x === Nothing )+failures :: [Failure]+failures =+    case preview (stringPrism @Int16) "1" of+        Nothing -> fail' "preview (stringPrism @Int16) \"1\" = Nothing"+        Just n ->+            case review refine n of+                1 -> okay+                result -> fail' $ "review refine" ! show' n ! "=" ! show result+            <>+            case review stringPrism n of+                "1" -> okay+                result -> fail' $ "review stringPrism" ! show' n ! "=" ! show result+    <>+    case preview (stringPrism @Int16) "57" of+        Nothing -> fail' "preview (stringPrism @Int16) \"57\" = Nothing"+        Just n ->+            case review refine n of+                57 -> okay+                result -> fail' $ "review refine" ! show' n ! "=" ! show result+            <>+            case review stringPrism n of+                "57" -> okay+                result -> fail' $ "review stringPrism" ! show' n ! "=" ! show result+    <>+    foldMap+        (\x -> case preview (stringPrism @Int16) x of+            Nothing -> okay+            result -> fail' $ "preview (stringPrism @Int16)" ! show' x ! "=" ! show result+        )         [ "0", "-0", "-1", "00", "𝟝𝟟", "57 ", "057"         , "99999999999999999999999" ]
test/TestPrelude.hs view
@@ -1,10 +1,29 @@-module TestPrelude (module X) where+module TestPrelude (module X, Failure (..), main', show', okay, fail', (!)) where  import Control.Monad as X import Data.Foldable as X import Data.Int as X-import Hedgehog as X import Optics.Optic as X import Optics.Re as X import Prelude as X import System.Exit as X++data Failure = Failure String++main' :: [Failure] -> IO ()+main' failures =+    unless (null failures) $ do+        for_ failures $ \(Failure x) -> putStrLn ("🔥 " ++ x)+        exitFailure++show' :: Show a => a -> String+show' x = showsPrec 11 x ""++okay :: [Failure]+okay = []++fail' :: String -> [Failure]+fail' x = [Failure x]++(!) :: String -> String -> String+x ! y = x <> " " <> y