Representing ASCII with refined supersets

Version on this page:
LTS Haskell 20.15:
Stackage Nightly 2023-03-24:
Latest on Hackage:

See all snapshots ascii-superset appears in

Apache-2.0 licensed by Chris Martin
Maintained by Chris Martin, Julie Moronuki
This version can be pinned in stack with:ascii-superset-,2248

Module documentation for

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.

Changes (2023-01-06)

New in ASCII.CaseRefinement:

forgetCase :: ASCII'case letterCase superset -> ASCII superset

And a new corresponding Lift instance:

instance Lift (ASCII'case letterCase superset) (ASCII superset) (2023-01-05)

New classes:

class ToCasefulChar (letterCase :: Case) char where
    toCasefulChar :: CaselessChar -> char
class ToCasefulString (letterCase :: Case) string where
    toCasefulString :: [CaselessChar] -> string (2023-01-05)

Add instance Lift a a (2023-01-05)

ASCII'case now has instances for:

  • ToCaselessChar
  • ToChar
  • ToCaselessString
  • ToString (2023-01-05)

Add instance FromChar CaselessChar (2023-01-03)

Add to the CharSuperset class a new method:

toCaseChar :: Case -> char -> char

Add to the StringSuperset class a new method:

toCaseString :: Case -> string -> string

Add to the ASCII.CaseRefinement module:

refineCharToCase :: forall letterCase char.
    KnownCase letterCase => CharSuperset char =>
    ASCII char -> ASCII'case letterCase char
refineStringToCase :: forall letterCase char.
    KnownCase letterCase => StringSuperset char =>
    ASCII char -> ASCII'case letterCase char (2023-01-03)

Add to ASCII.CaseRefinement the KnownCase class. (2023-01-03)

Add classes ToChar (isAsciiChar, toCharUnsafe) and FromChar (fromChar), of which CharSuperset is now a subclass with no methods of its own.

Add classes ToString (isAsciiString, toCharListUnsafe, toCharListSub) and FromString (fromCharList), of which StringSuperset is now a subclass which still has some methods (substituteString and mapCharsUnsafe).

Add class ToCaselessChar (isAsciiCaselessChar, toCaselessCharUnsafe), which is a superclass of ToChar. Also added related functions toCaselessCharMaybe, toCaselessCharOrFail, and toCaselessCharSub.

Add class ToCaselessString (isAsciiCaselessString, toCaselessCharListUnsafe, toCaselessCharListSub) which is a superclass of ToString. Also added related functions toCaselessCharListMaybe and toCaselessCharListOrFail. (2023-01-02)

Add module ASCII.CaseRefinement

  • This includes ASCII'case, a new refinement type for characters strings. It asserts that any character which is a letter must be of a particular case.

Switch test suite from hedgehog to hspec (2022-01-02)

Minor Cabal correction (change extra-doc-files to extra-source-files) (2022-12-30)

Metadata changes only (2022-04-20)

Drop support for base 4.11 (GHC 8.4) and base 4.12 (GHC 8.6)

Modify documentation on the Lift class. Previously it indicated that the class was for converting ASCII into supersets of ASCII. The class’s purpose is now restated as being a conversion from any character set to any other larger character set. The purpose is to indicate that the ASCII subset types defined in the ascii-numbers package may reasonably have Lift instances. (2022-03-22)

Switch test-suite over to hedgehog (2022-01-09)

Support GHC 9.2 (2021-11-13)

Support hashable-1.4 (2021-09-26)

Add a test suite

Raise text lower bound to 1.2.3 (2021-02-10)

Support GHC 9.0 (2021-02-09)

Support bytestring-0.11 (2021-01-27)

New functions:

  • convertCharOrFail
  • convertStringMaybe
  • convertStringOrFail
  • convertCharMaybe (2021-01-25)

Add some comments (2020-05-18)

Support GHC 8.10 (2020-05-05)

Initial release