typed-encoding-0.5.0.0: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Examples.TypedEncoding.SomeEnc

Description

This module defines SomeEnc - existentially quantified version of Enc and basic combinators.

This construction is common to more dependently typed Haskell but is isomorphic to CheckedEnc.

Post v0.4 typed-encoding supports CheckedEnc while SomeEnc remains as as example.

(Moved from Data.TypedEncoding.Common.Types.SomeEnc in previous versions)

Since: 0.5.0.0

Synopsis

Documentation

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

data SomeEnc conf str where Source #

Existentially quantified quantified Enc effectively isomorphic to CheckedEnc

Since: 0.2.0.0

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 (Enc '[TEST] () (Text hello))"
Instance details

Defined in Examples.TypedEncoding.SomeEnc

Methods

displ :: SomeEnc c str -> String Source #

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

Since: 0.2.0.0

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

Since: 0.2.0.0

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

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

Since: 0.2.0.0

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

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

@since 0.2.0.0 s