mirror of
https://github.com/tfausak/witch.git
synced 2024-11-25 22:13:49 +03:00
Add an instance for tagging values
This commit is contained in:
parent
30284b95c5
commit
7c5226d034
@ -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 ::
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user