nat-optics 1 → 1.0.0.1
raw patch · 7 files changed
+128/−22 lines, 7 filesdep +hedgehogdep +nat-opticsPVP ok
version bump matches the API change (PVP)
Dependencies added: hedgehog, nat-optics
API changes (from Hackage documentation)
Files
- changelog.txt +2/−0
- nat-optics.cabal +42/−20
- src/NatOptics/NonNegative.hs +9/−1
- src/NatOptics/Positive.hs +9/−1
- test/NonNegative.hs +28/−0
- test/Positive.hs +28/−0
- test/TestPrelude.hs +10/−0
+ changelog.txt view
@@ -0,0 +1,2 @@+v1 - Initial release+v1.0.0.1 - Added tests, added a few examples to the docs
nat-optics.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: nat-optics-version: 1+version: 1.0.0.1 category: Numeric, Optics synopsis:@@ -13,8 +13,9 @@ - "NatOptics.NonNegative" includes 0, 1, 2, 3, ... - "NatOptics.Positive" includes 1, 2, 3, 4, ... - You probably also want to import the "Optics" module- from the `optics` package.+ The modules in this package re-export some optics functions+ to cover basic usage, but you probably also want to import+ the "Optics" module from the `optics` package. copyright: 2021 Mission Valley Software LLC license: MIT@@ -28,28 +29,49 @@ build-type: Simple +extra-source-files: changelog.txt+ source-repository head type: git location: https://github.com/typeclasses/nat-optics -library- default-language: Haskell2010- ghc-options: -Wall- hs-source-dirs: src+common language+ default-language: Haskell2010+ ghc-options: -Wall+ default-extensions: DerivingStrategies+ , GeneralizedNewtypeDeriving+ , NoImplicitPrelude+ , TypeApplications - default-extensions:- DerivingStrategies- GeneralizedNewtypeDeriving- NoImplicitPrelude+common dependencies+ build-depends: base ^>= 4.14 || ^>= 4.15+ , text ^>= 1.2.3+ , optics-core ^>= 0.4 - exposed-modules:- NatOptics.NonNegative- NatOptics.Positive+common test+ import: language+ , dependencies+ default-extensions: TemplateHaskell+ build-depends: hedgehog ^>= 1.0.4+ , nat-optics+ other-modules: TestPrelude - other-modules:- NatOptics.Internal+library+ import: language+ , dependencies+ hs-source-dirs: src+ exposed-modules: NatOptics.NonNegative+ , NatOptics.Positive+ other-modules: NatOptics.Internal - build-depends:- base ^>= 4.14 || ^>= 4.15- , text ^>= 1.2.3- , optics-core ^>= 0.4+test-suite NonNegative+ import: test+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: NonNegative.hs++test-suite Positive+ import: test+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Positive.hs
src/NatOptics/NonNegative.hs view
@@ -35,7 +35,15 @@ deriving newtype (Eq, Ord, Show) {- | For any numeric type @n@,- @'NonNegative' n@ is a subset of @n@. -}+ @'NonNegative' n@ is a subset of @n@.++Examples:++- @'preview' 'refine' (-1 :: 'Integer')@ = @'Nothing'@+- @'preview' 'refine' (0 :: 'Integer')@ = @'Just' (NonNegative 0)@+- @'preview' 'refine' (1 :: 'Integer')@ = @'Just' (NonNegative 1)@+- @'preview' 'refine' (2 :: 'Integer')@ = @'Just' (NonNegative 2)@+-} refine :: (Num n, Ord n) => Prism' n (NonNegative n) refine = prism' number verify
src/NatOptics/Positive.hs view
@@ -34,7 +34,15 @@ deriving newtype (Eq, Ord, Show) {- | For any numeric type @n@,- @'Positive' n@ is a subset of @n@.-}+ @'Positive' n@ is a subset of @n@.++Examples:++- @'preview' 'refine' (-1 :: 'Integer')@ = @'Nothing'@+- @'preview' 'refine' (0 :: 'Integer')@ = @'Nothing'@+- @'preview' 'refine' (1 :: 'Integer')@ = @'Just' (Positive 1)@+- @'preview' 'refine' (2 :: 'Integer')@ = @'Just' (Positive 2)@+-} refine :: (Num n, Ord n) => Prism' n (Positive n) refine = prism' number verify
+ test/NonNegative.hs view
@@ -0,0 +1,28 @@+module Main (main) where++import NatOptics.NonNegative+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"++ traverse_+ (\x -> preview (stringPrism @Int32) x === Nothing )+ [ "-0", "-1", "00", "𝟝𝟟", "57 ", "057"+ , "9999999999999999999999999999" ]
+ test/Positive.hs view
@@ -0,0 +1,28 @@+module Main (main) where++import NatOptics.Positive+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"++ traverse_+ (\x -> preview (stringPrism @Int16) x === Nothing )+ [ "0", "-0", "-1", "00", "𝟝𝟟", "57 ", "057"+ , "99999999999999999999999" ]
+ test/TestPrelude.hs view
@@ -0,0 +1,10 @@+module TestPrelude (module X) 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