{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeApplications #-}

-- | This module treats 'Bytes' data as holding text encoded in ISO-8859-1. This
-- encoding can only encode codepoints strictly below @U+0100@, but this allows
-- each codepoint to be placed directly into a single byte. This range consists
-- of Unicode Basic Latin, Latin-1 Supplement and C0+C1 Controls, which includes
-- ASCII.
--
-- Strictly, ISO-8859-1 is not to be confused with ISO/IEC 8859-1 (which was the
-- default encoding for webpages before HTML5). ISO/IEC 8859-1 lacks encodings
-- for the C0 and C1 control characters. 
-- 
-- With HTML5, the default encoding of webpages was changed to Windows-1252,
-- which is _not_ compatible with ISO-8859-1. Windows-1252 uses the C1 Control
-- range (@U+0080@ -- @U+009F@) mostly to encode a variety of printable
-- characters. For this encoding, see 'Data.Bytes.Text.Windows1252'.
module Data.Bytes.Text.Latin1
  ( toString
  , fromString
  -- * Specialized Comparisons
  , equals1
  , equals2
  , equals3
  , equals4
  , equals5
  , equals6
  , equals7
  , equals8
  , equals9
  , equals10
  , equals11
  , equals12
  ) where

import Data.Bytes.Types (Bytes(..))
import Data.Char (ord,chr)
import Data.Primitive (ByteArray(ByteArray))
import Data.Word (Word8)
import GHC.Exts (Int(I#),Char(C#))

import qualified Data.Bytes.Pure as Bytes
import qualified GHC.Exts as Exts


-- | Convert a 'String' consisting of only characters representable
-- by ISO-8859-1. These are encoded with ISO-8859-1. Any character
-- with a codepoint above @U+00FF@ is replaced by an unspecified byte.
fromString :: String -> Bytes
fromString :: String -> Bytes
fromString =
  ByteArray -> Bytes
Bytes.fromByteArray (ByteArray -> Bytes) -> (String -> ByteArray) -> String -> Bytes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word8] -> ByteArray
forall l. IsList l => [Item l] -> l
Exts.fromList ([Word8] -> ByteArray)
-> (String -> [Word8]) -> String -> ByteArray
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Word8) -> String -> [Word8]
forall a b. (a -> b) -> [a] -> [b]
map ((Integral Int, Num Word8) => Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (Int -> Word8) -> (Char -> Int) -> Char -> Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord)

-- | Interpret a byte sequence as text encoded by ISO-8859-1.
toString :: Bytes -> String
{-# INLINE toString #-}
toString :: Bytes -> String
toString = (Word8 -> String -> String) -> String -> Bytes -> String
forall a. (Word8 -> a -> a) -> a -> Bytes -> a
Bytes.foldr (\Word8
w String
xs -> Int -> Char
chr (Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral @Word8 @Int Word8
w) Char -> String -> String
forall a. a -> [a] -> [a]
: String
xs) []

-- TODO presumably also fromText and fromShortText


-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a singleton whose element matches the character?
equals1 :: Char -> Bytes -> Bool
{-# INLINE equals1 #-}
equals1 :: Char -> Bytes -> Bool
equals1 !Char
c0 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
1 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a doubleton whose elements match the characters?
equals2 :: Char -> Char -> Bytes -> Bool
equals2 :: Char -> Char -> Bytes -> Bool
equals2 !Char
c0 !Char
c1 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
2 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a tripleton whose elements match the characters?
equals3 :: Char -> Char -> Char -> Bytes -> Bool
equals3 :: Char -> Char -> Char -> Bytes -> Bool
equals3 !Char
c0 !Char
c1 !Char
c2 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
3 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a quadrupleton whose elements match the characters?
equals4 :: Char -> Char -> Char -> Char -> Bytes -> Bool
equals4 :: Char -> Char -> Char -> Char -> Bytes -> Bool
equals4 !Char
c0 !Char
c1 !Char
c2 !Char
c3 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
4 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a quintupleton whose elements match the characters?
equals5 :: Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals5 :: Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals5 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
5 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
       Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a sextupleton whose elements match the characters?
equals6 :: Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals6 :: Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals6 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
6 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
       Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
       Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a septupleton whose elements match the characters?
equals7 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals7 :: Char
-> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals7 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
7 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
       Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
       Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
       Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- an octupleton whose elements match the characters?
equals8 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals8 :: Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Bytes
-> Bool
equals8 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 !Char
c7 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
8 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
       Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
       Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
       Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6) Bool -> Bool -> Bool
&&
       Char
c7 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a 9-tuple whose elements match the characters?
equals9 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals9 :: Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Bytes
-> Bool
equals9 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 !Char
c7 !Char
c8 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
9 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
       Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
       Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
       Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
       Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
       Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
       Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6) Bool -> Bool -> Bool
&&
       Char
c7 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7) Bool -> Bool -> Bool
&&
       Char
c8 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
8)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a 10-tuple whose elements match the characters?
equals10 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals10 :: Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Bytes
-> Bool
equals10 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 !Char
c7 !Char
c8 !Char
c9 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
10 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
        Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
        Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
        Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
        Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
        Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
        Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6) Bool -> Bool -> Bool
&&
        Char
c7 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7) Bool -> Bool -> Bool
&&
        Char
c8 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
8) Bool -> Bool -> Bool
&&
        Char
c9 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
9)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a 11-tuple whose elements match the characters?
equals11 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals11 :: Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Bytes
-> Bool
equals11 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 !Char
c7 !Char
c8 !Char
c9 !Char
c10 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
11 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
        Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
        Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
        Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
        Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
        Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
        Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6) Bool -> Bool -> Bool
&&
        Char
c7 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7) Bool -> Bool -> Bool
&&
        Char
c8 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
8) Bool -> Bool -> Bool
&&
        Char
c9 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
9) Bool -> Bool -> Bool
&&
        Char
c10 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
10)
  Int
_ -> Bool
False

-- | Is the byte sequence, when interpreted as ISO-8859-1-encoded text,
-- a 12-tuple whose elements match the characters?
equals12 :: Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Char -> Bytes -> Bool
equals12 :: Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Char
-> Bytes
-> Bool
equals12 !Char
c0 !Char
c1 !Char
c2 !Char
c3 !Char
c4 !Char
c5 !Char
c6 !Char
c7 !Char
c8 !Char
c9 !Char
c10 !Char
c11 (Bytes ByteArray
arr Int
off Int
len) = case Int
len of
  Int
12 -> Char
c0 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr Int
off Bool -> Bool -> Bool
&&
        Char
c1 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Bool -> Bool -> Bool
&&
        Char
c2 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) Bool -> Bool -> Bool
&&
        Char
c3 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Bool -> Bool -> Bool
&&
        Char
c4 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) Bool -> Bool -> Bool
&&
        Char
c5 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
5) Bool -> Bool -> Bool
&&
        Char
c6 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
6) Bool -> Bool -> Bool
&&
        Char
c7 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7) Bool -> Bool -> Bool
&&
        Char
c8 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
8) Bool -> Bool -> Bool
&&
        Char
c9 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
9) Bool -> Bool -> Bool
&&
        Char
c10 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
10) Bool -> Bool -> Bool
&&
        Char
c11 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ByteArray -> Int -> Char
indexCharArray ByteArray
arr (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
11)
  Int
_ -> Bool
False

indexCharArray :: ByteArray -> Int -> Char
indexCharArray :: ByteArray -> Int -> Char
indexCharArray (ByteArray ByteArray#
arr) (I# Int#
off) = Char# -> Char
C# (ByteArray# -> Int# -> Char#
Exts.indexCharArray# ByteArray#
arr Int#
off)