typed-encoding-0.2.2.0: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Internal.Types.CheckedEnc

Contents

Description

Module defines CheckedEnc - untyped ADT version of Enc

Synopsis

Documentation

>>> :set -XOverloadedStrings -XMultiParamTypeClasses -XDataKinds -XAllowAmbiguousTypes
>>> import qualified Data.Text as T

Untyped Enc

data CheckedEnc conf str Source #

Represents some validated encoded string.

CheckedEnc is untyped version of Enc. CheckedEnc contains verified encoded data, encoding is visible at the value level only.

Constructors

MkCheckedEnc [EncAnn] conf str 
Instances
(Eq conf, Eq str) => Eq (CheckedEnc conf str) Source # 
Instance details

Defined in Data.TypedEncoding.Internal.Types.CheckedEnc

Methods

(==) :: CheckedEnc conf str -> CheckedEnc conf str -> Bool #

(/=) :: CheckedEnc conf str -> CheckedEnc conf str -> Bool #

(Show conf, Show str) => Show (CheckedEnc conf str) Source # 
Instance details

Defined in Data.TypedEncoding.Internal.Types.CheckedEnc

Methods

showsPrec :: Int -> CheckedEnc conf str -> ShowS #

show :: CheckedEnc conf str -> String #

showList :: [CheckedEnc conf str] -> ShowS #

(Show c, Displ str) => Displ (CheckedEnc c str) Source #
>>> displ $ unsafeCheckedEnc ["TEST"] () ("hello" :: T.Text)
"MkCheckedEnc [TEST] () (Text hello)"
Instance details

Defined in Data.TypedEncoding.Internal.Types.CheckedEnc

Methods

displ :: CheckedEnc c str -> String Source #

unsafeCheckedEnc :: [EncAnn] -> c -> s -> CheckedEnc c s Source #

toCheckedEnc :: forall xs c str. SymbolList xs => Enc xs c str -> CheckedEnc c str Source #

fromCheckedEnc :: forall xs c str. SymbolList xs => CheckedEnc c str -> Maybe (Enc xs c str) Source #

proc_toCheckedEncFromCheckedEnc :: forall xs c str. (SymbolList xs, Eq c, Eq str) => CheckedEnc c str -> Bool Source #

>>> let encsometest = MkCheckedEnc ["TEST"] () $ T.pack "hello"
>>> proc_toCheckedEncFromCheckedEnc @'["TEST"] encsometest
True
>>> proc_toCheckedEncFromCheckedEnc @'["TEST1"] encsometest
False

proc_fromCheckedEncToCheckedEnc :: forall xs c str. (SymbolList xs, Eq c, Eq str) => Enc xs c str -> Bool Source #

>>> let enctest = unsafeSetPayload () "hello" :: Enc '["TEST"] () T.Text
>>> proc_fromCheckedEncToCheckedEnc enctest
True