ascii-superset 1.0.0.4 → 1.0.1.0
raw patch · 3 files changed
+35/−6 lines, 3 filesdep ~ascii-chardep ~bytestringdep ~textPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ascii-char, bytestring, text
API changes (from Hackage documentation)
+ ASCII.Superset: convertCharMaybe :: (CharSuperset char1, CharSuperset char2) => char1 -> Maybe char2
+ ASCII.Superset: convertCharOrFail :: (CharSuperset char1, CharSuperset char2, MonadFail context) => char1 -> context char2
+ ASCII.Superset: convertStringMaybe :: (StringSuperset string1, StringSuperset string2) => string1 -> Maybe string2
+ ASCII.Superset: convertStringOrFail :: (StringSuperset string1, StringSuperset string2, MonadFail context) => string1 -> context string2
Files
- ASCII/Superset.hs +19/−2
- ascii-superset.cabal +5/−4
- changelog.txt +11/−0
ASCII/Superset.hs view
@@ -2,11 +2,11 @@ {- * Characters -} {- ** Class -} CharSuperset (..),- {- ** Functions -} asCharUnsafe, toCharMaybe, toCharOrFail, toCharSub, substituteChar,+ {- ** Functions -} asCharUnsafe, toCharMaybe, toCharOrFail, toCharSub, substituteChar, convertCharMaybe, convertCharOrFail, {- * Strings -} {- ** Class -} StringSuperset (..),- {- ** Functions -} toCharListMaybe, toCharListOrFail+ {- ** Functions -} toCharListMaybe, toCharListOrFail, convertStringMaybe, convertStringOrFail ) where @@ -14,6 +14,7 @@ import Control.Monad.Fail ( MonadFail (fail) ) import Data.Bool ( Bool, (&&) ) import Data.Function ( (.), id )+import Data.Functor ( fmap ) import Data.Ord ( (<=), (>=) ) import Data.Maybe ( Maybe (..) ) @@ -59,7 +60,15 @@ substituteChar :: CharSuperset char => char -> char substituteChar x = if isAsciiChar x then x else fromChar ASCII.Substitute +-- | Convert from one ASCII-superset character type to another via the ASCII 'ASCII.Char' type. Fails as 'Nothing' if the input is outside the ASCII character set.+convertCharMaybe :: (CharSuperset char1, CharSuperset char2) => char1 -> Maybe char2+convertCharMaybe = convertCharOrFail +-- | Convert from one ASCII-superset character type to another via the ASCII 'ASCII.Char' type. Fails with 'fail' if the input is outside the ASCII character set.+convertCharOrFail :: (CharSuperset char1, CharSuperset char2, MonadFail context) => char1 -> context char2+convertCharOrFail = fmap fromChar . toCharOrFail++ --- String --- class StringSuperset string@@ -83,6 +92,14 @@ toCharListOrFail :: (StringSuperset string, MonadFail context) => string -> context [ASCII.Char] toCharListOrFail x = if isAsciiString x then return (toCharListUnsafe x) else fail "String contains non-ASCII characters"++-- | Convert from one ASCII-superset string type to another by converting each character of the input string to an ASCII 'ASCII.Char', and then converting the ASCII character list to the desired output type. Fails as 'Nothing' if the input contains any character that is outside the ASCII character set.+convertStringMaybe :: (StringSuperset string1, StringSuperset string2) => string1 -> Maybe string2+convertStringMaybe = convertStringOrFail++-- | Convert from one ASCII-superset string type to another by converting each character of the input string to an ASCII 'ASCII.Char', and then converting the ASCII character list to the desired output type. Fails with 'fail' if the input contains any character that is outside the ASCII character set.+convertStringOrFail :: (StringSuperset string1, StringSuperset string2, MonadFail context) => string1 -> context string2+convertStringOrFail = fmap fromCharList . toCharListOrFail --- Instances ---
ascii-superset.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.0 name: ascii-superset-version: 1.0.0.4+version: 1.0.1.0 synopsis: Representing ASCII with refined supersets category: Data, Text @@ -36,11 +36,12 @@ default-extensions: DeriveGeneric ghc-options: -Wall -fno-warn-unused-imports + build-depends: ascii-char ^>= 1.0+ build-depends: base >= 4.11 && < 4.15- build-depends: bytestring >= 0.10 && < 0.11- build-depends: ascii-char >= 1.0 && < 1.1+ build-depends: bytestring ^>= 0.10 build-depends: hashable >= 1.2 && < 1.4- build-depends: text >= 1.2 && < 1.3+ build-depends: text ^>= 1.2 exposed-modules: ASCII.Superset exposed-modules: ASCII.Isomorphism
changelog.txt view
@@ -1,2 +1,13 @@ 1.0.0.0 - 2020-05-05 - Initial release+ 1.0.0.2 - 2020-05-18 - Support GHC 8.10++1.0.0.4 - 2021-01-25 - Add some comments++1.0.1.0 - 2021-01-27++ New functions:+ - convertCharMaybe+ - convertCharOrFail+ - convertStringMaybe+ - convertStringOrFail