module System.Console.Haskeline.Recover where

import GHC.IO.Encoding
import GHC.IO.Encoding.Failure

transliterateFailure :: TextEncoding -> TextEncoding
transliterateFailure :: TextEncoding -> TextEncoding
transliterateFailure
  TextEncoding
    { mkTextEncoder :: ()
mkTextEncoder = IO (TextEncoder estate)
mkEncoder
    , mkTextDecoder :: ()
mkTextDecoder = IO (TextDecoder dstate)
mkDecoder
    , textEncodingName :: TextEncoding -> String
textEncodingName = String
name
    } = TextEncoding
          { mkTextDecoder :: IO (TextDecoder dstate)
mkTextDecoder = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall {from} {to} {state}.
(Buffer from -> Buffer to -> IO (Buffer from, Buffer to))
-> BufferCodec from to state -> BufferCodec from to state
setRecover
                                forall a b. (a -> b) -> a -> b
$ CodingFailureMode
-> Buffer Word8 -> Buffer Char -> IO (Buffer Word8, Buffer Char)
recoverDecode CodingFailureMode
TransliterateCodingFailure)
                            IO (TextDecoder dstate)
mkDecoder
          , mkTextEncoder :: IO (TextEncoder estate)
mkTextEncoder = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall {from} {to} {state}.
(Buffer from -> Buffer to -> IO (Buffer from, Buffer to))
-> BufferCodec from to state -> BufferCodec from to state
setRecover
                                forall a b. (a -> b) -> a -> b
$ CodingFailureMode
-> Buffer Char -> Buffer Word8 -> IO (Buffer Char, Buffer Word8)
recoverEncode CodingFailureMode
TransliterateCodingFailure)
                            IO (TextEncoder estate)
mkEncoder
          , textEncodingName :: String
textEncodingName = String
name
          }
  where
    setRecover :: (Buffer from -> Buffer to -> IO (Buffer from, Buffer to))
-> BufferCodec from to state -> BufferCodec from to state
setRecover Buffer from -> Buffer to -> IO (Buffer from, Buffer to)
r BufferCodec from to state
x = BufferCodec from to state
x { recover :: Buffer from -> Buffer to -> IO (Buffer from, Buffer to)
recover = Buffer from -> Buffer to -> IO (Buffer from, Buffer to)
r }