natural 0.3.0.3 → 0.3.0.4
raw patch · 3 files changed
+26/−1 lines, 3 filesdep ~basedep ~lensPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: base, lens
API changes (from Hackage documentation)
+ Natural: instance Natural.AsPositive Natural.Natural
+ Natural: naturalPositive :: Iso' Natural (Maybe Positive)
Files
- changelog.md +4/−0
- natural.cabal +1/−1
- src/Natural.hs +21/−0
changelog.md view
@@ -1,3 +1,7 @@+0.3.0.4++* add `naturalPositive` iso and `instance AsPositive Natural` prism.+ 0.3.0.3 * added some more functions.
natural.cabal view
@@ -1,7 +1,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: natural-version: 0.3.0.3+version: 0.3.0.4 synopsis: Natural number description: <<http://i.imgur.com/uZnp9ke.png>>
src/Natural.hs view
@@ -36,6 +36,7 @@ , SumPositive(..) , MaxPositive(..) , MinPositive(..)+, naturalPositive , one , one' , successor1@@ -542,6 +543,26 @@ instance Semigroup MinPositive where MinPositive (Positive x) <> MinPositive (Positive y) = MinPositive (Positive (x `min` y))++naturalPositive ::+ Iso' Natural (Maybe Positive)+naturalPositive =+ iso+ (\(Natural n) ->+ if n == 0 then Nothing else Just (Positive n))+ (\x -> Natural (+ case x of+ Nothing ->+ 0+ Just (Positive n) ->+ n)+ )++instance AsPositive Natural where+ _Positive =+ prism'+ (\(Positive n) -> Natural n)+ (\(Natural n) -> if n == 0 then Nothing else Just (Positive n)) one :: Prism'