{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Data.TypedEncoding.Instances.Restriction.CHAR8 where
import Data.TypedEncoding.Instances.Support
import Data.TypedEncoding.Common.Class.Util.StringConstraints
import Data.TypedEncoding.Instances.Restriction.ByteRep (encImpl, CharOutOfRange (..))
import Data.TypedEncoding.Internal.Util (explainBool)
import Data.Char
testEncChar8Char :: Encoding (Either EncodeEx) "r-CHAR8" "r-CHAR8" c Char
testEncChar8Char :: Encoding (Either EncodeEx) "r-CHAR8" "r-CHAR8" c Char
testEncChar8Char = (Char -> Either CharOutOfRange Char)
-> Encoding (Either EncodeEx) "r-CHAR8" (AlgNm "r-CHAR8") c Char
forall (nm :: Symbol) err c str.
(KnownSymbol nm, Show err) =>
(str -> Either err str)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEx (\Char
c -> (Char -> CharOutOfRange)
-> (Char, Bool) -> Either CharOutOfRange Char
forall a err. (a -> err) -> (a, Bool) -> Either err a
explainBool (Int -> Char -> CharOutOfRange
CharOutOfRange Int
255) (Char
c, (Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
255) (Int -> Bool) -> (Char -> Int) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord (Char -> Bool) -> Char -> Bool
forall a b. (a -> b) -> a -> b
$ Char
c))
testEncCHAR8 :: Char8Find str => Encoding (Either EncodeEx) "r-CHAR8" "r-CHAR8" c str
testEncCHAR8 :: Encoding (Either EncodeEx) "r-CHAR8" "r-CHAR8" c str
testEncCHAR8 = (str -> Either CharOutOfRange str)
-> Encoding (Either EncodeEx) "r-CHAR8" (AlgNm "r-CHAR8") c str
forall (nm :: Symbol) err c str.
(KnownSymbol nm, Show err) =>
(str -> Either err str)
-> Encoding (Either EncodeEx) nm (AlgNm nm) c str
_implEncodingEx @"r-CHAR8" (Int -> str -> Either CharOutOfRange str
forall str.
Char8Find str =>
Int -> str -> Either CharOutOfRange str
encImpl Int
255)