packages feed

witch 1.2.4.0 → 1.3.0.0

raw patch · 3 files changed

+18/−17 lines, 3 files

Files

source/library/Witch/Instances.hs view
@@ -939,15 +939,16 @@  -- Fixed --- | Uses 'Fixed.MkFixed'. This means @from \@Integer \@Centi 2@ is @0.02@--- rather than @2.00@.-instance From.From Integer (Fixed.Fixed a) where-  from = Fixed.MkFixed+-- | Uses 'fromInteger'. This means @from \@Integer \@Centi 2@ is @02.00@+-- rather than @0.02@.+instance (Fixed.HasResolution a) => From.From Integer (Fixed.Fixed a) where+  from = fromInteger --- | Uses 'Fixed.MkFixed'. This means @from \@Centi \@Integer 3.00@ is @300@--- rather than @3@.-instance From.From (Fixed.Fixed a) Integer where-  from (Fixed.MkFixed t) = t+-- | Converts via 'Rational' when there is no fractional part. This means+-- @tryFrom \@Centi \@Integer 2.00@ is @Right 2@ and+-- @tryFrom \@Centi \@Integer 0.02@ will fail.+instance (Fixed.HasResolution a) => TryFrom.TryFrom (Fixed.Fixed a) Integer where+  tryFrom = Utility.eitherTryFrom $ TryFrom.tryFrom @Rational . From.from  -- | Uses 'toRational'. instance (Fixed.HasResolution a) => From.From (Fixed.Fixed a) Rational where
source/test-suite/Main.hs view
@@ -1663,16 +1663,16 @@     describe "From Integer (Fixed a)" $ do       let f = Witch.from @Integer @Fixed.Deci       it "works" $ do-        f 1 `shouldBe` 0.1-        f 10 `shouldBe` 1-        f 120 `shouldBe` 12+        f 1 `shouldBe` 1.0+        f 10 `shouldBe` 10.0+        f 120 `shouldBe` 120.0 -    describe "From (Fixed a) Integer" $ do-      let f = Witch.from @Fixed.Deci @Integer+    describe "TryFrom (Fixed a) Integer" $ do+      let f = hush . Witch.tryFrom @Fixed.Deci @Integer       it "works" $ do-        f 0.1 `shouldBe` 1-        f 1 `shouldBe` 10-        f 12 `shouldBe` 120+        f 0.1 `shouldBe` Nothing+        f 1 `shouldBe` Just 1+        f 12 `shouldBe` Just 12      describe "From (Fixed a) Rational" $ do       let f = Witch.from @Fixed.Deci @Rational
witch.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: witch-version: 1.2.4.0+version: 1.3.0.0 synopsis: Convert values from one type into another. description: Witch converts values from one type into another. build-type: Simple