packages feed

ascii-superset 1.2.2.0 → 1.2.3.0

raw patch · 5 files changed

+43/−6 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ ASCII.Lift: instance ASCII.Lift.Lift a a

Files

ascii-superset.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: ascii-superset-version: 1.2.2.0+version: 1.2.3.0 synopsis: Representing ASCII with refined supersets category: Data, Text 
changelog.md view
@@ -1,3 +1,7 @@+### 1.2.3.0 (2023-01-05)++Add `instance Lift a a`+ ### 1.2.2.0 (2023-01-05)  `ASCII'case` now has instances for:
library/ASCII/Lift.hs view
@@ -35,6 +35,8 @@      lift :: subset -> superset +instance Lift a a where lift x = x+ {-| A value from an ASCII superset that has been refined by the 'ASCII' type constructor may be lifted back into the superset by unwrapping it from the 'ASCII' type. -}
library/ASCII/Superset.hs view
@@ -62,7 +62,10 @@  This includes the 'ASCII.Char' type itself, character sets that are supersets of ASCII, and numeric types such as 'Word8' that are often used to represent-ASCII characters. -}+ASCII characters.++This does /not/ include 'CaselessChar', because that cannot be converted to+'ASCII.Char' without choosing a case. -} class ToCaselessChar char => ToChar char where      -- | Test whether a character can be converted to 'ASCII.Char'@@ -75,7 +78,11 @@  This class includes supersets of ASCII, in which case 'fromChar' is a lifting function. It also includes 'CaselessChar', in which case 'fromChar' discards-case information. -}+case information.++This does /not/ include 'ASCII.CaseRefinement.ASCII'case', because that represents+a subset of 'ASCII.Char'; not all characters are of the wanted case, so no total+conversion is possible without changing case. -} class FromChar char where      -- | Conversion from 'ASCII.Char'@@ -164,7 +171,10 @@  This includes @['ASCII.Char']@ type itself, strings of character sets that are supersets of ASCII, and sequences of numeric types such as 'Word8' that are-often used to represent ASCII characters. -}+often used to represent ASCII characters.++This does /not/ include @['CaselessChar']@, because that cannot be converted+to @['ASCII.Char']@ without choosing a case. -} class ToCaselessString string => ToString string where      -- | Test whether a string can be converted to @['ASCII.Char']@@@ -182,7 +192,12 @@  This class includes supersets of ASCII, in which case 'fromCharList' lifts each character into the larger character set. It also includes @['CaselessChar']@, in-which case 'fromCharList' discards case information from letters. -}+which case 'fromCharList' discards case information from letters.++This does /not/ include @['ASCII.CaseRefinement.ASCII'case']@, because that+represents a subset of ASCII; not all ASCII characters are of case wanted by+'ASCII.CaseRefinement.ASCII'case', so no total conversion is possible without+changing case. -} class FromString string where      -- | Conversion from @['ASCII.Char']@
test/Main.hs view
@@ -34,9 +34,25 @@             let f x = Lift.lift x :: Word8             f CapitalLetterA `shouldBe` 65 -        it "list" $ do+        it "to unicode" $ do+            let f = Lift.lift+            f CapitalLetterA `shouldBe` 'A'++        it "list to Text" $ do             let f x = Lift.lift x :: Text             f [CapitalLetterH, SmallLetterI, ExclamationMark] `shouldBe` "Hi!"++        it "list to ASCII Text" $ do+            let f x = Lift.lift x :: ASCII Text+            f [CapitalLetterH, SmallLetterI, ExclamationMark] `shouldBe` (asciiUnsafe "Hi!")++        it "ASCII Word8" $ do+            let f x = Lift.lift (x :: ASCII Word8) :: Word8+            f (asciiUnsafe 65) `shouldBe` 65++        it "can be id" $ do+            let f x = Lift.lift (x :: Unicode.Char) :: Unicode.Char+            f 'x' `shouldBe` 'x'      describe "refinement" $ do