positive 0.3 → 0.4
raw patch · 2 files changed
+19/−4 lines, 2 filesdep +semigroupsPVP ok
version bump matches the API change (PVP)
Dependencies added: semigroups
API changes (from Hackage documentation)
+ Numeric.Positive: nonEmptyLength :: NonEmpty a -> Positive
Files
- positive.cabal +4/−3
- src/Numeric/Positive.hs +15/−1
positive.cabal view
@@ -1,12 +1,12 @@ name: positive-version: 0.3+version: 0.4 cabal-version: >= 1.10 author: Hans Hoglund maintainer: Hans Hoglund <hans@hanshoglund.se> license: BSD3 license-file: COPYING-synopsis: Positive numbers.+synopsis: Positive integers. category: tested-with: GHC build-type: Simple@@ -21,7 +21,8 @@ library build-depends: base >= 4 && < 5,- nats >= 0.2 && < 1+ nats >= 0.2 && < 1,+ semigroups >= 0.15.2 && < 1 hs-source-dirs: src default-language: Haskell2010 exposed-modules:
src/Numeric/Positive.hs view
@@ -3,9 +3,13 @@ module Numeric.Positive ( Positive,- positive+ positive,+ nonEmptyLength, ) where+ import Numeric.Natural+import Data.Semigroup+import qualified Data.List.NonEmpty as NonEmpty newtype Positive = Positive { getPositive :: Natural } deriving ( @@ -54,3 +58,13 @@ positive :: a -> (a -> a) -> Positive -> a positive a f 1 = f a positive a f n = f (positive a f $ pred n)++nonEmptyLength :: NonEmpty.NonEmpty a -> Positive+nonEmptyLength = fromIntegral . NonEmpty.length++-- _positive :: Integral a => Prism' a Positive+-- _positive :: prism' fromIntegral (\x -> if x > 0 then Just (fromInteger x :: Positive) else Nothing)++-- _nonEmpty :: Prism [a] [b] (NonEmpty a) (NonEmpty b)+-- _nonEmpty :: prism' NonEmpty.toList (\x -> if lenght x > 0 then Just (NonEmpty.fromList x) else Nothing)+