{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}

-- | v0.2 style encoding combinators
-- 
-- @since 0.3.0.0
module Data.TypedEncoding.Instances.Support.Encode where

import           Data.TypedEncoding.Instances.Support.Unsafe
import           Data.TypedEncoding.Combinators.Unsafe
import           Data.TypedEncoding.Common.Types.Enc
import           Data.Proxy
import           Data.TypedEncoding.Common.Types
import           GHC.TypeLits

-- | 
-- Create @"r-"@ - like encoding based on 'Data.TypedEncoding.Common.Class.fromEncF' like function. 
-- 
-- Useful for small not performance critical encoding since it executed provided @fromEnc@ function
-- to verify the encoding
--
-- this method does not restrict @nm@ to follow "r-" naming convention but is expected to be used to define @"r-"@ encoding. 
_implEncFromString :: forall nm err a c str . 
                       (KnownSymbol nm
                       , Show err) 
                       => 
                       (Enc '[nm] () str -> Either err a) 
                       -> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncFromString :: (Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str
 -> Either err a)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncFromString Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str
-> Either err a
fn = Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding
     (Either EncodeEx)
     nm
     (Concat (LTakeUntil (ToList1 nm "") ":"))
     c
     str
forall (nm :: Symbol) conf str (f :: * -> *) (alg :: Symbol).
Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs conf str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm alg conf str
UnsafeMkEncoding Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy forall (xs :: [Symbol]).
Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
f
   where 
       f :: forall xs . Enc xs c str -> Either EncodeEx (Enc (nm ': xs) c str)
       f :: Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
f Enc @[Symbol] xs c str
enc = 
           case Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str
-> Either err a
fn (() -> str -> Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str
forall k conf str (enc :: k). conf -> str -> Enc @k enc conf str
unsafeSetPayload () (str -> Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str)
-> str -> Enc @[Symbol] ((':) @Symbol nm ('[] @Symbol)) () str
forall a b. (a -> b) -> a -> b
$ Enc @[Symbol] xs c str -> str
forall k (enc :: k) conf str. Enc @k enc conf str -> str
getPayload Enc @[Symbol] xs c str
enc) of
               Right a
_ -> Enc @[Symbol] ((':) @Symbol nm xs) c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall a b. b -> Either a b
Right (Enc @[Symbol] ((':) @Symbol nm xs) c str
 -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Enc @[Symbol] ((':) @Symbol nm xs) c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall a b. (a -> b) -> a -> b
$ (str -> str)
-> Enc @[Symbol] xs c str
-> Enc @[Symbol] ((':) @Symbol nm xs) c str
forall k1 k2 s1 s2 (e1 :: k1) c (e2 :: k2).
(s1 -> s2) -> Enc @k1 e1 c s1 -> Enc @k2 e2 c s2
withUnsafeCoerce str -> str
forall a. a -> a
id Enc @[Symbol] xs c str
enc
               Left err
err ->  EncodeEx
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall a b. a -> Either a b
Left (EncodeEx
 -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> EncodeEx
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall a b. (a -> b) -> a -> b
$ Proxy @Symbol nm -> err -> EncodeEx
forall a (x :: Symbol).
(Show a, KnownSymbol x) =>
Proxy @Symbol x -> a -> EncodeEx
EncodeEx (Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy :: Proxy nm) err
err

-- * Compiler figures out algorithm, these appear fast enough 

_implEncodingP :: forall nm f c str . Applicative f => (str -> str) -> Encoding f nm (AlgNm nm)  c str
_implEncodingP :: (str -> str) -> Encoding f nm (AlgNm nm) c str
_implEncodingP str -> str
f = (forall (xs :: [Symbol]).
 Enc @[Symbol] xs c str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm (AlgNm nm) c str
forall (f :: * -> *) (nm :: Symbol) conf str.
(forall (xs :: [Symbol]).
 Enc @[Symbol] xs conf str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm (AlgNm nm) conf str
_mkEncoding ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding f nm (AlgNm nm) c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm (AlgNm nm) c str
forall a b. (a -> b) -> a -> b
$ (str -> f str)
-> Enc @[Symbol] xs c str
-> f (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF (str -> f str
forall (f :: * -> *) a. Applicative f => a -> f a
pure (str -> f str) -> (str -> str) -> str -> f str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. str -> str
f)

_implEncodingConfP :: forall nm f c str . Applicative f => (c -> str -> str) -> Encoding f nm (AlgNm nm) c str
_implEncodingConfP :: (c -> str -> str) -> Encoding f nm (AlgNm nm) c str
_implEncodingConfP c -> str -> str
f = (forall (xs :: [Symbol]).
 Enc @[Symbol] xs c str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm (AlgNm nm) c str
forall (f :: * -> *) (nm :: Symbol) conf str.
(forall (xs :: [Symbol]).
 Enc @[Symbol] xs conf str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm (AlgNm nm) conf str
_mkEncoding ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding f nm (AlgNm nm) c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm (AlgNm nm) c str
forall a b. (a -> b) -> a -> b
$ (c -> str -> f str)
-> Enc @[Symbol] xs c str
-> f (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) conf str (enc1 :: k1) (enc2 :: k2).
Functor f =>
(conf -> str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF' (\c
c -> str -> f str
forall (f :: * -> *) a. Applicative f => a -> f a
pure (str -> f str) -> (str -> str) -> str -> f str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> str -> str
f c
c)

_implEncodingEx :: forall nm err c str . (KnownSymbol nm, Show err) => (str -> Either err str) -> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEx :: (str -> Either err str)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEx str -> Either err str
f = (forall (xs :: [Symbol]).
 Enc @[Symbol] xs c str
 -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall (f :: * -> *) (nm :: Symbol) conf str.
(forall (xs :: [Symbol]).
 Enc @[Symbol] xs conf str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm (AlgNm nm) conf str
_mkEncoding ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding (Either EncodeEx) nm (AlgNm nm) c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall a b. (a -> b) -> a -> b
$ (str -> Either EncodeEx str)
-> Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF ((err -> Either EncodeEx str)
-> (str -> Either EncodeEx str)
-> Either err str
-> Either EncodeEx str
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (EncodeEx -> Either EncodeEx str
forall a b. a -> Either a b
Left (EncodeEx -> Either EncodeEx str)
-> (err -> EncodeEx) -> err -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy @Symbol nm -> err -> EncodeEx
forall a (x :: Symbol).
(Show a, KnownSymbol x) =>
Proxy @Symbol x -> a -> EncodeEx
EncodeEx Proxy @Symbol nm
p) str -> Either EncodeEx str
forall a b. b -> Either a b
Right (Either err str -> Either EncodeEx str)
-> (str -> Either err str) -> str -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. str -> Either err str
f) 
   where
        p :: Proxy @Symbol nm
p = Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy :: Proxy nm

_implEncodingEncodeEx :: forall nm c str . (KnownSymbol nm) => (str -> Either EncodeEx str) -> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEncodeEx :: (str -> Either EncodeEx str)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEncodeEx str -> Either EncodeEx str
f = (forall (xs :: [Symbol]).
 Enc @[Symbol] xs c str
 -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall (f :: * -> *) (nm :: Symbol) conf str.
(forall (xs :: [Symbol]).
 Enc @[Symbol] xs conf str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm (AlgNm nm) conf str
_mkEncoding ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding (Either EncodeEx) nm (AlgNm nm) c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall a b. (a -> b) -> a -> b
$ (str -> Either EncodeEx str)
-> Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF str -> Either EncodeEx str
f 


_implEncodingConfEx :: forall nm err c str . (KnownSymbol nm, Show err) => (c -> str -> Either err str) -> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingConfEx :: (c -> str -> Either err str)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingConfEx c -> str -> Either err str
f = (forall (xs :: [Symbol]).
 Enc @[Symbol] xs c str
 -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall (f :: * -> *) (nm :: Symbol) conf str.
(forall (xs :: [Symbol]).
 Enc @[Symbol] xs conf str
 -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm (AlgNm nm) conf str
_mkEncoding ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding (Either EncodeEx) nm (AlgNm nm) c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
forall a b. (a -> b) -> a -> b
$ (c -> str -> Either EncodeEx str)
-> Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) conf str (enc1 :: k1) (enc2 :: k2).
Functor f =>
(conf -> str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF' (\c
c -> (err -> Either EncodeEx str)
-> (str -> Either EncodeEx str)
-> Either err str
-> Either EncodeEx str
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (EncodeEx -> Either EncodeEx str
forall a b. a -> Either a b
Left (EncodeEx -> Either EncodeEx str)
-> (err -> EncodeEx) -> err -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy @Symbol nm -> err -> EncodeEx
forall a (x :: Symbol).
(Show a, KnownSymbol x) =>
Proxy @Symbol x -> a -> EncodeEx
EncodeEx Proxy @Symbol nm
p) str -> Either EncodeEx str
forall a b. b -> Either a b
Right (Either err str -> Either EncodeEx str)
-> (str -> Either err str) -> str -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> str -> Either err str
f c
c) 
    where
        p :: Proxy @Symbol nm
p = Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy :: Proxy nm



-- * Assume @alg ~ nm@ or explicit @alg@ 

implEncodingP :: forall nm f c str . Applicative f => (str -> str) -> Encoding f nm nm c str
implEncodingP :: (str -> str) -> Encoding f nm nm c str
implEncodingP str -> str
f = Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm nm c str
forall (nm :: Symbol) conf str (f :: * -> *) (alg :: Symbol).
Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs conf str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm alg conf str
UnsafeMkEncoding Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding f nm nm c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding f nm nm c str
forall a b. (a -> b) -> a -> b
$ (str -> f str)
-> Enc @[Symbol] xs c str
-> f (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF (str -> f str
forall (f :: * -> *) a. Applicative f => a -> f a
pure (str -> f str) -> (str -> str) -> str -> f str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. str -> str
f)

implEncodingEx :: forall nm err c str . (KnownSymbol nm, Show err) =>  (str -> Either err str) -> Encoding (Either EncodeEx) nm nm c str
implEncodingEx :: (str -> Either err str) -> Encoding (Either EncodeEx) nm nm c str
implEncodingEx = forall err c str.
(KnownSymbol nm, Show err) =>
(str -> Either err str) -> Encoding (Either EncodeEx) nm nm c str
forall (alg :: Symbol) (nm :: Symbol) err c str.
(KnownSymbol nm, Show err) =>
(str -> Either err str) -> Encoding (Either EncodeEx) nm alg c str
implEncodingEx' @nm @nm

implEncodingEx' :: forall alg nm err c str . (KnownSymbol nm, Show err) =>  (str -> Either err str) -> Encoding (Either EncodeEx) nm alg c str
implEncodingEx' :: (str -> Either err str) -> Encoding (Either EncodeEx) nm alg c str
implEncodingEx' str -> Either err str
f = Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm alg c str
forall (nm :: Symbol) conf str (f :: * -> *) (alg :: Symbol).
Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs conf str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm alg conf str
UnsafeMkEncoding Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding (Either EncodeEx) nm alg c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm alg c str
forall a b. (a -> b) -> a -> b
$ (str -> Either EncodeEx str)
-> Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF ((err -> Either EncodeEx str)
-> (str -> Either EncodeEx str)
-> Either err str
-> Either EncodeEx str
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (EncodeEx -> Either EncodeEx str
forall a b. a -> Either a b
Left (EncodeEx -> Either EncodeEx str)
-> (err -> EncodeEx) -> err -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy @Symbol nm -> err -> EncodeEx
forall a (x :: Symbol).
(Show a, KnownSymbol x) =>
Proxy @Symbol x -> a -> EncodeEx
EncodeEx Proxy @Symbol nm
p) str -> Either EncodeEx str
forall a b. b -> Either a b
Right (Either err str -> Either EncodeEx str)
-> (str -> Either err str) -> str -> Either EncodeEx str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. str -> Either err str
f) 
   where
        p :: Proxy @Symbol nm
p = Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy :: Proxy nm

implEncodingEncodeEx' :: forall alg nm c str . (KnownSymbol nm) =>  (str -> Either EncodeEx str) -> Encoding (Either EncodeEx) nm alg c str
implEncodingEncodeEx' :: (str -> Either EncodeEx str)
-> Encoding (Either EncodeEx) nm alg c str
implEncodingEncodeEx' str -> Either EncodeEx str
f = Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm alg c str
forall (nm :: Symbol) conf str (f :: * -> *) (alg :: Symbol).
Proxy @Symbol nm
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs conf str
    -> f (Enc @[Symbol] ((':) @Symbol nm xs) conf str))
-> Encoding f nm alg conf str
UnsafeMkEncoding Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy ((forall (xs :: [Symbol]).
  Enc @[Symbol] xs c str
  -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
 -> Encoding (Either EncodeEx) nm alg c str)
-> (forall (xs :: [Symbol]).
    Enc @[Symbol] xs c str
    -> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str))
-> Encoding (Either EncodeEx) nm alg c str
forall a b. (a -> b) -> a -> b
$ (str -> Either EncodeEx str)
-> Enc @[Symbol] xs c str
-> Either EncodeEx (Enc @[Symbol] ((':) @Symbol nm xs) c str)
forall k1 k2 (f :: * -> *) str (enc1 :: k1) conf (enc2 :: k2).
Functor f =>
(str -> f str)
-> Enc @k1 enc1 conf str -> f (Enc @k2 enc2 conf str)
implTranF str -> Either EncodeEx str
f 
   where
        p :: Proxy @Symbol nm
p = Proxy @Symbol nm
forall k (t :: k). Proxy @k t
Proxy :: Proxy nm


-- |
-- @since 0.5.1.0
implVerifyR :: (a -> Either err b) -> a -> Either err a
implVerifyR :: (a -> Either err b) -> a -> Either err a
implVerifyR a -> Either err b
fn a
a = 
     case a -> Either err b
fn a
a of 
         Left err
err -> err -> Either err a
forall a b. a -> Either a b
Left err
err
         Right b
_ -> a -> Either err a
forall a b. b -> Either a b
Right a
a