packages feed

witch 1.0.1.0 → 1.0.2.0

raw patch · 3 files changed

+140/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Witch.Instances: instance Witch.From.From Data.Text.Internal.Lazy.Text (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString)
+ Witch.Instances: instance Witch.From.From Data.Text.Internal.Lazy.Text (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString)
+ Witch.Instances: instance Witch.From.From Data.Text.Internal.Text (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString)
+ Witch.Instances: instance Witch.From.From Data.Text.Internal.Text (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString)
+ Witch.Instances: instance Witch.From.From GHC.Base.String (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString)
+ Witch.Instances: instance Witch.From.From GHC.Base.String (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString)
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString) Data.Text.Internal.Lazy.Text
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString) Data.Text.Internal.Text
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Internal.ByteString) GHC.Base.String
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString) Data.Text.Internal.Lazy.Text
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString) Data.Text.Internal.Text
+ Witch.Instances: instance Witch.TryFrom.TryFrom (Data.Tagged.Tagged "UTF-8" Data.ByteString.Lazy.Internal.ByteString) GHC.Base.String

Files

source/library/Witch/Instances.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-}@@ -1042,6 +1043,10 @@ instance TryFrom.TryFrom ByteString.ByteString Text.Text where   tryFrom = Utility.eitherTryFrom Text.decodeUtf8' +-- | Uses 'Text.decodeUtf8''.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" ByteString.ByteString) Text.Text where+  tryFrom = Utility.eitherTryFrom $ Text.decodeUtf8' . From.from+ -- | Converts via 'Text.Text'. instance TryFrom.TryFrom ByteString.ByteString LazyText.Text where   tryFrom =@@ -1050,12 +1055,26 @@         . Utility.tryInto @Text.Text  -- | Converts via 'Text.Text'.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" ByteString.ByteString) LazyText.Text where+  tryFrom =+    Utility.eitherTryFrom $+      fmap (Utility.into @LazyText.Text)+        . Utility.tryInto @Text.Text++-- | Converts via 'Text.Text'. instance TryFrom.TryFrom ByteString.ByteString String where   tryFrom =     Utility.eitherTryFrom $       fmap (Utility.into @String)         . Utility.tryInto @Text.Text +-- | Converts via 'Text.Text'.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" ByteString.ByteString) String where+  tryFrom =+    Utility.eitherTryFrom $+      fmap (Utility.into @String)+        . Utility.tryInto @Text.Text+ -- LazyByteString  -- | Uses 'LazyByteString.pack'.@@ -1074,6 +1093,10 @@ instance TryFrom.TryFrom LazyByteString.ByteString LazyText.Text where   tryFrom = Utility.eitherTryFrom LazyText.decodeUtf8' +-- | Uses 'LazyText.decodeUtf8''.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" LazyByteString.ByteString) LazyText.Text where+  tryFrom = Utility.eitherTryFrom $ LazyText.decodeUtf8' . From.from+ -- | Converts via 'LazyText.Text'. instance TryFrom.TryFrom LazyByteString.ByteString Text.Text where   tryFrom =@@ -1082,12 +1105,26 @@         . Utility.tryInto @LazyText.Text  -- | Converts via 'LazyText.Text'.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" LazyByteString.ByteString) Text.Text where+  tryFrom =+    Utility.eitherTryFrom $+      fmap (Utility.into @Text.Text)+        . Utility.tryInto @LazyText.Text++-- | Converts via 'LazyText.Text'. instance TryFrom.TryFrom LazyByteString.ByteString String where   tryFrom =     Utility.eitherTryFrom $       fmap (Utility.into @String)         . Utility.tryInto @LazyText.Text +-- | Converts via 'LazyText.Text'.+instance TryFrom.TryFrom (Tagged.Tagged "UTF-8" LazyByteString.ByteString) String where+  tryFrom =+    Utility.eitherTryFrom $+      fmap (Utility.into @String)+        . Utility.tryInto @LazyText.Text+ -- ShortByteString  -- | Uses 'ShortByteString.pack'.@@ -1112,10 +1149,18 @@ instance From.From Text.Text ByteString.ByteString where   from = Text.encodeUtf8 +-- | Uses 'Text.encodeUtf8'.+instance From.From Text.Text (Tagged.Tagged "UTF-8" ByteString.ByteString) where+  from = From.from . Text.encodeUtf8+ -- | Converts via 'ByteString.ByteString'. instance From.From Text.Text LazyByteString.ByteString where   from = Utility.via @ByteString.ByteString +-- | Converts via 'ByteString.ByteString'.+instance From.From Text.Text (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where+  from = fmap From.from . Utility.into @(Tagged.Tagged "UTF-8" ByteString.ByteString)+ -- LazyText  -- | Uses 'LazyText.toStrict'.@@ -1126,10 +1171,18 @@ instance From.From LazyText.Text LazyByteString.ByteString where   from = LazyText.encodeUtf8 +-- | Uses 'LazyText.encodeUtf8'.+instance From.From LazyText.Text (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where+  from = From.from . LazyText.encodeUtf8+ -- | Converts via 'LazyByteString.ByteString'. instance From.From LazyText.Text ByteString.ByteString where   from = Utility.via @LazyByteString.ByteString +-- | Converts via 'LazyByteString.ByteString'.+instance From.From LazyText.Text (Tagged.Tagged "UTF-8" ByteString.ByteString) where+  from = fmap From.from . Utility.into @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)+ -- String  -- | Uses 'Text.pack'. Some 'Char' values cannot be represented in 'Text.Text'@@ -1154,8 +1207,16 @@ instance From.From String ByteString.ByteString where   from = Utility.via @Text.Text +-- | Converts via 'Text.Text'.+instance From.From String (Tagged.Tagged "UTF-8" ByteString.ByteString) where+  from = Utility.via @Text.Text+ -- | Converts via 'LazyText.Text'. instance From.From String LazyByteString.ByteString where+  from = Utility.via @LazyText.Text++-- | Converts via 'LazyText.Text'.+instance From.From String (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where   from = Utility.via @LazyText.Text  -- TryFromException
source/test-suite/Main.hs view
@@ -1807,6 +1807,13 @@         f (ByteString.pack [0x61]) `shouldBe` Just (Text.pack "a")         f (ByteString.pack [0xff]) `shouldBe` Nothing +    describe "TryFrom ByteString Text" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" ByteString.ByteString) @Text.Text+      it "works" $ do+        f (Tagged.Tagged (ByteString.pack [])) `shouldBe` Just (Text.pack "")+        f (Tagged.Tagged (ByteString.pack [0x61])) `shouldBe` Just (Text.pack "a")+        f (Tagged.Tagged (ByteString.pack [0xff])) `shouldBe` Nothing+     describe "TryFrom ByteString LazyText" $ do       let f = hush . Witch.tryFrom @ByteString.ByteString @LazyText.Text       it "works" $ do@@ -1814,6 +1821,13 @@         f (ByteString.pack [0x61]) `shouldBe` Just (LazyText.pack "a")         f (ByteString.pack [0xff]) `shouldBe` Nothing +    describe "TryFrom ByteString LazyText" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" ByteString.ByteString) @LazyText.Text+      it "works" $ do+        f (Tagged.Tagged (ByteString.pack [])) `shouldBe` Just (LazyText.pack "")+        f (Tagged.Tagged (ByteString.pack [0x61])) `shouldBe` Just (LazyText.pack "a")+        f (Tagged.Tagged (ByteString.pack [0xff])) `shouldBe` Nothing+     describe "TryFrom ByteString String" $ do       let f = hush . Witch.tryFrom @ByteString.ByteString @String       it "works" $ do@@ -1821,6 +1835,13 @@         f (ByteString.pack [0x61]) `shouldBe` Just "a"         f (ByteString.pack [0xff]) `shouldBe` Nothing +    describe "TryFrom ByteString String" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" ByteString.ByteString) @String+      it "works" $ do+        f (Tagged.Tagged (ByteString.pack [])) `shouldBe` Just ""+        f (Tagged.Tagged (ByteString.pack [0x61])) `shouldBe` Just "a"+        f (Tagged.Tagged (ByteString.pack [0xff])) `shouldBe` Nothing+     describe "From [Word8] LazyByteString" $ do       let f = Witch.from @[Word.Word8] @LazyByteString.ByteString       it "works" $ do@@ -1856,6 +1877,20 @@         f (LazyByteString.pack [0x61]) `shouldBe` Just (Text.pack "a")         f (LazyByteString.pack [0xff]) `shouldBe` Nothing +    describe "TryFrom LazyByteString LazyText" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" LazyByteString.ByteString) @LazyText.Text+      it "works" $ do+        f (Tagged.Tagged (LazyByteString.pack [])) `shouldBe` Just (LazyText.pack "")+        f (Tagged.Tagged (LazyByteString.pack [0x61])) `shouldBe` Just (LazyText.pack "a")+        f (Tagged.Tagged (LazyByteString.pack [0xff])) `shouldBe` Nothing++    describe "TryFrom LazyByteString Text" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" LazyByteString.ByteString) @Text.Text+      it "works" $ do+        f (Tagged.Tagged (LazyByteString.pack [])) `shouldBe` Just (Text.pack "")+        f (Tagged.Tagged (LazyByteString.pack [0x61])) `shouldBe` Just (Text.pack "a")+        f (Tagged.Tagged (LazyByteString.pack [0xff])) `shouldBe` Nothing+     describe "TryFrom LazyByteString String" $ do       let f = hush . Witch.tryFrom @LazyByteString.ByteString @String       it "works" $ do@@ -1863,6 +1898,13 @@         f (LazyByteString.pack [0x61]) `shouldBe` Just "a"         f (LazyByteString.pack [0xff]) `shouldBe` Nothing +    describe "TryFrom LazyByteString String" $ do+      let f = hush . Witch.tryFrom @(Tagged.Tagged "UTF-8" LazyByteString.ByteString) @String+      it "works" $ do+        f (Tagged.Tagged (LazyByteString.pack [])) `shouldBe` Just ""+        f (Tagged.Tagged (LazyByteString.pack [0x61])) `shouldBe` Just "a"+        f (Tagged.Tagged (LazyByteString.pack [0xff])) `shouldBe` Nothing+     describe "From [Word8] ShortByteString" $ do       let f = Witch.from @[Word.Word8] @ShortByteString.ShortByteString       it "works" $ do@@ -1897,12 +1939,24 @@         f (Text.pack "") `shouldBe` ByteString.pack []         f (Text.pack "a") `shouldBe` ByteString.pack [0x61] +    describe "From Text ByteString" $ do+      let f = Witch.from @Text.Text @(Tagged.Tagged "UTF-8" ByteString.ByteString)+      it "works" $ do+        f (Text.pack "") `shouldBe` Tagged.Tagged (ByteString.pack [])+        f (Text.pack "a") `shouldBe` Tagged.Tagged (ByteString.pack [0x61])+     describe "From Text LazyByteString" $ do       let f = Witch.from @Text.Text @LazyByteString.ByteString       it "works" $ do         f (Text.pack "") `shouldBe` LazyByteString.pack []         f (Text.pack "a") `shouldBe` LazyByteString.pack [0x61] +    describe "From Text LazyByteString" $ do+      let f = Witch.from @Text.Text @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)+      it "works" $ do+        f (Text.pack "") `shouldBe` Tagged.Tagged (LazyByteString.pack [])+        f (Text.pack "a") `shouldBe` Tagged.Tagged (LazyByteString.pack [0x61])+     describe "From LazyText Text" $ do       let f = Witch.from @LazyText.Text @Text.Text       it "works" $ do@@ -1916,12 +1970,24 @@         f (LazyText.pack "") `shouldBe` LazyByteString.pack []         f (LazyText.pack "a") `shouldBe` LazyByteString.pack [0x61] +    describe "From LazyText LazyByteString" $ do+      let f = Witch.from @LazyText.Text @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)+      it "works" $ do+        f (LazyText.pack "") `shouldBe` Tagged.Tagged (LazyByteString.pack [])+        f (LazyText.pack "a") `shouldBe` Tagged.Tagged (LazyByteString.pack [0x61])+     describe "From LazyText ByteString" $ do       let f = Witch.from @LazyText.Text @ByteString.ByteString       it "works" $ do         f (LazyText.pack "") `shouldBe` ByteString.pack []         f (LazyText.pack "a") `shouldBe` ByteString.pack [0x61] +    describe "From LazyText ByteString" $ do+      let f = Witch.from @LazyText.Text @(Tagged.Tagged "UTF-8" ByteString.ByteString)+      it "works" $ do+        f (LazyText.pack "") `shouldBe` Tagged.Tagged (ByteString.pack [])+        f (LazyText.pack "a") `shouldBe` Tagged.Tagged (ByteString.pack [0x61])+     describe "From String Text" $ do       let f = Witch.from @String @Text.Text       it "works" $ do@@ -1956,11 +2022,23 @@         f "" `shouldBe` ByteString.pack []         f "a" `shouldBe` ByteString.pack [0x61] +    describe "From String ByteString" $ do+      let f = Witch.from @String @(Tagged.Tagged "UTF-8" ByteString.ByteString)+      it "works" $ do+        f "" `shouldBe` Tagged.Tagged (ByteString.pack [])+        f "a" `shouldBe` Tagged.Tagged (ByteString.pack [0x61])+     describe "From String LazyByteString" $ do       let f = Witch.from @String @LazyByteString.ByteString       it "works" $ do         f "" `shouldBe` LazyByteString.pack []         f "a" `shouldBe` LazyByteString.pack [0x61]++    describe "From String LazyByteString" $ do+      let f = Witch.from @String @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)+      it "works" $ do+        f "" `shouldBe` Tagged.Tagged (LazyByteString.pack [])+        f "a" `shouldBe` Tagged.Tagged (LazyByteString.pack [0x61])      describe "From Integer Day" $ do       let f = Witch.from @Integer @Time.Day
witch.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name: witch-version: 1.0.1.0+version: 1.0.2.0 synopsis: Convert values from one type into another. description: Witch converts values from one type into another.