typed-encoding-0.3.0.2: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Common.Class.Util.StringConstraints

Contents

Description

ToStrInj and ToStrIso are future replacement for Data.TypedEncoding.Common.Class.IsStringR (currently not used).

Synopsis

Documentation

>>> :set -XScopedTypeVariables -XTypeApplications -XAllowAmbiguousTypes
>>> import Test.QuickCheck
>>> import Test.QuickCheck.Instances.Text()
>>> import Test.QuickCheck.Instances.ByteString()

IsString reversal

class ToStrInj str from where Source #

Reverses IsString

law for types that are also IsString:

 toString . fromString == id

Note: ByteString is not a valid instance, ByteString "r-ASCII", or "r-UTF8" would be needed. B8.unpack $ B8.pack "160688" == "176"

This class is separated from ToStrIso to allow instances from smaller types the can inject into the String type.

Since: 0.3.0.0

Methods

toString :: from -> str Source #

Instances
ToStrInj String String Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

ToStrInj String Text Source #
prop_toStringFromString (Proxy :: Proxy TL.Text)
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

toString :: Text -> String Source #

ToStrInj String Text Source #
prop_toStringFromString (Proxy :: Proxy T.Text)
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

toString :: Text -> String Source #

class ToStrInj str from => ToStrIso str from Source #

Same as ToStrInj but with additional

law for types that are also IsString: fromString . toString == id

Since: 0.3.0.0

Instances
ToStrIso String String Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

ToStrIso String Text Source #
prop_fromStringToString @TL.Text
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

ToStrIso String Text Source #
prop_fromStringToString @T.Text
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

class Char8Find str where Source #

Used to find exceptions that violated "r-" encoding Expected to be used to check encoding of ASCII-7 so Text and ByteString are compatible.

Since: 0.3.0.0

Methods

find :: (Char -> Bool) -> str -> Maybe Char Source #

Instances
Char8Find String Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

find :: (Char -> Bool) -> String -> Maybe Char Source #

Char8Find ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

find :: (Char -> Bool) -> ByteString -> Maybe Char Source #

Char8Find ByteString Source #

B8.pack is basically a convenient way to get Word8 elements into ByteString.

During B8.pack conversion charters are downsized to the 0-255 range (become a Word8). The length is preserved.

>>> B8.pack "\160582"
"F"
>>> B.length $ B8.pack "\160582"
1

This instance allows to check elements of ByteString interpreting them as Char.

Safe if restricting to 7bit code points.

Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

find :: (Char -> Bool) -> ByteString -> Maybe Char Source #

Char8Find Text Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

find :: (Char -> Bool) -> Text -> Maybe Char Source #

Char8Find Text Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Util.StringConstraints

Methods

find :: (Char -> Bool) -> Text -> Maybe Char Source #