mirror of
https://github.com/tfausak/witch.git
synced 2024-11-25 22:13:49 +03:00
Rearrange UTF-8 instances
This commit is contained in:
parent
b352927f1d
commit
6fbc49e133
@ -1039,24 +1039,6 @@ instance From.From ByteString.ByteString LazyByteString.ByteString where
|
||||
instance From.From ByteString.ByteString ShortByteString.ShortByteString where
|
||||
from = ShortByteString.toShort
|
||||
|
||||
-- | 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 (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 (Tagged.Tagged "UTF-8" ByteString.ByteString) String where
|
||||
tryFrom =
|
||||
Utility.eitherTryFrom $
|
||||
fmap (Utility.into @String)
|
||||
. Utility.tryInto @Text.Text
|
||||
|
||||
-- LazyByteString
|
||||
|
||||
-- | Uses 'LazyByteString.pack'.
|
||||
@ -1071,24 +1053,6 @@ instance From.From LazyByteString.ByteString [Word.Word8] where
|
||||
instance From.From LazyByteString.ByteString ByteString.ByteString where
|
||||
from = LazyByteString.toStrict
|
||||
|
||||
-- | 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 (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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) String where
|
||||
tryFrom =
|
||||
Utility.eitherTryFrom $
|
||||
fmap (Utility.into @String)
|
||||
. Utility.tryInto @LazyText.Text
|
||||
|
||||
-- ShortByteString
|
||||
|
||||
-- | Uses 'ShortByteString.pack'.
|
||||
@ -1109,28 +1073,12 @@ instance From.From ShortByteString.ShortByteString ByteString.ByteString where
|
||||
instance From.From Text.Text LazyText.Text where
|
||||
from = LazyText.fromStrict
|
||||
|
||||
-- | 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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where
|
||||
from = fmap From.from . Utility.into @(Tagged.Tagged "UTF-8" ByteString.ByteString)
|
||||
|
||||
-- LazyText
|
||||
|
||||
-- | Uses 'LazyText.toStrict'.
|
||||
instance From.From LazyText.Text Text.Text where
|
||||
from = LazyText.toStrict
|
||||
|
||||
-- | 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 (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'
|
||||
@ -1151,14 +1099,6 @@ instance From.From String LazyText.Text where
|
||||
instance From.From LazyText.Text String where
|
||||
from = LazyText.unpack
|
||||
|
||||
-- | 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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where
|
||||
from = Utility.via @LazyText.Text
|
||||
|
||||
-- TryFromException
|
||||
|
||||
-- | Uses @coerce@.
|
||||
@ -1286,6 +1226,68 @@ 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)
|
||||
|
||||
-- UTF-8
|
||||
|
||||
-- | 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 (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 (Tagged.Tagged "UTF-8" ByteString.ByteString) String where
|
||||
tryFrom =
|
||||
Utility.eitherTryFrom $
|
||||
fmap (Utility.into @String)
|
||||
. Utility.tryInto @Text.Text
|
||||
|
||||
-- | 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 (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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) String where
|
||||
tryFrom =
|
||||
Utility.eitherTryFrom $
|
||||
fmap (Utility.into @String)
|
||||
. Utility.tryInto @LazyText.Text
|
||||
|
||||
-- | 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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where
|
||||
from = fmap From.from . Utility.into @(Tagged.Tagged "UTF-8" ByteString.ByteString)
|
||||
|
||||
-- | 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 (Tagged.Tagged "UTF-8" ByteString.ByteString) where
|
||||
from = fmap From.from . Utility.into @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)
|
||||
|
||||
-- | 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 (Tagged.Tagged "UTF-8" LazyByteString.ByteString) where
|
||||
from = Utility.via @LazyText.Text
|
||||
|
||||
--
|
||||
|
||||
realFloatToRational ::
|
||||
|
@ -1800,31 +1800,6 @@ spec = describe "Witch" $ do
|
||||
f (ByteString.pack [0x00]) `shouldBe` ShortByteString.pack [0x00]
|
||||
f (ByteString.pack [0x0f, 0xf0]) `shouldBe` ShortByteString.pack [0x0f, 0xf0]
|
||||
|
||||
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
|
||||
f (Tagged.Tagged (ByteString.pack [0x24])) `shouldBe` Just (Text.pack "\x24")
|
||||
f (Tagged.Tagged (ByteString.pack [0xc2, 0xa3])) `shouldBe` Just (Text.pack "\xa3")
|
||||
f (Tagged.Tagged (ByteString.pack [0xe2, 0x82, 0xac])) `shouldBe` Just (Text.pack "\x20ac")
|
||||
f (Tagged.Tagged (ByteString.pack [0xf0, 0x90, 0x8d, 0x88])) `shouldBe` Just (Text.pack "\x10348")
|
||||
|
||||
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 @(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
|
||||
@ -1846,27 +1821,6 @@ spec = describe "Witch" $ do
|
||||
f (LazyByteString.pack [0x00]) `shouldBe` ByteString.pack [0x00]
|
||||
f (LazyByteString.pack [0x0f, 0xf0]) `shouldBe` ByteString.pack [0x0f, 0xf0]
|
||||
|
||||
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 @(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
|
||||
@ -1895,22 +1849,6 @@ spec = describe "Witch" $ do
|
||||
f (Text.pack "a") `shouldBe` LazyText.pack "a"
|
||||
f (Text.pack "ab") `shouldBe` LazyText.pack "ab"
|
||||
|
||||
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])
|
||||
f (Text.pack "\x24") `shouldBe` Tagged.Tagged (ByteString.pack [0x24])
|
||||
f (Text.pack "\xa3") `shouldBe` Tagged.Tagged (ByteString.pack [0xc2, 0xa3])
|
||||
f (Text.pack "\x20ac") `shouldBe` Tagged.Tagged (ByteString.pack [0xe2, 0x82, 0xac])
|
||||
f (Text.pack "\x10348") `shouldBe` Tagged.Tagged (ByteString.pack [0xf0, 0x90, 0x8d, 0x88])
|
||||
|
||||
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
|
||||
@ -1918,18 +1856,6 @@ spec = describe "Witch" $ do
|
||||
f (LazyText.pack "a") `shouldBe` Text.pack "a"
|
||||
f (LazyText.pack "ab") `shouldBe` Text.pack "ab"
|
||||
|
||||
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 @(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
|
||||
@ -1958,18 +1884,6 @@ spec = describe "Witch" $ do
|
||||
f (LazyText.pack "a") `shouldBe` "a"
|
||||
f (LazyText.pack "ab") `shouldBe` "ab"
|
||||
|
||||
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 @(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
|
||||
it "works" $ do
|
||||
@ -2095,6 +2009,92 @@ spec = describe "Witch" $ do
|
||||
it "works" $ do
|
||||
f (Tagged.Tagged False) `shouldBe` Tagged.Tagged False
|
||||
|
||||
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
|
||||
f (Tagged.Tagged (ByteString.pack [0x24])) `shouldBe` Just (Text.pack "\x24")
|
||||
f (Tagged.Tagged (ByteString.pack [0xc2, 0xa3])) `shouldBe` Just (Text.pack "\xa3")
|
||||
f (Tagged.Tagged (ByteString.pack [0xe2, 0x82, 0xac])) `shouldBe` Just (Text.pack "\x20ac")
|
||||
f (Tagged.Tagged (ByteString.pack [0xf0, 0x90, 0x8d, 0x88])) `shouldBe` Just (Text.pack "\x10348")
|
||||
|
||||
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 @(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 "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 @(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 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])
|
||||
f (Text.pack "\x24") `shouldBe` Tagged.Tagged (ByteString.pack [0x24])
|
||||
f (Text.pack "\xa3") `shouldBe` Tagged.Tagged (ByteString.pack [0xc2, 0xa3])
|
||||
f (Text.pack "\x20ac") `shouldBe` Tagged.Tagged (ByteString.pack [0xe2, 0x82, 0xac])
|
||||
f (Text.pack "\x10348") `shouldBe` Tagged.Tagged (ByteString.pack [0xf0, 0x90, 0x8d, 0x88])
|
||||
|
||||
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 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 @(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 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 @(Tagged.Tagged "UTF-8" LazyByteString.ByteString)
|
||||
it "works" $ do
|
||||
f "" `shouldBe` Tagged.Tagged (LazyByteString.pack [])
|
||||
f "a" `shouldBe` Tagged.Tagged (LazyByteString.pack [0x61])
|
||||
|
||||
newtype Age
|
||||
= Age Int.Int8
|
||||
deriving (Eq, Show)
|
||||
|
Loading…
Reference in New Issue
Block a user