typed-encoding-0.3.0.1: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Common.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
>>> import  Data.TypedEncoding.Combinators.Unsafe (unsafeSetPayload)

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.

Since: 0.2.0.0

Constructors

UnsafeMkCheckedEnc [EncAnn] conf str

Constructor renamed from previous versions

Since: 0.3.0.0

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

Defined in Data.TypedEncoding.Common.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.Common.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)
"UnsafeMkCheckedEnc [TEST] () (Text hello)"
Instance details

Defined in Data.TypedEncoding.Common.Types.CheckedEnc

Methods

displ :: CheckedEnc c str -> String Source #

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

Since: 0.2.0.0

getCheckedPayload :: CheckedEnc conf str -> str Source #

Since: 0.2.0.0

getCheckedEncPayload :: CheckedEnc conf str -> ([EncAnn], str) Source #

Since: 0.2.0.0

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

Since: 0.2.0.0

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

Since: 0.2.0.0

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

>>> let encsometest = UnsafeMkCheckedEnc ["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