ascii-superset 1.2.7.0 → 1.3.0.0
raw patch · 5 files changed
+28/−86 lines, 5 filesdep ~hspecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hspec
API changes (from Hackage documentation)
- ASCII.Lift: class Lift subset superset
- ASCII.Lift: instance ASCII.Lift.Lift (ASCII.CaseRefinement.ASCII'case letterCase superset) (ASCII.Refinement.Internal.ASCII superset)
- ASCII.Lift: instance ASCII.Lift.Lift (ASCII.CaseRefinement.ASCII'case letterCase superset) superset
- ASCII.Lift: instance ASCII.Lift.Lift (ASCII.Refinement.Internal.ASCII superset) superset
- ASCII.Lift: instance ASCII.Lift.Lift a a
- ASCII.Lift: instance ASCII.Superset.CharSuperset superset => ASCII.Lift.Lift ASCII.Char.Char superset
- ASCII.Lift: instance ASCII.Superset.StringSuperset superset => ASCII.Lift.Lift [ASCII.Char.Char] superset
- ASCII.Lift: lift :: Lift subset superset => subset -> superset
Files
- ascii-superset.cabal +1/−6
- changelog.md +10/−0
- library/ASCII/Lift.hs +0/−52
- readme.md +0/−4
- test/Main.hs +17/−24
ascii-superset.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: ascii-superset-version: 1.2.7.0+version: 1.3.0.0 synopsis: Representing ASCII with refined supersets category: Data, Text @@ -10,10 +10,6 @@ is valid as ASCII, as well as a type constructor representing a value of a superset that is known to be valid ASCII. - It also defines the Lift class, which provides a polymorphic lift- operation that can be used to convert characters and strings into- types that support a larger set of characters.- license: Apache-2.0 license-file: license.txt @@ -74,7 +70,6 @@ ASCII.SupersetConversion ASCII.Isomorphism ASCII.Refinement- ASCII.Lift other-modules: ASCII.Refinement.Internal
changelog.md view
@@ -1,3 +1,13 @@+### 1.3.0.0 (2023-02-28)++Removed the `ASCII.Lift` module. The `Lift` class is now gone. It was a mess. It+was not possible to define a comprehensive set of instances for this class, and+as a user it was difficult to guess what types `lift` would work on.++All of the `lift` implementations were just other functions anyway: `fromChar`,+`fromCharList`, `ASCII.Refinement.lift`, etc. Use one of those other polymorphic+but slightly more specific functions instead.+ ### 1.2.7.0 (2023-02-08) Add module `ASCII.Superset.Text`
− library/ASCII/Lift.hs
@@ -1,52 +0,0 @@-{-|--@-(lift CapitalLetterA :: Word8) == 65--(lift [CapitalLetterH, SmallLetterI, ExclamationMark] :: Text) == "Hi!"-@ -}-module ASCII.Lift (Lift (..)) where--import ASCII.CaseRefinement (ASCII'case)-import ASCII.Char (Char)-import ASCII.Refinement.Internal (ASCII)-import ASCII.Superset (CharSuperset, StringSuperset)--import qualified ASCII.CaseRefinement as CaseRefinement-import qualified ASCII.Refinement.Internal as Refinement-import qualified ASCII.Superset as S--{-| Embedding of one character set within another--The @subset@ and @superset@ types may be characters or strings in-ASCII, some subset of ASCII, or some superset of ASCII. -}-class Lift subset superset where-- {-| Converts from a smaller to a larger type-- Due to the highly polymorphic nature of the 'lift' function,- often it must used with an explicit type signature or type- application to avoid any type ambiguity. -}-- 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. -}-instance Lift (ASCII superset) superset where lift = Refinement.lift--instance Lift (ASCII'case letterCase superset) superset where lift = CaseRefinement.lift--instance Lift (ASCII'case letterCase superset) (ASCII superset) where lift = CaseRefinement.forgetCase--{-| An ASCII 'Char' may be 'lift'ed into any larger character set (a-'CharSuperset'); for example, 'lift' can convert an ASCII character into a value-of the standard 'Prelude.Char' type in "Prelude". -}-instance CharSuperset superset => Lift Char superset where lift = S.fromChar--{-| An ASCII 'Char' list may be 'lift'ed into a string of any larger character-set (a 'StringSuperset'); for example, 'lift' can convert a list of ASCII-characters into a value of the standard 'Prelude.String' type in "Prelude". -}-instance StringSuperset superset => Lift [Char] superset where lift = S.fromCharList
readme.md view
@@ -1,7 +1,3 @@ This package defines classes which describe what subset of a type is valid as ASCII, as well as a type constructor representing a value of a superset that is known to be valid ASCII.--It also defines the `Lift` class, which provides a polymorphic lift operation-that can be used to convert characters and strings into types that support a-larger set of characters.
test/Main.hs view
@@ -6,12 +6,12 @@ import ASCII.CaseRefinement (ASCII'lower, ASCII'upper, asciiCaseUnsafe) import ASCII.Char (Char (..)) import ASCII.Refinement (ASCII, asciiUnsafe)+import ASCII.Superset (fromChar, fromCharList) import qualified ASCII.Case as Case import qualified ASCII.Caseless as CC import qualified ASCII.CaseRefinement as CaseRefinement import qualified ASCII.Char as ASCII-import qualified ASCII.Lift as Lift import qualified ASCII.Refinement as Refinement import qualified ASCII.Superset as Superset @@ -28,31 +28,19 @@ main :: IO () main = hspec $ do - describe "lift" $ do+ describe "fromChar" $ do it "letter" $ do- let f x = Lift.lift x :: Word8+ let f x = fromChar x :: Word8 f CapitalLetterA `shouldBe` 65 it "to unicode" $ do- let f = Lift.lift+ let f = fromChar 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'+ it "id" $ do+ let f x = fromChar (x :: ASCII.Char) :: ASCII.Char+ f CapitalLetterA `shouldBe` CapitalLetterA describe "refinement" $ do @@ -63,10 +51,15 @@ f 97 `shouldBe` Just (asciiUnsafe 97) f 128 `shouldBe` Nothing - it "fromCharList" $ do- let f x = Refinement.fromCharList x :: ASCII Text- f [CapitalLetterH, SmallLetterI, ExclamationMark] `shouldBe` asciiUnsafe "Hi!"+ describe "fromCharList" $ do+ it "Text" $ do+ let f x = fromCharList x :: Text+ f [CapitalLetterH, SmallLetterI, ExclamationMark] `shouldBe` "Hi!" + it "ASCII Text" $ do+ let f x = Refinement.fromCharList x :: ASCII Text+ f [CapitalLetterH, SmallLetterI, ExclamationMark] `shouldBe` asciiUnsafe "Hi!"+ it "toCharList" $ do let f x = Refinement.toCharList (Refinement.substituteString x :: ASCII Text)@@ -149,8 +142,8 @@ check = ([UpperCase, LowerCase] & Foldable.all (\c -> ASCII.allCharacters & Foldable.all (\x ->- Superset.toCaseChar c (Superset.fromChar @a x)- == Superset.fromChar @a (Case.toCase c x)+ Superset.toCaseChar c (fromChar @a x)+ == fromChar @a (Case.toCase c x) ))) `shouldBe` True it "ASCII.Char" $ check @ASCII.Char it "Unicode.Char" $ check @Unicode.Char