{-# language BangPatterns #-}
{-# language BinaryLiterals #-}
{-# language BlockArguments #-}
{-# language DerivingStrategies #-}
{-# language DeriveAnyClass #-}
{-# language LambdaCase #-}
{-# language MagicHash #-}
{-# language NamedFieldPuns #-}
{-# language PatternSynonyms #-}
{-# language TypeApplications #-}
{-# language UnboxedSums #-}
{-# language UnboxedTuples #-}
module Json
(
Value(..)
, Member(..)
, SyntaxException(..)
, decode
, encode
, pattern (:->)
, emptyArray
, emptyObject
, object1
, object2
, object3
, object4
, object5
, object6
, object7
, object8
, object9
, object10
, object11
, object12
) where
import Prelude hiding (Bool(True,False))
import Control.Exception (Exception)
import Control.Monad.ST (ST)
import Control.Monad.ST.Run (runSmallArrayST)
import Data.Bits ((.&.),(.|.),unsafeShiftR)
import Data.Builder.ST (Builder)
import Data.Bytes.Parser (Parser)
import Data.Bytes.Types (Bytes(..))
import Data.Char (ord)
import Data.Number.Scientific (Scientific)
import Data.Primitive (ByteArray,MutableByteArray,SmallArray)
import Data.Text.Short (ShortText)
import GHC.Exts (Char(C#),Int(I#),gtWord#,ltWord#,word2Int#,chr#)
import GHC.Word (Word8,Word16)
import qualified Prelude
import qualified Data.Builder.ST as B
import qualified Data.Bytes.Builder as BLDR
import qualified Data.Bytes.Parser as P
import qualified Data.Chunks as Chunks
import qualified Data.Text.Short.Unsafe as TS
import qualified Data.Number.Scientific as SCI
import qualified Data.Primitive as PM
import qualified Data.Bytes.Parser.Utf8 as Utf8
import qualified Data.Bytes.Parser.Latin as Latin
import qualified Data.ByteString.Short.Internal as BSS
import qualified Data.Bytes.Parser.Unsafe as Unsafe
import qualified GHC.Word.Compat
data Value
= Object !(SmallArray Member)
| Array !(SmallArray Value)
| String {-# UNPACK #-} !ShortText
| Number {-# UNPACK #-} !Scientific
| Null
| True
| False
deriving stock (Value -> Value -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Value -> Value -> Bool
$c/= :: Value -> Value -> Bool
== :: Value -> Value -> Bool
$c== :: Value -> Value -> Bool
Eq,Int -> Value -> ShowS
[Value] -> ShowS
Value -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Value] -> ShowS
$cshowList :: [Value] -> ShowS
show :: Value -> String
$cshow :: Value -> String
showsPrec :: Int -> Value -> ShowS
$cshowsPrec :: Int -> Value -> ShowS
Show)
data SyntaxException
= EmptyInput
| ExpectedColon
| ExpectedCommaOrRightBracket
| ExpectedFalse
| ExpectedNull
| ExpectedQuote
| ExpectedQuoteOrRightBrace
| ExpectedTrue
| IncompleteArray
| IncompleteEscapeSequence
| IncompleteObject
| IncompleteString
| InvalidEscapeSequence
| InvalidLeader
| InvalidNumber
| LeadingZero
| UnexpectedLeftovers
deriving stock (SyntaxException -> SyntaxException -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SyntaxException -> SyntaxException -> Bool
$c/= :: SyntaxException -> SyntaxException -> Bool
== :: SyntaxException -> SyntaxException -> Bool
$c== :: SyntaxException -> SyntaxException -> Bool
Eq,Int -> SyntaxException -> ShowS
[SyntaxException] -> ShowS
SyntaxException -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SyntaxException] -> ShowS
$cshowList :: [SyntaxException] -> ShowS
show :: SyntaxException -> String
$cshow :: SyntaxException -> String
showsPrec :: Int -> SyntaxException -> ShowS
$cshowsPrec :: Int -> SyntaxException -> ShowS
Show)
deriving anyclass (Show SyntaxException
Typeable SyntaxException
SomeException -> Maybe SyntaxException
SyntaxException -> String
SyntaxException -> SomeException
forall e.
Typeable e
-> Show e
-> (e -> SomeException)
-> (SomeException -> Maybe e)
-> (e -> String)
-> Exception e
displayException :: SyntaxException -> String
$cdisplayException :: SyntaxException -> String
fromException :: SomeException -> Maybe SyntaxException
$cfromException :: SomeException -> Maybe SyntaxException
toException :: SyntaxException -> SomeException
$ctoException :: SyntaxException -> SomeException
Exception)
data Member = Member
{ Member -> ShortText
key :: {-# UNPACK #-} !ShortText
, Member -> Value
value :: !Value
} deriving stock (Member -> Member -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Member -> Member -> Bool
$c/= :: Member -> Member -> Bool
== :: Member -> Member -> Bool
$c== :: Member -> Member -> Bool
Eq,Int -> Member -> ShowS
[Member] -> ShowS
Member -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Member] -> ShowS
$cshowList :: [Member] -> ShowS
show :: Member -> String
$cshow :: Member -> String
showsPrec :: Int -> Member -> ShowS
$cshowsPrec :: Int -> Member -> ShowS
Show)
emptyArray :: Value
{-# noinline emptyArray #-}
emptyArray :: Value
emptyArray = SmallArray Value -> Value
Array forall a. Monoid a => a
mempty
emptyObject :: Value
{-# noinline emptyObject #-}
emptyObject :: Value
emptyObject = SmallArray Member -> Value
Object forall a. Monoid a => a
mempty
isSpace :: Word8 -> Prelude.Bool
{-# inline isSpace #-}
isSpace :: Word8 -> Bool
isSpace Word8
w =
Word8
w forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
' '
Bool -> Bool -> Bool
|| Word8
w forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\t'
Bool -> Bool -> Bool
|| Word8
w forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\r'
Bool -> Bool -> Bool
|| Word8
w forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\n'
decode :: Bytes -> Either SyntaxException Value
decode :: Bytes -> Either SyntaxException Value
decode = forall e a. (forall s. Parser e s a) -> Bytes -> Either e a
P.parseBytesEither do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
Value
result <- forall e s. e -> Parser e s Char
Latin.any SyntaxException
EmptyInput forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Char -> Parser SyntaxException s Value
parser
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Parser e s ()
P.endOfInput SyntaxException
UnexpectedLeftovers
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
result
encode :: Value -> BLDR.Builder
{-# noinline encode #-}
encode :: Value -> Builder
encode Value
v0 = Builder -> Builder
BLDR.rebuild forall a b. (a -> b) -> a -> b
$ case Value
v0 of
Value
True -> Char -> Char -> Char -> Char -> Builder
BLDR.ascii4 Char
't' Char
'r' Char
'u' Char
'e'
Value
False -> Char -> Char -> Char -> Char -> Char -> Builder
BLDR.ascii5 Char
'f' Char
'a' Char
'l' Char
's' Char
'e'
Value
Null -> Char -> Char -> Char -> Char -> Builder
BLDR.ascii4 Char
'n' Char
'u' Char
'l' Char
'l'
String ShortText
s -> ShortText -> Builder
BLDR.shortTextJsonString ShortText
s
Number Scientific
n -> Scientific -> Builder
SCI.builderUtf8 Scientific
n
Array SmallArray Value
ys -> case forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray Value
ys of
Int
0 -> Char -> Char -> Builder
BLDR.ascii2 Char
'[' Char
']'
Int
_ ->
let !(# Value
z #) = forall a. SmallArray a -> Int -> (# a #)
PM.indexSmallArray## SmallArray Value
ys Int
0
in Char -> Builder
BLDR.ascii Char
'['
forall a. Semigroup a => a -> a -> a
<>
Value -> Builder
encode Value
z
forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b -> b) -> b -> SmallArray a -> b
foldrTail
( \Value
v Builder
b -> Char -> Builder
BLDR.ascii Char
',' forall a. Semigroup a => a -> a -> a
<> Value -> Builder
encode Value
v forall a. Semigroup a => a -> a -> a
<> Builder
b
) (Char -> Builder
BLDR.ascii Char
']') SmallArray Value
ys
Object SmallArray Member
ys -> case forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray Member
ys of
Int
0 -> Char -> Char -> Builder
BLDR.ascii2 Char
'{' Char
'}'
Int
_ ->
let !(# Member
z #) = forall a. SmallArray a -> Int -> (# a #)
PM.indexSmallArray## SmallArray Member
ys Int
0
in Char -> Builder
BLDR.ascii Char
'{'
forall a. Semigroup a => a -> a -> a
<>
Member -> Builder
encodeMember Member
z
forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b -> b) -> b -> SmallArray a -> b
foldrTail
( \Member
v Builder
b -> Char -> Builder
BLDR.ascii Char
',' forall a. Semigroup a => a -> a -> a
<> Member -> Builder
encodeMember Member
v forall a. Semigroup a => a -> a -> a
<> Builder
b
) (Char -> Builder
BLDR.ascii Char
'}') SmallArray Member
ys
encodeMember :: Member -> BLDR.Builder
encodeMember :: Member -> Builder
encodeMember Member{ShortText
key :: ShortText
key :: Member -> ShortText
key,Value
value :: Value
value :: Member -> Value
value} =
ShortText -> Builder
BLDR.shortTextJsonString ShortText
key
forall a. Semigroup a => a -> a -> a
<>
Char -> Builder
BLDR.ascii Char
':'
forall a. Semigroup a => a -> a -> a
<>
Value -> Builder
encode Value
value
foldrTail :: (a -> b -> b) -> b -> PM.SmallArray a -> b
{-# inline foldrTail #-}
foldrTail :: forall a b. (a -> b -> b) -> b -> SmallArray a -> b
foldrTail a -> b -> b
f b
z !SmallArray a
ary = Int -> b
go Int
1 where
!sz :: Int
sz = forall a. SmallArray a -> Int
PM.sizeofSmallArray SmallArray a
ary
go :: Int -> b
go Int
i
| Int
i forall a. Eq a => a -> a -> Bool
== Int
sz = b
z
| (# a
x #) <- forall a. SmallArray a -> Int -> (# a #)
PM.indexSmallArray## SmallArray a
ary Int
i
= a -> b -> b
f a
x (Int -> b
go (Int
iforall a. Num a => a -> a -> a
+Int
1))
parser :: Char -> Parser SyntaxException s Value
parser :: forall s. Char -> Parser SyntaxException s Value
parser = \case
Char
'{' -> forall s. Parser SyntaxException s Value
objectTrailedByBrace
Char
'[' -> forall s. Parser SyntaxException s Value
arrayTrailedByBracket
Char
't' -> do
forall e s. e -> Char -> Char -> Char -> Parser e s ()
Latin.char3 SyntaxException
ExpectedTrue Char
'r' Char
'u' Char
'e'
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
True
Char
'f' -> do
forall e s. e -> Char -> Char -> Char -> Char -> Parser e s ()
Latin.char4 SyntaxException
ExpectedFalse Char
'a' Char
'l' Char
's' Char
'e'
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
False
Char
'n' -> do
forall e s. e -> Char -> Char -> Char -> Parser e s ()
Latin.char3 SyntaxException
ExpectedNull Char
'u' Char
'l' Char
'l'
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
Null
Char
'"' -> do
Int
start <- forall e s. Parser e s Int
Unsafe.cursor
forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
string ShortText -> Value
String Int
start
Char
'-' -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Scientific -> Value
Number (forall e s. e -> Parser e s Scientific
SCI.parserNegatedUtf8Bytes SyntaxException
InvalidNumber)
Char
'0' -> forall e s. (Char -> Bool) -> Parser e s Bool
Latin.trySatisfy (\Char
c -> Char
c forall a. Ord a => a -> a -> Bool
>= Char
'0' Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
'9') forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
Prelude.True -> forall e s a. e -> Parser e s a
P.fail SyntaxException
LeadingZero
Bool
Prelude.False -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Scientific -> Value
Number (forall e s. e -> Int -> Parser e s Scientific
SCI.parserTrailingUtf8Bytes SyntaxException
InvalidNumber Int
0)
Char
c | Char
c forall a. Ord a => a -> a -> Bool
>= Char
'1' Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
'9' ->
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Scientific -> Value
Number (forall e s. e -> Int -> Parser e s Scientific
SCI.parserTrailingUtf8Bytes SyntaxException
InvalidNumber (Char -> Int
ord Char
c forall a. Num a => a -> a -> a
- Int
48))
Char
_ -> forall e s a. e -> Parser e s a
P.fail SyntaxException
InvalidLeader
objectTrailedByBrace :: Parser SyntaxException s Value
{-# inline objectTrailedByBrace #-}
objectTrailedByBrace :: forall s. Parser SyntaxException s Value
objectTrailedByBrace = do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteObject forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Char
'}' -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
emptyObject
Char
'"' -> do
Int
start <- forall e s. Parser e s Int
Unsafe.cursor
!ShortText
theKey <- forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
string forall a. a -> a
id Int
start
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Char -> Parser e s ()
Latin.char SyntaxException
ExpectedColon Char
':'
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
Value
val <- forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteObject forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Char -> Parser SyntaxException s Value
parser
let !mbr :: Member
mbr = ShortText -> Value -> Member
Member ShortText
theKey Value
val
!Builder s Member
b0 <- forall s a e. ST s a -> Parser e s a
P.effect forall s a. ST s (Builder s a)
B.new
Builder s Member
b1 <- forall s a e. ST s a -> Parser e s a
P.effect (forall a s. a -> Builder s a -> ST s (Builder s a)
B.push Member
mbr Builder s Member
b0)
forall s. Builder s Member -> Parser SyntaxException s Value
objectStep Builder s Member
b1
Char
_ -> forall e s a. e -> Parser e s a
P.fail SyntaxException
ExpectedQuoteOrRightBrace
objectStep :: Builder s Member -> Parser SyntaxException s Value
objectStep :: forall s. Builder s Member -> Parser SyntaxException s Value
objectStep !Builder s Member
b = do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteObject forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Char
',' -> do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Char -> Parser e s ()
Latin.char SyntaxException
ExpectedQuote Char
'"'
Int
start <- forall e s. Parser e s Int
Unsafe.cursor
!ShortText
theKey <- forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
string forall a. a -> a
id Int
start
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Char -> Parser e s ()
Latin.char SyntaxException
ExpectedColon Char
':'
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
Value
val <- forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteObject forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Char -> Parser SyntaxException s Value
parser
let !mbr :: Member
mbr = ShortText -> Value -> Member
Member ShortText
theKey Value
val
forall s a e. ST s a -> Parser e s a
P.effect (forall a s. a -> Builder s a -> ST s (Builder s a)
B.push Member
mbr Builder s Member
b) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Builder s Member -> Parser SyntaxException s Value
objectStep
Char
'}' -> do
!Chunks Member
r <- forall s a e. ST s a -> Parser e s a
P.effect (forall s a. Builder s a -> ST s (Chunks a)
B.freeze Builder s Member
b)
let !arr :: SmallArray Member
arr = forall a. Chunks a -> SmallArray a
Chunks.concat Chunks Member
r
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SmallArray Member -> Value
Object SmallArray Member
arr)
Char
_ -> forall e s a. e -> Parser e s a
P.fail SyntaxException
ExpectedCommaOrRightBracket
arrayTrailedByBracket :: Parser SyntaxException s Value
{-# inline arrayTrailedByBracket #-}
arrayTrailedByBracket :: forall s. Parser SyntaxException s Value
arrayTrailedByBracket = do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteArray forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Char
']' -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
emptyArray
Char
c -> do
!Builder s Value
b0 <- forall s a e. ST s a -> Parser e s a
P.effect forall s a. ST s (Builder s a)
B.new
Value
val <- forall s. Char -> Parser SyntaxException s Value
parser Char
c
Builder s Value
b1 <- forall s a e. ST s a -> Parser e s a
P.effect (forall a s. a -> Builder s a -> ST s (Builder s a)
B.push Value
val Builder s Value
b0)
forall s. Builder s Value -> Parser SyntaxException s Value
arrayStep Builder s Value
b1
arrayStep :: Builder s Value -> Parser SyntaxException s Value
arrayStep :: forall s. Builder s Value -> Parser SyntaxException s Value
arrayStep !Builder s Value
b = do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteArray forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Char
',' -> do
forall e s. (Word8 -> Bool) -> Parser e s ()
P.skipWhile Word8 -> Bool
isSpace
Value
val <- forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteArray forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Char -> Parser SyntaxException s Value
parser
forall s a e. ST s a -> Parser e s a
P.effect (forall a s. a -> Builder s a -> ST s (Builder s a)
B.push Value
val Builder s Value
b) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall s. Builder s Value -> Parser SyntaxException s Value
arrayStep
Char
']' -> do
!Chunks Value
r <- forall s a e. ST s a -> Parser e s a
P.effect (forall s a. Builder s a -> ST s (Chunks a)
B.freeze Builder s Value
b)
let !arr :: SmallArray Value
arr = forall a. Chunks a -> SmallArray a
Chunks.concat Chunks Value
r
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SmallArray Value -> Value
Array SmallArray Value
arr)
Char
_ -> forall e s a. e -> Parser e s a
P.fail SyntaxException
ExpectedCommaOrRightBracket
c2w :: Char -> Word8
c2w :: Char -> Word8
c2w = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord
string :: (ShortText -> a) -> Int -> Parser SyntaxException s a
{-# inline string #-}
string :: forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
string ShortText -> a
wrap !Int
start = forall {s}. Int -> Parser SyntaxException s a
go Int
1 where
go :: Int -> Parser SyntaxException s a
go !Int
canMemcpy = do
forall e s. e -> Parser e s Word8
P.any SyntaxException
IncompleteString forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word8
92 -> forall e s. e -> Parser e s Word8
P.any SyntaxException
InvalidEscapeSequence forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> Parser SyntaxException s a
go Int
0
Word8
34 -> do
!Int
pos <- forall e s. Parser e s Int
Unsafe.cursor
case Int
canMemcpy of
Int
1 -> do
ByteArray
src <- forall e s. Parser e s ByteArray
Unsafe.expose
ByteArray
str <- forall s a e. ST s a -> Parser e s a
P.effect forall a b. (a -> b) -> a -> b
$ do
let end :: Int
end = Int
pos forall a. Num a => a -> a -> a
- Int
1
let len :: Int
len = Int
end forall a. Num a => a -> a -> a
- Int
start
MutableByteArray s
dst <- forall (m :: * -> *).
PrimMonad m =>
Int -> m (MutableByteArray (PrimState m))
PM.newByteArray Int
len
forall (m :: * -> *).
PrimMonad m =>
MutableByteArray (PrimState m)
-> Int -> ByteArray -> Int -> Int -> m ()
PM.copyByteArray MutableByteArray s
dst Int
0 ByteArray
src Int
start Int
len
forall (m :: * -> *).
PrimMonad m =>
MutableByteArray (PrimState m) -> m ByteArray
PM.unsafeFreezeByteArray MutableByteArray s
dst
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShortText -> a
wrap (ShortByteString -> ShortText
TS.fromShortByteStringUnsafe (ByteArray -> ShortByteString
byteArrayToShortByteString ByteArray
str)))
Int
_ -> do
forall e s. Int -> Parser e s ()
Unsafe.unconsume (Int
pos forall a. Num a => a -> a -> a
- Int
start)
let end :: Int
end = Int
pos forall a. Num a => a -> a -> a
- Int
1
let maxLen :: Int
maxLen = Int
end forall a. Num a => a -> a -> a
- Int
start
forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
copyAndEscape ShortText -> a
wrap Int
maxLen
GHC.Word.Compat.W8# Word#
w -> Int -> Parser SyntaxException s a
go (Int
canMemcpy forall a. Bits a => a -> a -> a
.&. Int# -> Int
I# (Word# -> Word# -> Int#
ltWord# Word#
w Word#
128##) forall a. Bits a => a -> a -> a
.&. Int# -> Int
I# (Word# -> Word# -> Int#
gtWord# Word#
w Word#
31##))
copyAndEscape :: (ShortText -> a) -> Int -> Parser SyntaxException s a
{-# inline copyAndEscape #-}
copyAndEscape :: forall a s. (ShortText -> a) -> Int -> Parser SyntaxException s a
copyAndEscape ShortText -> a
wrap !Int
maxLen = do
!MutableByteArray s
dst <- forall s a e. ST s a -> Parser e s a
P.effect (forall (m :: * -> *).
PrimMonad m =>
Int -> m (MutableByteArray (PrimState m))
PM.newByteArray Int
maxLen)
let go :: Int -> Parser SyntaxException s a
go !Int
ix = forall e s. e -> Parser e s Char#
Utf8.any# SyntaxException
IncompleteString forall s e a.
Parser s e Char# -> (Char# -> Parser s e a) -> Parser s e a
`P.bindFromCharToLifted` \Char#
c -> case Char#
c of
Char#
'\\'# -> forall e s. e -> Parser e s Char
Latin.any SyntaxException
IncompleteEscapeSequence forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Char
'"' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'"'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'\\' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\\'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
't' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\t'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'n' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\n'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'r' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\r'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'/' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'/'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'b' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\b'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'f' -> do
forall s a e. ST s a -> Parser e s a
P.effect (forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
dst Int
ix (Char -> Word8
c2w Char
'\f'))
Int -> Parser SyntaxException s a
go (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
Char
'u' -> do
Word16
w <- forall e s. e -> Parser e s Word16
Latin.hexFixedWord16 SyntaxException
InvalidEscapeSequence
if Word16
w forall a. Ord a => a -> a -> Bool
>= Word16
0xD800 Bool -> Bool -> Bool
&& Word16
w forall a. Ord a => a -> a -> Bool
< Word16
0xDFFF
then Int -> Parser SyntaxException s a
go forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s a e. ST s a -> Parser e s a
P.effect (forall s. MutableByteArray s -> Int -> Char -> ST s Int
encodeUtf8Char MutableByteArray s
dst Int
ix Char
'\xFFFD')
else Int -> Parser SyntaxException s a
go forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s a e. ST s a -> Parser e s a
P.effect (forall s. MutableByteArray s -> Int -> Char -> ST s Int
encodeUtf8Char MutableByteArray s
dst Int
ix (Word16 -> Char
w16ToChar Word16
w))
Char
_ -> forall e s a. e -> Parser e s a
P.fail SyntaxException
InvalidEscapeSequence
Char#
'"'# -> do
ByteArray
str <- forall s a e. ST s a -> Parser e s a
P.effect
(forall (m :: * -> *).
PrimMonad m =>
MutableByteArray (PrimState m) -> m ByteArray
PM.unsafeFreezeByteArray forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (m :: * -> *).
PrimMonad m =>
MutableByteArray (PrimState m)
-> Int -> m (MutableByteArray (PrimState m))
PM.resizeMutableByteArray MutableByteArray s
dst Int
ix)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ShortText -> a
wrap (ShortByteString -> ShortText
TS.fromShortByteStringUnsafe (ByteArray -> ShortByteString
byteArrayToShortByteString ByteArray
str)))
Char#
_ -> Int -> Parser SyntaxException s a
go forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s a e. ST s a -> Parser e s a
P.effect (forall s. MutableByteArray s -> Int -> Char -> ST s Int
encodeUtf8Char MutableByteArray s
dst Int
ix (Char# -> Char
C# Char#
c))
Int -> Parser SyntaxException s a
go Int
0
encodeUtf8Char :: MutableByteArray s -> Int -> Char -> ST s Int
encodeUtf8Char :: forall s. MutableByteArray s -> Int -> Char -> ST s Int
encodeUtf8Char !MutableByteArray s
marr !Int
ix !Char
c
| Char
c forall a. Ord a => a -> a -> Bool
< Char
'\128' = do
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr Int
ix (Char -> Word8
c2w Char
c)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
| Char
c forall a. Ord a => a -> a -> Bool
< Char
'\x0800' = do
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr Int
ix
(forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
6 forall a. Bits a => a -> a -> a
.|. Int
0b11000000))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (Char -> Int
ord Char
c))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ix forall a. Num a => a -> a -> a
+ Int
2)
| Char
c forall a. Ord a => a -> a -> Bool
<= Char
'\xffff' = do
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr Int
ix
(forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
12 forall a. Bits a => a -> a -> a
.|. Int
0b11100000))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
6))))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
2)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (Char -> Int
ord Char
c))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ix forall a. Num a => a -> a -> a
+ Int
3)
| Bool
otherwise = do
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr Int
ix
(forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
18 forall a. Bits a => a -> a -> a
.|. Int
0b11110000))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
1)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
12))))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
2)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (forall a. Bits a => a -> Int -> a
unsafeShiftR (Char -> Int
ord Char
c) Int
6))))
forall a (m :: * -> *).
(Prim a, PrimMonad m) =>
MutableByteArray (PrimState m) -> Int -> a -> m ()
PM.writeByteArray MutableByteArray s
marr (Int
ix forall a. Num a => a -> a -> a
+ Int
3)
(Word8
0b10000000 forall a. Bits a => a -> a -> a
.|. (Word8
0b00111111 forall a. Bits a => a -> a -> a
.&. (forall a b. (Integral a, Num b) => a -> b
fromIntegral @Int @Word8 (Char -> Int
ord Char
c))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
ix forall a. Num a => a -> a -> a
+ Int
4)
byteArrayToShortByteString :: ByteArray -> BSS.ShortByteString
byteArrayToShortByteString :: ByteArray -> ShortByteString
byteArrayToShortByteString (PM.ByteArray ByteArray#
x) = ByteArray# -> ShortByteString
BSS.SBS ByteArray#
x
w16ToChar :: Word16 -> Char
w16ToChar :: Word16 -> Char
w16ToChar (GHC.Word.Compat.W16# Word#
w) = Char# -> Char
C# (Int# -> Char#
chr# (Word# -> Int#
word2Int# Word#
w))
pattern (:->) :: ShortText -> Value -> Member
pattern key $b:-> :: ShortText -> Value -> Member
$m:-> :: forall {r}.
Member -> (ShortText -> Value -> r) -> ((# #) -> r) -> r
:-> value = Member{key,value}
object1 :: Member -> Value
{-# inline object1 #-}
object1 :: Member -> Value
object1 Member
a = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
1 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object2 :: Member -> Member -> Value
{-# inline object2 #-}
object2 :: Member -> Member -> Value
object2 Member
a Member
b = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
2 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object3 :: Member -> Member -> Member -> Value
{-# inline object3 #-}
object3 :: Member -> Member -> Member -> Value
object3 Member
a Member
b Member
c = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
3 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object4 :: Member -> Member -> Member -> Member -> Value
{-# inline object4 #-}
object4 :: Member -> Member -> Member -> Member -> Value
object4 Member
a Member
b Member
c Member
d = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
4 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object5 :: Member -> Member -> Member -> Member -> Member -> Value
{-# inline object5 #-}
object5 :: Member -> Member -> Member -> Member -> Member -> Value
object5 Member
a Member
b Member
c Member
d Member
e = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
5 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object6 :: Member -> Member -> Member -> Member -> Member -> Member -> Value
{-# inline object6 #-}
object6 :: Member -> Member -> Member -> Member -> Member -> Member -> Value
object6 Member
a Member
b Member
c Member
d Member
e Member
f = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
6 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object7 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
{-# inline object7 #-}
object7 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object7 Member
a Member
b Member
c Member
d Member
e Member
f Member
g = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
7 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object8 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
{-# inline object8 #-}
object8 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object8 Member
a Member
b Member
c Member
d Member
e Member
f Member
g Member
h = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
8 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
7 Member
h
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object9 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member
-> Value
{-# inline object9 #-}
object9 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object9 Member
a Member
b Member
c Member
d Member
e Member
f Member
g Member
h Member
i = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
9 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
7 Member
h
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
8 Member
i
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object10 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member
-> Member -> Member -> Value
{-# inline object10 #-}
object10 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object10 Member
a Member
b Member
c Member
d Member
e Member
f Member
g Member
h Member
i Member
j = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
10 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
7 Member
h
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
8 Member
i
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
9 Member
j
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object11 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member
-> Member -> Member -> Member -> Value
{-# inline object11 #-}
object11 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object11 Member
a Member
b Member
c Member
d Member
e Member
f Member
g Member
h Member
i Member
j Member
k = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
11 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
7 Member
h
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
8 Member
i
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
9 Member
j
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
10 Member
k
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst
object12 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member
-> Member -> Member -> Member -> Member -> Value
{-# inline object12 #-}
object12 :: Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Member
-> Value
object12 Member
a Member
b Member
c Member
d Member
e Member
f Member
g Member
h Member
i Member
j Member
k Member
l = SmallArray Member -> Value
Object forall a b. (a -> b) -> a -> b
$ forall a. (forall s. ST s (SmallArray a)) -> SmallArray a
runSmallArrayST forall a b. (a -> b) -> a -> b
$ do
SmallMutableArray s Member
dst <- forall (m :: * -> *) a.
PrimMonad m =>
Int -> a -> m (SmallMutableArray (PrimState m) a)
PM.newSmallArray Int
12 Member
a
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
1 Member
b
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
2 Member
c
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
3 Member
d
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
4 Member
e
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
5 Member
f
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
6 Member
g
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
7 Member
h
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
8 Member
i
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
9 Member
j
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
10 Member
k
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> Int -> a -> m ()
PM.writeSmallArray SmallMutableArray s Member
dst Int
11 Member
l
forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableArray (PrimState m) a -> m (SmallArray a)
PM.unsafeFreezeSmallArray SmallMutableArray s Member
dst