diff --git a/source/library/Witch/Instances.hs b/source/library/Witch/Instances.hs index 99d173f..68e35b6 100644 --- a/source/library/Witch/Instances.hs +++ b/source/library/Witch/Instances.hs @@ -23,6 +23,7 @@ import qualified Data.Map as Map 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 @@ -1272,6 +1273,11 @@ instance From.From Time.NominalDiffTime Time.CalendarDiffTime where 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) + -- realFloatToRational :: diff --git a/source/test-suite/Main.hs b/source/test-suite/Main.hs index 291f9af..1e10b69 100644 --- a/source/test-suite/Main.hs +++ b/source/test-suite/Main.hs @@ -20,6 +20,7 @@ import qualified Data.Map as Map 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 @@ -2070,6 +2071,11 @@ spec = describe "Witch" $ do 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 + newtype Age = Age Int.Int8 deriving (Eq, Show) diff --git a/witch.cabal b/witch.cabal index cfa4229..363b52e 100644 --- a/witch.cabal +++ b/witch.cabal @@ -26,6 +26,7 @@ common library , 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