witch 1.0.0.4 → 1.0.1.0
raw patch · 3 files changed
+32/−1 lines, 3 filesdep +taggedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: tagged
API changes (from Hackage documentation)
- Witch.Instances: instance Data.Fixed.HasResolution a => Witch.From.From (Data.Fixed.Fixed a) GHC.Real.Rational
- Witch.Instances: instance Data.Fixed.HasResolution a => Witch.TryFrom.TryFrom GHC.Real.Rational (Data.Fixed.Fixed a)
- Witch.Instances: instance Witch.From.From (Data.Fixed.Fixed a) GHC.Num.Integer.Integer
- Witch.Instances: instance Witch.From.From GHC.Num.Integer.Integer (Data.Fixed.Fixed a)
+ Witch.Instances: instance forall k (a :: k). Data.Fixed.HasResolution a => Witch.From.From (Data.Fixed.Fixed a) GHC.Real.Rational
+ Witch.Instances: instance forall k (a :: k). Data.Fixed.HasResolution a => Witch.TryFrom.TryFrom GHC.Real.Rational (Data.Fixed.Fixed a)
+ Witch.Instances: instance forall k (a :: k). Witch.From.From (Data.Fixed.Fixed a) GHC.Num.Integer.Integer
+ Witch.Instances: instance forall k (a :: k). Witch.From.From GHC.Num.Integer.Integer (Data.Fixed.Fixed a)
+ Witch.Instances: instance forall k (t :: k) a. Witch.From.From (Data.Tagged.Tagged t a) a
+ Witch.Instances: instance forall k a (t :: k). Witch.From.From a (Data.Tagged.Tagged t a)
+ Witch.Instances: instance forall k1 k2 (t :: k1) a (u :: k2). Witch.From.From (Data.Tagged.Tagged t a) (Data.Tagged.Tagged u a)
Files
- source/library/Witch/Instances.hs +13/−0
- source/test-suite/Main.hs +17/−0
- witch.cabal +2/−1
source/library/Witch/Instances.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-orphans #-}@@ -23,6 +24,7 @@ import qualified Data.Ratio as Ratio import qualified Data.Sequence as Seq import qualified Data.Set as Set+import qualified Data.Tagged as Tagged import qualified Data.Text as Text import qualified Data.Text.Encoding as Text import qualified Data.Text.Lazy as LazyText@@ -1271,6 +1273,17 @@ -- | Uses 'Time.zonedTimeToUTC'. instance From.From Time.ZonedTime Time.UTCTime where from = Time.zonedTimeToUTC++-- Tagged++-- | Uses @coerce@. Essentially the same as 'Tagged.Tagged'.+instance From.From a (Tagged.Tagged t a)++-- | Uses @coerce@. Essentially the same as 'Tagged.unTagged'.+instance From.From (Tagged.Tagged t a) a++-- | Uses @coerce@. Essentially the same as 'Tagged.retag'.+instance From.From (Tagged.Tagged t a) (Tagged.Tagged u a) --
source/test-suite/Main.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NegativeLiterals #-} {-# LANGUAGE TemplateHaskell #-}@@ -20,6 +21,7 @@ import qualified Data.Ratio as Ratio import qualified Data.Sequence as Seq import qualified Data.Set as Set+import qualified Data.Tagged as Tagged import qualified Data.Text as Text import qualified Data.Text.Lazy as LazyText import qualified Data.Time as Time@@ -2069,6 +2071,21 @@ let f = Witch.from @Time.ZonedTime @Time.UTCTime it "works" $ do f (Time.ZonedTime (Time.LocalTime (Time.ModifiedJulianDay 0) (Time.TimeOfDay 0 0 0)) Time.utc) `shouldBe` Time.UTCTime (Time.ModifiedJulianDay 0) 0++ describe "From a (Tagged t a)" $ do+ let f = Witch.from @Bool @(Tagged.Tagged () Bool)+ it "works" $ do+ f False `shouldBe` Tagged.Tagged False++ describe "From (Tagged t a) a" $ do+ let f = Witch.from @(Tagged.Tagged () Bool) @Bool+ it "works" $ do+ f (Tagged.Tagged False) `shouldBe` False++ describe "From (Tagged t a) (Tagged u a)" $ do+ let f = Witch.from @(Tagged.Tagged "old" Bool) @(Tagged.Tagged "new" Bool)+ it "works" $ do+ f (Tagged.Tagged False) `shouldBe` Tagged.Tagged False newtype Age = Age Int.Int8
witch.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: witch-version: 1.0.0.4+version: 1.0.1.0 synopsis: Convert values from one type into another. description: Witch converts values from one type into another. @@ -26,6 +26,7 @@ , base >= 4.10 && < 4.18 , bytestring >= 0.10.8 && < 0.12 , containers >= 0.5.10 && < 0.7+ , tagged >= 0.8.6 && < 0.9 , text >= 1.2.3 && < 1.3 || >= 2.0 && < 2.1 , time >= 1.9.1 && < 1.13 default-language: Haskell2010