Movatterモバイル変換
[0]ホーム
{-# LANGUAGE Trustworthy #-}{-# LANGUAGE NoImplicitPrelude , BangPatterns , NondecreasingIndentation , MagicHash , UnboxedTuples #-}{-# OPTIONS_GHC -funbox-strict-fields #-}------------------------------------------------------------------------------- |-- Module : GHC.IO.Encoding.UTF16-- Copyright : (c) The University of Glasgow, 2009-- License : see libraries/base/LICENSE---- Maintainer : libraries@haskell.org-- Stability : internal-- Portability : non-portable---- UTF-16 Codecs for the IO library---- Portions Copyright : (c) Tom Harper 2008-2009,-- (c) Bryan O'Sullivan 2009,-- (c) Duncan Coutts 2009-------------------------------------------------------------------------------moduleGHC.IO.Encoding.UTF16(utf16,mkUTF16,utf16_decode,utf16_encode,utf16be,mkUTF16be,utf16be_decode,utf16be_encode,utf16le,mkUTF16le,utf16le_decode,utf16le_encode,)whereimportGHC.BaseimportGHC.RealimportGHC.Num-- import GHC.IOimportGHC.IO.BufferimportGHC.IO.Encoding.FailureimportGHC.IO.Encoding.TypesimportGHC.WordimportData.BitsimportGHC.IORef-- ------------------------------------------------------------------------------- The UTF-16 codec: either UTF16BE or UTF16LE with a BOMutf16::TextEncodingutf16 :: TextEncodingutf16=CodingFailureMode -> TextEncodingmkUTF16CodingFailureModeErrorOnCodingFailure-- | @since 4.4.0.0mkUTF16::CodingFailureMode->TextEncodingmkUTF16 :: CodingFailureMode -> TextEncodingmkUTF16CodingFailureModecfm=TextEncoding{textEncodingName :: StringtextEncodingName=String"UTF-16",mkTextDecoder :: IO (TextDecoder (Maybe DecodeBuffer#))mkTextDecoder=CodingFailureMode -> IO (TextDecoder (Maybe DecodeBuffer#))utf16_DFCodingFailureModecfm,mkTextEncoder :: IO (TextEncoder Bool)mkTextEncoder=CodingFailureMode -> IO (TextEncoder Bool)utf16_EFCodingFailureModecfm}utf16_DF::CodingFailureMode->IO(TextDecoder(MaybeDecodeBuffer#))utf16_DF :: CodingFailureMode -> IO (TextDecoder (Maybe DecodeBuffer#))utf16_DFCodingFailureModecfm=doIORef (Maybe DecodeBuffer#)seen_bom<-Maybe DecodeBuffer# -> IO (IORef (Maybe DecodeBuffer#))forall a. a -> IO (IORef a)newIORefMaybe DecodeBuffer#forall a. Maybe aNothingTextDecoder (Maybe DecodeBuffer#)-> IO (TextDecoder (Maybe DecodeBuffer#))forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: DecodeBuffer#encode#=IORef (Maybe DecodeBuffer#) -> DecodeBuffer#utf16_decodeIORef (Maybe DecodeBuffer#)seen_bom,recover# :: Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recover#=CodingFailureMode-> Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recoverDecode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO (Maybe DecodeBuffer#)getState#=IORef (Maybe DecodeBuffer#) -> IO (Maybe DecodeBuffer#)forall a. IORef a -> IO areadIORefIORef (Maybe DecodeBuffer#)seen_bom,setState# :: Maybe DecodeBuffer# -> IO ()setState#=IORef (Maybe DecodeBuffer#) -> Maybe DecodeBuffer# -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef (Maybe DecodeBuffer#)seen_bom})utf16_EF::CodingFailureMode->IO(TextEncoderBool)utf16_EF :: CodingFailureMode -> IO (TextEncoder Bool)utf16_EFCodingFailureModecfm=doIORef Booldone_bom<-Bool -> IO (IORef Bool)forall a. a -> IO (IORef a)newIORefBoolFalseTextEncoder Bool -> IO (TextEncoder Bool)forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: CodeBuffer# Char Word8encode#=IORef Bool -> CodeBuffer# Char Word8utf16_encodeIORef Booldone_bom,recover# :: Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recover#=CodingFailureMode-> Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recoverEncode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO BoolgetState#=IORef Bool -> IO Boolforall a. IORef a -> IO areadIORefIORef Booldone_bom,setState# :: Bool -> IO ()setState#=IORef Bool -> Bool -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef Booldone_bom})utf16_encode::IORefBool->EncodeBuffer#utf16_encode :: IORef Bool -> CodeBuffer# Char Word8utf16_encodeIORef Booldone_bomBuffer Charinputoutput :: Buffer Word8output@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8oraw,bufL :: forall e. Buffer e -> IntbufL=Int_,bufR :: forall e. Buffer e -> IntbufR=Intow,bufSize :: forall e. Buffer e -> IntbufSize=Intos}State# RealWorldst0=dolet!(#State# RealWorldst1,Boolb#)=IO Bool -> State# RealWorld -> (# State# RealWorld, Bool #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef Bool -> IO Boolforall a. IORef a -> IO areadIORefIORef Booldone_bom)State# RealWorldst0ifBoolbthenCodeBuffer# Char Word8utf16_native_encodeBuffer CharinputBuffer Word8outputState# RealWorldst1elseifIntosInt -> Int -> Intforall a. Num a => a -> a -> a-IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int2then(#State# RealWorldst1,CodingProgressOutputUnderflow,Buffer Charinput,Buffer Word8output#)elsedolet!(#State# RealWorldst2,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef Bool -> Bool -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef Booldone_bomBoolTrue)State# RealWorldst1!(#State# RealWorldst3,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8orawIntowWord8bom1)State# RealWorldst2!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int1)Word8bom2)State# RealWorldst3CodeBuffer# Char Word8utf16_native_encodeBuffer CharinputBuffer Word8output{bufR=ow+2}State# RealWorldst4utf16_decode::IORef(MaybeDecodeBuffer#)->DecodeBuffer#utf16_decode :: IORef (Maybe DecodeBuffer#) -> DecodeBuffer#utf16_decodeIORef (Maybe DecodeBuffer#)seen_bominput :: Buffer Word8input@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8iraw,bufL :: forall e. Buffer e -> IntbufL=Intir,bufR :: forall e. Buffer e -> IntbufR=Intiw,bufSize :: forall e. Buffer e -> IntbufSize=Int_}Buffer CharoutputState# RealWorldst0=dolet!(#State# RealWorldst1,Maybe DecodeBuffer#mb#)=IO (Maybe DecodeBuffer#)-> State# RealWorld -> (# State# RealWorld, Maybe DecodeBuffer# #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef (Maybe DecodeBuffer#) -> IO (Maybe DecodeBuffer#)forall a. IORef a -> IO areadIORefIORef (Maybe DecodeBuffer#)seen_bom)State# RealWorldst0caseMaybe DecodeBuffer#mbofJustDecodeBuffer#decode->DecodeBuffer#decodeBuffer Word8inputBuffer CharoutputState# RealWorldst1Maybe DecodeBuffer#Nothing->ifIntiwInt -> Int -> Intforall a. Num a => a -> a -> a-IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int2then(#State# RealWorldst1,CodingProgressInputUnderflow,Buffer Word8input,Buffer Charoutput#)elsedolet!(#State# RealWorldst2,Word8c0#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8irawIntir)State# RealWorldst1!(#State# RealWorldst3,Word8c1#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int1))State# RealWorldst2case()of()_|Word8c0Word8 -> Word8 -> Boolforall a. Eq a => a -> a -> Bool==Word8bomBBool -> Bool -> Bool&&Word8c1Word8 -> Word8 -> Boolforall a. Eq a => a -> a -> Bool==Word8bomL->let!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef (Maybe DecodeBuffer#) -> Maybe DecodeBuffer# -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef (Maybe DecodeBuffer#)seen_bom(DecodeBuffer# -> Maybe DecodeBuffer#forall a. a -> Maybe aJustDecodeBuffer#utf16be_decode))State# RealWorldst3inDecodeBuffer#utf16be_decodeBuffer Word8input{bufL=ir+2}Buffer CharoutputState# RealWorldst4|Word8c0Word8 -> Word8 -> Boolforall a. Eq a => a -> a -> Bool==Word8bomLBool -> Bool -> Bool&&Word8c1Word8 -> Word8 -> Boolforall a. Eq a => a -> a -> Bool==Word8bomB->let!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef (Maybe DecodeBuffer#) -> Maybe DecodeBuffer# -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef (Maybe DecodeBuffer#)seen_bom(DecodeBuffer# -> Maybe DecodeBuffer#forall a. a -> Maybe aJustDecodeBuffer#utf16le_decode))State# RealWorldst3inDecodeBuffer#utf16le_decodeBuffer Word8input{bufL=ir+2}Buffer CharoutputState# RealWorldst4|Boolotherwise->let!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(IORef (Maybe DecodeBuffer#) -> Maybe DecodeBuffer# -> IO ()forall a. IORef a -> a -> IO ()writeIORefIORef (Maybe DecodeBuffer#)seen_bom(DecodeBuffer# -> Maybe DecodeBuffer#forall a. a -> Maybe aJustDecodeBuffer#utf16_native_decode))State# RealWorldst3inDecodeBuffer#utf16_native_decodeBuffer Word8inputBuffer CharoutputState# RealWorldst4bomB,bomL,bom1,bom2::Word8bomB :: Word8bomB=Word80xfebomL :: Word8bomL=Word80xff-- choose UTF-16BE by default for UTF-16 outpututf16_native_decode::DecodeBuffer#utf16_native_decode :: DecodeBuffer#utf16_native_decode=DecodeBuffer#utf16be_decodeutf16_native_encode::EncodeBuffer#utf16_native_encode :: CodeBuffer# Char Word8utf16_native_encode=CodeBuffer# Char Word8utf16be_encodebom1 :: Word8bom1=Word8bomBbom2 :: Word8bom2=Word8bomL-- ------------------------------------------------------------------------------- UTF16LE and UTF16BEutf16be::TextEncodingutf16be :: TextEncodingutf16be=CodingFailureMode -> TextEncodingmkUTF16beCodingFailureModeErrorOnCodingFailure-- | @since 4.4.0.0mkUTF16be::CodingFailureMode->TextEncodingmkUTF16be :: CodingFailureMode -> TextEncodingmkUTF16beCodingFailureModecfm=TextEncoding{textEncodingName :: StringtextEncodingName=String"UTF-16BE",mkTextDecoder :: IO (TextDecoder ())mkTextDecoder=CodingFailureMode -> IO (TextDecoder ())utf16be_DFCodingFailureModecfm,mkTextEncoder :: IO (TextEncoder ())mkTextEncoder=CodingFailureMode -> IO (TextEncoder ())utf16be_EFCodingFailureModecfm}utf16be_DF::CodingFailureMode->IO(TextDecoder())utf16be_DF :: CodingFailureMode -> IO (TextDecoder ())utf16be_DFCodingFailureModecfm=TextDecoder () -> IO (TextDecoder ())forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: DecodeBuffer#encode#=DecodeBuffer#utf16be_decode,recover# :: Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recover#=CodingFailureMode-> Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recoverDecode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO ()getState#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),setState# :: () -> IO ()setState#=IO () -> () -> IO ()forall a b. a -> b -> aconst(IO () -> () -> IO ()) -> IO () -> () -> IO ()forall a b. (a -> b) -> a -> b$() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn()})utf16be_EF::CodingFailureMode->IO(TextEncoder())utf16be_EF :: CodingFailureMode -> IO (TextEncoder ())utf16be_EFCodingFailureModecfm=TextEncoder () -> IO (TextEncoder ())forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: CodeBuffer# Char Word8encode#=CodeBuffer# Char Word8utf16be_encode,recover# :: Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recover#=CodingFailureMode-> Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recoverEncode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO ()getState#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),setState# :: () -> IO ()setState#=IO () -> () -> IO ()forall a b. a -> b -> aconst(IO () -> () -> IO ()) -> IO () -> () -> IO ()forall a b. (a -> b) -> a -> b$() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn()})utf16le::TextEncodingutf16le :: TextEncodingutf16le=CodingFailureMode -> TextEncodingmkUTF16leCodingFailureModeErrorOnCodingFailure-- | @since 4.4.0.0mkUTF16le::CodingFailureMode->TextEncodingmkUTF16le :: CodingFailureMode -> TextEncodingmkUTF16leCodingFailureModecfm=TextEncoding{textEncodingName :: StringtextEncodingName=String"UTF16-LE",mkTextDecoder :: IO (TextDecoder ())mkTextDecoder=CodingFailureMode -> IO (TextDecoder ())utf16le_DFCodingFailureModecfm,mkTextEncoder :: IO (TextEncoder ())mkTextEncoder=CodingFailureMode -> IO (TextEncoder ())utf16le_EFCodingFailureModecfm}utf16le_DF::CodingFailureMode->IO(TextDecoder())utf16le_DF :: CodingFailureMode -> IO (TextDecoder ())utf16le_DFCodingFailureModecfm=TextDecoder () -> IO (TextDecoder ())forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: DecodeBuffer#encode#=DecodeBuffer#utf16le_decode,recover# :: Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recover#=CodingFailureMode-> Buffer Word8-> Buffer Char-> State# RealWorld-> (# State# RealWorld, Buffer Word8, Buffer Char #)recoverDecode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO ()getState#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),setState# :: () -> IO ()setState#=IO () -> () -> IO ()forall a b. a -> b -> aconst(IO () -> () -> IO ()) -> IO () -> () -> IO ()forall a b. (a -> b) -> a -> b$() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn()})utf16le_EF::CodingFailureMode->IO(TextEncoder())utf16le_EF :: CodingFailureMode -> IO (TextEncoder ())utf16le_EFCodingFailureModecfm=TextEncoder () -> IO (TextEncoder ())forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(BufferCodec#{encode# :: CodeBuffer# Char Word8encode#=CodeBuffer# Char Word8utf16le_encode,recover# :: Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recover#=CodingFailureMode-> Buffer Char-> Buffer Word8-> State# RealWorld-> (# State# RealWorld, Buffer Char, Buffer Word8 #)recoverEncode#CodingFailureModecfm,close# :: IO ()close#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),getState# :: IO ()getState#=() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn(),setState# :: () -> IO ()setState#=IO () -> () -> IO ()forall a b. a -> b -> aconst(IO () -> () -> IO ()) -> IO () -> () -> IO ()forall a b. (a -> b) -> a -> b$() -> IO ()forall a. a -> IO aforall (m :: * -> *) a. Monad m => a -> m areturn()})utf16be_decode::DecodeBuffer#utf16be_decode :: DecodeBuffer#utf16be_decodeinput :: Buffer Word8input@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8iraw,bufL :: forall e. Buffer e -> IntbufL=Intir0,bufR :: forall e. Buffer e -> IntbufR=Intiw,bufSize :: forall e. Buffer e -> IntbufSize=Int_}output :: Buffer Charoutput@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Charoraw,bufL :: forall e. Buffer e -> IntbufL=Int_,bufR :: forall e. Buffer e -> IntbufR=Intow0,bufSize :: forall e. Buffer e -> IntbufSize=Intos}State# RealWorldst=letloop :: Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop!Intir!IntowState# RealWorldst0|IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intos=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst0|IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intiw=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int1Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==Intiw=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|Boolotherwise=dolet!(#State# RealWorldst1,Word8c0#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8irawIntir)State# RealWorldst0!(#State# RealWorldst2,Word8c1#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int1))State# RealWorldst1letx1 :: Word16x1=Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c0Word16 -> Int -> Word16forall a. Bits a => a -> Int -> a`shiftL`Int8Word16 -> Word16 -> Word16forall a. Num a => a -> a -> a+Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c1ifWord16 -> Boolvalidate1Word16x1thenlet!(#State# RealWorldst3,Intow'#)=IO Int -> State# RealWorld -> (# State# RealWorld, Int #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> Char -> IO IntwriteCharBufRawBuffer CharorawIntow(Int -> CharunsafeChr(Word16 -> Intforall a b. (Integral a, Num b) => a -> bfromIntegralWord16x1)))State# RealWorldst2inInt-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)Intow'State# RealWorldst3elseifIntiwInt -> Int -> Intforall a. Num a => a -> a -> a-IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int4thenCodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst2elsedolet!(#State# RealWorldst3,Word8c2#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int2))State# RealWorldst2!(#State# RealWorldst4,Word8c3#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int3))State# RealWorldst3x2 :: Word16x2=Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c2Word16 -> Int -> Word16forall a. Bits a => a -> Int -> a`shiftL`Int8Word16 -> Word16 -> Word16forall a. Num a => a -> a -> a+Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c3ifBool -> Boolnot(Word16 -> Word16 -> Boolvalidate2Word16x1Word16x2)thenState# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)invalidState# RealWorldst4elsedolet!(#State# RealWorldst5,Intow'#)=IO Int -> State# RealWorld -> (# State# RealWorld, Int #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> Char -> IO IntwriteCharBufRawBuffer CharorawIntow(Word16 -> Word16 -> Charchr2Word16x1Word16x2))State# RealWorldst4Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int4)Intow'State# RealWorldst5whereinvalid::DecodingBuffer#invalid :: State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)invalidState# RealWorldst'=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInvalidSequenceIntirIntowState# RealWorldst'-- lambda-lifted, to avoid thunks being built in the inner-loop:{-# NOINLINEdone#-}done::CodingProgress->Int->Int->DecodingBuffer#done :: CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgresswhy!Intir!IntowState# RealWorldst'=let!ri :: Buffer Word8ri=ifIntirInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==IntiwthenBuffer Word8input{bufL=0,bufR=0}elseBuffer Word8input{bufL=ir}!ro :: Buffer Charro=Buffer Charoutput{bufR=ow}in(#State# RealWorldst',CodingProgresswhy,Buffer Word8ri,Buffer Charro#)inInt-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loopIntir0Intow0State# RealWorldstutf16le_decode::DecodeBuffer#utf16le_decode :: DecodeBuffer#utf16le_decodeinput :: Buffer Word8input@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8iraw,bufL :: forall e. Buffer e -> IntbufL=Intir0,bufR :: forall e. Buffer e -> IntbufR=Intiw,bufSize :: forall e. Buffer e -> IntbufSize=Int_}output :: Buffer Charoutput@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Charoraw,bufL :: forall e. Buffer e -> IntbufL=Int_,bufR :: forall e. Buffer e -> IntbufR=Intow0,bufSize :: forall e. Buffer e -> IntbufSize=Intos}State# RealWorldst=letloop::Int->Int->DecodingBuffer#loop :: Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop!Intir!IntowState# RealWorldst0|IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intos=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst0|IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intiw=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int1Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==Intiw=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|Boolotherwise=dolet!(#State# RealWorldst1,Word8c0#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8irawIntir)State# RealWorldst0!(#State# RealWorldst2,Word8c1#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int1))State# RealWorldst1x1 :: Word16x1=Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c1Word16 -> Int -> Word16forall a. Bits a => a -> Int -> a`shiftL`Int8Word16 -> Word16 -> Word16forall a. Num a => a -> a -> a+Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c0ifWord16 -> Boolvalidate1Word16x1thenlet!(#State# RealWorldst3,Intow'#)=IO Int -> State# RealWorld -> (# State# RealWorld, Int #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> Char -> IO IntwriteCharBufRawBuffer CharorawIntow(Int -> CharunsafeChr(Word16 -> Intforall a b. (Integral a, Num b) => a -> bfromIntegralWord16x1)))State# RealWorldst2inInt-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)Intow'State# RealWorldst3elseifIntiwInt -> Int -> Intforall a. Num a => a -> a -> a-IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int4thenCodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInputUnderflowIntirIntowState# RealWorldst2elsedolet!(#State# RealWorldst3,Word8c2#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int2))State# RealWorldst2!(#State# RealWorldst4,Word8c3#)=IO Word8 -> State# RealWorld -> (# State# RealWorld, Word8 #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> IO Word8readWord8BufRawBuffer Word8iraw(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int3))State# RealWorldst3x2 :: Word16x2=Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c3Word16 -> Int -> Word16forall a. Bits a => a -> Int -> a`shiftL`Int8Word16 -> Word16 -> Word16forall a. Num a => a -> a -> a+Word8 -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegralWord8c2ifBool -> Boolnot(Word16 -> Word16 -> Boolvalidate2Word16x1Word16x2)thenState# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)invalidState# RealWorldst4elsedolet!(#State# RealWorldst5,Intow'#)=IO Int -> State# RealWorld -> (# State# RealWorld, Int #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> Char -> IO IntwriteCharBufRawBuffer CharorawIntow(Word16 -> Word16 -> Charchr2Word16x1Word16x2))State# RealWorldst4Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loop(IntirInt -> Int -> Intforall a. Num a => a -> a -> a+Int4)Intow'State# RealWorldst5whereinvalid::DecodingBuffer#invalid :: State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)invalidState# RealWorldst'=CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgressInvalidSequenceIntirIntowState# RealWorldst'-- lambda-lifted, to avoid thunks being built in the inner-loop:{-# NOINLINEdone#-}done::CodingProgress->Int->Int->DecodingBuffer#done :: CodingProgress-> Int-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)doneCodingProgresswhy!Intir!IntowState# RealWorldst'=let!ri :: Buffer Word8ri=ifIntirInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==IntiwthenBuffer Word8input{bufL=0,bufR=0}elseBuffer Word8input{bufL=ir}!ro :: Buffer Charro=Buffer Charoutput{bufR=ow}in(#State# RealWorldst',CodingProgresswhy,Buffer Word8ri,Buffer Charro#)inInt-> Int-> State# RealWorld-> (# State# RealWorld, CodingProgress, Buffer Word8, Buffer Char #)loopIntir0Intow0State# RealWorldstutf16be_encode::EncodeBuffer#utf16be_encode :: CodeBuffer# Char Word8utf16be_encodeinput :: Buffer Charinput@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Chariraw,bufL :: forall e. Buffer e -> IntbufL=Intir0,bufR :: forall e. Buffer e -> IntbufR=Intiw,bufSize :: forall e. Buffer e -> IntbufSize=Int_}output :: Buffer Word8output@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8oraw,bufL :: forall e. Buffer e -> IntbufL=Int_,bufR :: forall e. Buffer e -> IntbufR=Intow0,bufSize :: forall e. Buffer e -> IntbufSize=Intos}State# RealWorldst=let{-# NOINLINEdone#-}done::CodingProgress->Int->Int->EncodingBuffer#done :: CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgresswhy!Intir!IntowState# RealWorldst'=let!ri :: Buffer Charri=ifIntirInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==IntiwthenBuffer Charinput{bufL=0,bufR=0}elseBuffer Charinput{bufL=ir}!ro :: Buffer Word8ro=Buffer Word8output{bufR=ow}in(#State# RealWorldst',CodingProgresswhy,Buffer Charri,Buffer Word8ro#)loop::Int->Int->EncodingBuffer#loop :: Int -> Int -> EncodingBuffer#loop!Intir!IntowState# RealWorldst0|IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intiw=CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|IntosInt -> Int -> Intforall a. Num a => a -> a -> a-IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int2=CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst0|Boolotherwise=dolet!(#State# RealWorldst1,(Charc,Intir')#)=IO (Char, Int)-> State# RealWorld -> (# State# RealWorld, (Char, Int) #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> IO (Char, Int)readCharBufRawBuffer CharirawIntir)State# RealWorldst0caseChar -> IntordCharcofIntx|IntxInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int0x10000->ifChar -> BoolisSurrogateCharcthenCodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressInvalidSequenceIntirIntowState# RealWorldst1elsedolet!(#State# RealWorldst2,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8orawIntow(Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(IntxInt -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int8)))State# RealWorldst1!(#State# RealWorldst3,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int1)(Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegralIntx))State# RealWorldst2Int -> Int -> EncodingBuffer#loopIntir'(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)State# RealWorldst3|Boolotherwise->doifIntosInt -> Int -> Intforall a. Num a => a -> a -> a-IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int4thenCodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst1elsedoletn1 :: Intn1=IntxInt -> Int -> Intforall a. Num a => a -> a -> a-Int0x10000c1 :: Word8c1=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn1Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int18Int -> Int -> Intforall a. Num a => a -> a -> a+Int0xD8)c2 :: Word8c2=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn1Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int10)n2 :: Intn2=Intn1Int -> Int -> Intforall a. Bits a => a -> a -> a.&.Int0x3FFc3 :: Word8c3=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn2Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int8Int -> Int -> Intforall a. Num a => a -> a -> a+Int0xDC)c4 :: Word8c4=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegralIntn2--!(#State# RealWorldst2,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8orawIntowWord8c1)State# RealWorldst1!(#State# RealWorldst3,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int1)Word8c2)State# RealWorldst2!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)Word8c3)State# RealWorldst3!(#State# RealWorldst5,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int3)Word8c4)State# RealWorldst4Int -> Int -> EncodingBuffer#loopIntir'(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int4)State# RealWorldst5inInt -> Int -> EncodingBuffer#loopIntir0Intow0State# RealWorldstutf16le_encode::EncodeBuffer#utf16le_encode :: CodeBuffer# Char Word8utf16le_encodeinput :: Buffer Charinput@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Chariraw,bufL :: forall e. Buffer e -> IntbufL=Intir0,bufR :: forall e. Buffer e -> IntbufR=Intiw,bufSize :: forall e. Buffer e -> IntbufSize=Int_}output :: Buffer Word8output@Buffer{bufRaw :: forall e. Buffer e -> RawBuffer ebufRaw=RawBuffer Word8oraw,bufL :: forall e. Buffer e -> IntbufL=Int_,bufR :: forall e. Buffer e -> IntbufR=Intow0,bufSize :: forall e. Buffer e -> IntbufSize=Intos}State# RealWorldst=let{-# NOINLINEdone#-}done::CodingProgress->Int->Int->EncodingBuffer#done :: CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgresswhy!Intir!IntowState# RealWorldst'=let!ri :: Buffer Charri=ifIntirInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==IntiwthenBuffer Charinput{bufL=0,bufR=0}elseBuffer Charinput{bufL=ir}!ro :: Buffer Word8ro=Buffer Word8output{bufR=ow}in(#State# RealWorldst',CodingProgresswhy,Buffer Charri,Buffer Word8ro#)loop::Int->Int->EncodingBuffer#loop :: Int -> Int -> EncodingBuffer#loop!Intir!IntowState# RealWorldst0|IntirInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>=Intiw=CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressInputUnderflowIntirIntowState# RealWorldst0|IntosInt -> Int -> Intforall a. Num a => a -> a -> a-IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int2=CodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst0|Boolotherwise=dolet!(#State# RealWorldst1,(Charc,Intir')#)=IO (Char, Int)-> State# RealWorld -> (# State# RealWorld, (Char, Int) #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Char -> Int -> IO (Char, Int)readCharBufRawBuffer CharirawIntir)State# RealWorldst0caseChar -> IntordCharcofIntx|IntxInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int0x10000->ifChar -> BoolisSurrogateCharcthenCodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressInvalidSequenceIntirIntowState# RealWorldst1elsedolet!(#State# RealWorldst2,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8orawIntow(Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegralIntx))State# RealWorldst1!(#State# RealWorldst3,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int1)(Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(IntxInt -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int8)))State# RealWorldst2Int -> Int -> EncodingBuffer#loopIntir'(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)State# RealWorldst3|Boolotherwise->ifIntosInt -> Int -> Intforall a. Num a => a -> a -> a-IntowInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<Int4thenCodingProgress -> Int -> Int -> EncodingBuffer#doneCodingProgressOutputUnderflowIntirIntowState# RealWorldst1elsedoletn1 :: Intn1=IntxInt -> Int -> Intforall a. Num a => a -> a -> a-Int0x10000c1 :: Word8c1=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn1Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int18Int -> Int -> Intforall a. Num a => a -> a -> a+Int0xD8)c2 :: Word8c2=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn1Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int10)n2 :: Intn2=Intn1Int -> Int -> Intforall a. Bits a => a -> a -> a.&.Int0x3FFc3 :: Word8c3=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intn2Int -> Int -> Intforall a. Bits a => a -> Int -> a`shiftR`Int8Int -> Int -> Intforall a. Num a => a -> a -> a+Int0xDC)c4 :: Word8c4=Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegralIntn2--!(#State# RealWorldst2,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8orawIntowWord8c2)State# RealWorldst1!(#State# RealWorldst3,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int1)Word8c1)State# RealWorldst2!(#State# RealWorldst4,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int2)Word8c4)State# RealWorldst3!(#State# RealWorldst5,()#)=IO () -> State# RealWorld -> (# State# RealWorld, () #)forall a. IO a -> State# RealWorld -> (# State# RealWorld, a #)unIO(RawBuffer Word8 -> Int -> Word8 -> IO ()writeWord8BufRawBuffer Word8oraw(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int3)Word8c3)State# RealWorldst4Int -> Int -> EncodingBuffer#loopIntir'(IntowInt -> Int -> Intforall a. Num a => a -> a -> a+Int4)State# RealWorldst5inInt -> Int -> EncodingBuffer#loopIntir0Intow0State# RealWorldstchr2::Word16->Word16->Charchr2 :: Word16 -> Word16 -> Charchr2(W16#Word16#a#)(W16#Word16#b#)=Char# -> CharC#(Int# -> Char#chr#(Int#upper#Int# -> Int# -> Int#+#Int#lower#Int# -> Int# -> Int#+#Int#0x10000#))where!x# :: Int#x#=Word# -> Int#word2Int#(Word16# -> Word#word16ToWord#Word16#a#)!y# :: Int#y#=Word# -> Int#word2Int#(Word16# -> Word#word16ToWord#Word16#b#)!upper# :: Int#upper#=Int# -> Int# -> Int#uncheckedIShiftL#(Int#x#Int# -> Int# -> Int#-#Int#0xD800#)Int#10#!lower# :: Int#lower#=Int#y#Int# -> Int# -> Int#-#Int#0xDC00#{-# INLINEchr2#-}validate1::Word16->Boolvalidate1 :: Word16 -> Boolvalidate1Word16x1=(Word16x1Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool>=Word160Bool -> Bool -> Bool&&Word16x1Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool<Word160xD800)Bool -> Bool -> Bool||Word16x1Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool>Word160xDFFF{-# INLINEvalidate1#-}validate2::Word16->Word16->Boolvalidate2 :: Word16 -> Word16 -> Boolvalidate2Word16x1Word16x2=Word16x1Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool>=Word160xD800Bool -> Bool -> Bool&&Word16x1Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool<=Word160xDBFFBool -> Bool -> Bool&&Word16x2Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool>=Word160xDC00Bool -> Bool -> Bool&&Word16x2Word16 -> Word16 -> Boolforall a. Ord a => a -> a -> Bool<=Word160xDFFF{-# INLINEvalidate2#-}
[8]ページ先頭