typed-encoding-0.2.2.0: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Internal.Types.SomeEnc

Description

Module defines SomeEnc - existentially quantified version of Enc and basic combinators

Synopsis

Documentation

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

data SomeEnc conf str where Source #

Existentially quantified quanitified Enc effectively isomorphic to CheckedEnc

Constructors

MkSomeEnc :: SymbolList xs => Enc xs conf str -> SomeEnc conf str 
Instances
(Show c, Displ str) => Displ (SomeEnc c str) Source #
>>> let enctest = unsafeSetPayload () "hello" :: Enc '["TEST"] () T.Text
>>> displ $ MkSomeEnc enctest
"Some (MkEnc '[TEST] () (Text hello))"
Instance details

Defined in Data.TypedEncoding.Internal.Types.SomeEnc

Methods

displ :: SomeEnc c str -> String Source #

withSomeEnc :: SomeEnc conf str -> (forall xs. SymbolList xs => Enc xs conf str -> r) -> r Source #

toSome :: SymbolList xs => Enc xs conf str -> SomeEnc conf str Source #

someToChecked :: SomeEnc conf str -> CheckedEnc conf str Source #

>>> let enctest = unsafeSetPayload () "hello" :: Enc '["TEST"] () T.Text
>>> someToChecked . MkSomeEnc $ enctest
MkCheckedEnc ["TEST"] () "hello"

checkedToSome :: CheckedEnc conf str -> SomeEnc conf str Source #

>>> let tst = unsafeCheckedEnc ["TEST"] () "test"
>>> displ $ checkedToSome tst
"Some (MkEnc '[TEST] () test)"