{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
module Data.TypedEncoding.Pkg.Encoding.Instances where
import qualified Data.TypedEncoding.Instances.Support as Typed
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.TypedEncoding.Pkg.Encoding.Conv as Conv
instance (Conv.DynEnc s, Typed.Algorithm s "enc-pkg/encoding") => Typed.ToEncString (Either Typed.EncodeEx) s "enc-pkg/encoding" String B.ByteString where
toEncF = Conv.encodeStrictByteStringExplicit . Typed.toEncoding ()
instance (Conv.DynEnc s, Typed.Algorithm s "enc-pkg/encoding") => Typed.ToEncString (Either Typed.EncodeEx) s "enc-pkg/encoding" String BL.ByteString where
toEncF = Conv.encodeLazyByteStringExplicit . Typed.toEncoding ()
instance (
Typed.UnexpectedDecodeErr f
, Monad f
, Conv.DynEnc s
, Typed.Algorithm s "enc-pkg/encoding"
) => Typed.FromEncString f s "enc-pkg/encoding" String B.ByteString where
fromEncF = fmap Typed.fromEncoding . Conv.decodeStrictByteStringExplicit
instance (
Typed.UnexpectedDecodeErr f
, Monad f
, Conv.DynEnc s
, Typed.Algorithm s "enc-pkg/encoding"
) => Typed.FromEncString f s "enc-pkg/encoding" String BL.ByteString where
fromEncF = fmap Typed.fromEncoding . Conv.decodeLazyByteStringExplicit
instance (
Conv.DynEnc s
, Typed.Algorithm s "enc-pkg/encoding"
) => Typed.Encode (Either Typed.EncodeEx) s "enc-pkg/encoding" c String where
encoding = Conv.encString
instance (
Typed.UnexpectedDecodeErr f
, Monad f
, Conv.DynEnc s
, Typed.Algorithm s "enc-pkg/encoding"
) => Typed.Decode f s "enc-pkg/encoding" c String where
decoding = Conv.decString
instance Conv.DynEnc s => Typed.EncodingSuperset s where
type EncSuperset s = "r-CHAR8"