    {-# LANGUAGE EmptyDataDecls #-}
    {-# LANGUAGE ForeignFunctionInterface #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE CPP #-}
    {-# LANGUAGE TypeFamilies #-}
    {-# LANGUAGE ScopedTypeVariables #-}

    -- | Low-level, streaming YAML interface. For a higher-level interface, see
    -- "Data.Yaml".
    module Text.Libyaml
        ( -- * The event stream
          MarkedEvent(..)
        , Event (..)
        , Style (..)
        , SequenceStyle (..)
        , MappingStyle (..)
        , Tag (..)
        , AnchorName
        , Anchor
          -- * Encoding and decoding
        , encode
        , encodeWith
        , decode
        , decodeMarked
        , encodeFile
        , decodeFile
        , decodeFileMarked
        , encodeFileWith
        , FormatOptions
        , defaultFormatOptions
        , setWidth
        , setTagRendering
        , renderScalarTags
        , renderAllTags
        , renderNoTags
        , renderUriTags
          -- * Error handling
        , YamlException (..)
        , YamlMark (..)
        ) where

    import Prelude hiding (pi)

    import Data.Bits ((.|.))
    import Foreign.C
    import Foreign.Ptr
    import Foreign.ForeignPtr
    #if MIN_VERSION_base(4,7,0)
    import Foreign.ForeignPtr.Unsafe
    #endif
    import Foreign.Marshal.Alloc
    import qualified System.Posix.Internals as Posix

    #if !MIN_VERSION_base(4,8,0)
    import Control.Applicative
    #endif
    import Control.Exception (mask_, throwIO, Exception, finally)
    import Control.Monad
    import Control.Monad.IO.Class
    import Control.Monad.Trans.Resource
    import Data.Conduit hiding (Source, Sink, Conduit)
    import Data.Data

    import Data.ByteString (ByteString, packCString, packCStringLen)
    import qualified Data.ByteString.Char8 as B8
    import qualified Data.ByteString.Internal as B
    import qualified Data.ByteString.Unsafe as BU

    #if WINDOWS && __GLASGOW_HASKELL__ >= 806
    import System.Directory (removeFile)
    import qualified Control.Exception
    #endif

    data Event =
          EventStreamStart
        | EventStreamEnd
        | EventDocumentStart
        | EventDocumentEnd
        | EventAlias !AnchorName
        | EventScalar !ByteString !Tag !Style !Anchor
        | EventSequenceStart !Tag !SequenceStyle !Anchor
        | EventSequenceEnd
        | EventMappingStart !Tag !MappingStyle !Anchor
        | EventMappingEnd
        deriving (Int -> Event -> ShowS
    [Event] -> ShowS
    Event -> String
    (Int -> Event -> ShowS)
    -> (Event -> String) -> ([Event] -> ShowS) -> Show Event
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Event -> ShowS
    showsPrec :: Int -> Event -> ShowS
    $cshow :: Event -> String
    show :: Event -> String
    $cshowList :: [Event] -> ShowS
    showList :: [Event] -> ShowS
    Show, Event -> Event -> Bool
    (Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Event -> Event -> Bool
    == :: Event -> Event -> Bool
    $c/= :: Event -> Event -> Bool
    /= :: Event -> Event -> Bool
    Eq)

    -- | Event with start and end marks.
    --
    -- @since 0.10.4.0
    data MarkedEvent = MarkedEvent
        { MarkedEvent -> Event
    yamlEvent     :: Event
        , MarkedEvent -> YamlMark
    yamlStartMark :: YamlMark
        , MarkedEvent -> YamlMark
    yamlEndMark   :: YamlMark
        }

    -- | Style for scalars - e.g. quoted / folded
    --
    data Style = Any
               | Plain
               | SingleQuoted
               | DoubleQuoted
               | Literal
               | Folded
               | PlainNoTag
        deriving (Int -> Style -> ShowS
    [Style] -> ShowS
    Style -> String
    (Int -> Style -> ShowS)
    -> (Style -> String) -> ([Style] -> ShowS) -> Show Style
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Style -> ShowS
    showsPrec :: Int -> Style -> ShowS
    $cshow :: Style -> String
    show :: Style -> String
    $cshowList :: [Style] -> ShowS
    showList :: [Style] -> ShowS
    Show, ReadPrec [Style]
    ReadPrec Style
    Int -> ReadS Style
    ReadS [Style]
    (Int -> ReadS Style)
    -> ReadS [Style]
    -> ReadPrec Style
    -> ReadPrec [Style]
    -> Read Style
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Style
    readsPrec :: Int -> ReadS Style
    $creadList :: ReadS [Style]
    readList :: ReadS [Style]
    $creadPrec :: ReadPrec Style
    readPrec :: ReadPrec Style
    $creadListPrec :: ReadPrec [Style]
    readListPrec :: ReadPrec [Style]
    Read, Style -> Style -> Bool
    (Style -> Style -> Bool) -> (Style -> Style -> Bool) -> Eq Style
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Style -> Style -> Bool
    == :: Style -> Style -> Bool
    $c/= :: Style -> Style -> Bool
    /= :: Style -> Style -> Bool
    Eq, Int -> Style
    Style -> Int
    Style -> [Style]
    Style -> Style
    Style -> Style -> [Style]
    Style -> Style -> Style -> [Style]
    (Style -> Style)
    -> (Style -> Style)
    -> (Int -> Style)
    -> (Style -> Int)
    -> (Style -> [Style])
    -> (Style -> Style -> [Style])
    -> (Style -> Style -> [Style])
    -> (Style -> Style -> Style -> [Style])
    -> Enum Style
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: Style -> Style
    succ :: Style -> Style
    $cpred :: Style -> Style
    pred :: Style -> Style
    $ctoEnum :: Int -> Style
    toEnum :: Int -> Style
    $cfromEnum :: Style -> Int
    fromEnum :: Style -> Int
    $cenumFrom :: Style -> [Style]
    enumFrom :: Style -> [Style]
    $cenumFromThen :: Style -> Style -> [Style]
    enumFromThen :: Style -> Style -> [Style]
    $cenumFromTo :: Style -> Style -> [Style]
    enumFromTo :: Style -> Style -> [Style]
    $cenumFromThenTo :: Style -> Style -> Style -> [Style]
    enumFromThenTo :: Style -> Style -> Style -> [Style]
    Enum, Style
    Style -> Style -> Bounded Style
    forall a. a -> a -> Bounded a
    $cminBound :: Style
    minBound :: Style
    $cmaxBound :: Style
    maxBound :: Style
    Bounded, Eq Style
    Eq Style =>
    (Style -> Style -> Ordering)
    -> (Style -> Style -> Bool)
    -> (Style -> Style -> Bool)
    -> (Style -> Style -> Bool)
    -> (Style -> Style -> Bool)
    -> (Style -> Style -> Style)
    -> (Style -> Style -> Style)
    -> Ord Style
    Style -> Style -> Bool
    Style -> Style -> Ordering
    Style -> Style -> Style
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Style -> Style -> Ordering
    compare :: Style -> Style -> Ordering
    $c< :: Style -> Style -> Bool
    < :: Style -> Style -> Bool
    $c<= :: Style -> Style -> Bool
    <= :: Style -> Style -> Bool
    $c> :: Style -> Style -> Bool
    > :: Style -> Style -> Bool
    $c>= :: Style -> Style -> Bool
    >= :: Style -> Style -> Bool
    $cmax :: Style -> Style -> Style
    max :: Style -> Style -> Style
    $cmin :: Style -> Style -> Style
    min :: Style -> Style -> Style
    Ord, Typeable Style
    Typeable Style =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Style -> c Style)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Style)
    -> (Style -> Constr)
    -> (Style -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Style))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style))
    -> ((forall b. Data b => b -> b) -> Style -> Style)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Style -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Style -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Style -> m Style)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Style -> m Style)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Style -> m Style)
    -> Data Style
    Style -> Constr
    Style -> DataType
    (forall b. Data b => b -> b) -> Style -> Style
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Style -> u
    forall u. (forall d. Data d => d -> u) -> Style -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Style
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Style -> c Style
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Style)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Style -> c Style
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Style -> c Style
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Style
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Style
    $ctoConstr :: Style -> Constr
    toConstr :: Style -> Constr
    $cdataTypeOf :: Style -> DataType
    dataTypeOf :: Style -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Style)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Style)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
    $cgmapT :: (forall b. Data b => b -> b) -> Style -> Style
    gmapT :: (forall b. Data b => b -> b) -> Style -> Style
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Style -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Style -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Style -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Style -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style
    Data, Typeable)

    -- | Style for sequences - e.g. block or flow
    --
    -- @since 0.9.0
    data SequenceStyle = AnySequence | BlockSequence | FlowSequence
        deriving (Int -> SequenceStyle -> ShowS
    [SequenceStyle] -> ShowS
    SequenceStyle -> String
    (Int -> SequenceStyle -> ShowS)
    -> (SequenceStyle -> String)
    -> ([SequenceStyle] -> ShowS)
    -> Show SequenceStyle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> SequenceStyle -> ShowS
    showsPrec :: Int -> SequenceStyle -> ShowS
    $cshow :: SequenceStyle -> String
    show :: SequenceStyle -> String
    $cshowList :: [SequenceStyle] -> ShowS
    showList :: [SequenceStyle] -> ShowS
    Show, SequenceStyle -> SequenceStyle -> Bool
    (SequenceStyle -> SequenceStyle -> Bool)
    -> (SequenceStyle -> SequenceStyle -> Bool) -> Eq SequenceStyle
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: SequenceStyle -> SequenceStyle -> Bool
    == :: SequenceStyle -> SequenceStyle -> Bool
    $c/= :: SequenceStyle -> SequenceStyle -> Bool
    /= :: SequenceStyle -> SequenceStyle -> Bool
    Eq, Int -> SequenceStyle
    SequenceStyle -> Int
    SequenceStyle -> [SequenceStyle]
    SequenceStyle -> SequenceStyle
    SequenceStyle -> SequenceStyle -> [SequenceStyle]
    SequenceStyle -> SequenceStyle -> SequenceStyle -> [SequenceStyle]
    (SequenceStyle -> SequenceStyle)
    -> (SequenceStyle -> SequenceStyle)
    -> (Int -> SequenceStyle)
    -> (SequenceStyle -> Int)
    -> (SequenceStyle -> [SequenceStyle])
    -> (SequenceStyle -> SequenceStyle -> [SequenceStyle])
    -> (SequenceStyle -> SequenceStyle -> [SequenceStyle])
    -> (SequenceStyle
        -> SequenceStyle -> SequenceStyle -> [SequenceStyle])
    -> Enum SequenceStyle
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: SequenceStyle -> SequenceStyle
    succ :: SequenceStyle -> SequenceStyle
    $cpred :: SequenceStyle -> SequenceStyle
    pred :: SequenceStyle -> SequenceStyle
    $ctoEnum :: Int -> SequenceStyle
    toEnum :: Int -> SequenceStyle
    $cfromEnum :: SequenceStyle -> Int
    fromEnum :: SequenceStyle -> Int
    $cenumFrom :: SequenceStyle -> [SequenceStyle]
    enumFrom :: SequenceStyle -> [SequenceStyle]
    $cenumFromThen :: SequenceStyle -> SequenceStyle -> [SequenceStyle]
    enumFromThen :: SequenceStyle -> SequenceStyle -> [SequenceStyle]
    $cenumFromTo :: SequenceStyle -> SequenceStyle -> [SequenceStyle]
    enumFromTo :: SequenceStyle -> SequenceStyle -> [SequenceStyle]
    $cenumFromThenTo :: SequenceStyle -> SequenceStyle -> SequenceStyle -> [SequenceStyle]
    enumFromThenTo :: SequenceStyle -> SequenceStyle -> SequenceStyle -> [SequenceStyle]
    Enum, SequenceStyle
    SequenceStyle -> SequenceStyle -> Bounded SequenceStyle
    forall a. a -> a -> Bounded a
    $cminBound :: SequenceStyle
    minBound :: SequenceStyle
    $cmaxBound :: SequenceStyle
    maxBound :: SequenceStyle
    Bounded, Eq SequenceStyle
    Eq SequenceStyle =>
    (SequenceStyle -> SequenceStyle -> Ordering)
    -> (SequenceStyle -> SequenceStyle -> Bool)
    -> (SequenceStyle -> SequenceStyle -> Bool)
    -> (SequenceStyle -> SequenceStyle -> Bool)
    -> (SequenceStyle -> SequenceStyle -> Bool)
    -> (SequenceStyle -> SequenceStyle -> SequenceStyle)
    -> (SequenceStyle -> SequenceStyle -> SequenceStyle)
    -> Ord SequenceStyle
    SequenceStyle -> SequenceStyle -> Bool
    SequenceStyle -> SequenceStyle -> Ordering
    SequenceStyle -> SequenceStyle -> SequenceStyle
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: SequenceStyle -> SequenceStyle -> Ordering
    compare :: SequenceStyle -> SequenceStyle -> Ordering
    $c< :: SequenceStyle -> SequenceStyle -> Bool
    < :: SequenceStyle -> SequenceStyle -> Bool
    $c<= :: SequenceStyle -> SequenceStyle -> Bool
    <= :: SequenceStyle -> SequenceStyle -> Bool
    $c> :: SequenceStyle -> SequenceStyle -> Bool
    > :: SequenceStyle -> SequenceStyle -> Bool
    $c>= :: SequenceStyle -> SequenceStyle -> Bool
    >= :: SequenceStyle -> SequenceStyle -> Bool
    $cmax :: SequenceStyle -> SequenceStyle -> SequenceStyle
    max :: SequenceStyle -> SequenceStyle -> SequenceStyle
    $cmin :: SequenceStyle -> SequenceStyle -> SequenceStyle
    min :: SequenceStyle -> SequenceStyle -> SequenceStyle
    Ord, Typeable SequenceStyle
    Typeable SequenceStyle =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> SequenceStyle -> c SequenceStyle)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SequenceStyle)
    -> (SequenceStyle -> Constr)
    -> (SequenceStyle -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c SequenceStyle))
    -> ((forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r)
    -> (forall u. (forall d. Data d => d -> u) -> SequenceStyle -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle)
    -> Data SequenceStyle
    SequenceStyle -> Constr
    SequenceStyle -> DataType
    (forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u
    forall u. (forall d. Data d => d -> u) -> SequenceStyle -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SequenceStyle
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SequenceStyle -> c SequenceStyle
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SequenceStyle)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SequenceStyle -> c SequenceStyle
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SequenceStyle -> c SequenceStyle
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SequenceStyle
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SequenceStyle
    $ctoConstr :: SequenceStyle -> Constr
    toConstr :: SequenceStyle -> Constr
    $cdataTypeOf :: SequenceStyle -> DataType
    dataTypeOf :: SequenceStyle -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SequenceStyle)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SequenceStyle)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SequenceStyle)
    $cgmapT :: (forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle
    gmapT :: (forall b. Data b => b -> b) -> SequenceStyle -> SequenceStyle
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SequenceStyle -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> SequenceStyle -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> SequenceStyle -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SequenceStyle -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SequenceStyle -> m SequenceStyle
    Data, Typeable)

    -- | Style for mappings - e.g. block or flow
    --
    -- @since 0.9.0
    data MappingStyle = AnyMapping | BlockMapping | FlowMapping
        deriving (Int -> MappingStyle -> ShowS
    [MappingStyle] -> ShowS
    MappingStyle -> String
    (Int -> MappingStyle -> ShowS)
    -> (MappingStyle -> String)
    -> ([MappingStyle] -> ShowS)
    -> Show MappingStyle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MappingStyle -> ShowS
    showsPrec :: Int -> MappingStyle -> ShowS
    $cshow :: MappingStyle -> String
    show :: MappingStyle -> String
    $cshowList :: [MappingStyle] -> ShowS
    showList :: [MappingStyle] -> ShowS
    Show, MappingStyle -> MappingStyle -> Bool
    (MappingStyle -> MappingStyle -> Bool)
    -> (MappingStyle -> MappingStyle -> Bool) -> Eq MappingStyle
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MappingStyle -> MappingStyle -> Bool
    == :: MappingStyle -> MappingStyle -> Bool
    $c/= :: MappingStyle -> MappingStyle -> Bool
    /= :: MappingStyle -> MappingStyle -> Bool
    Eq, Int -> MappingStyle
    MappingStyle -> Int
    MappingStyle -> [MappingStyle]
    MappingStyle -> MappingStyle
    MappingStyle -> MappingStyle -> [MappingStyle]
    MappingStyle -> MappingStyle -> MappingStyle -> [MappingStyle]
    (MappingStyle -> MappingStyle)
    -> (MappingStyle -> MappingStyle)
    -> (Int -> MappingStyle)
    -> (MappingStyle -> Int)
    -> (MappingStyle -> [MappingStyle])
    -> (MappingStyle -> MappingStyle -> [MappingStyle])
    -> (MappingStyle -> MappingStyle -> [MappingStyle])
    -> (MappingStyle -> MappingStyle -> MappingStyle -> [MappingStyle])
    -> Enum MappingStyle
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MappingStyle -> MappingStyle
    succ :: MappingStyle -> MappingStyle
    $cpred :: MappingStyle -> MappingStyle
    pred :: MappingStyle -> MappingStyle
    $ctoEnum :: Int -> MappingStyle
    toEnum :: Int -> MappingStyle
    $cfromEnum :: MappingStyle -> Int
    fromEnum :: MappingStyle -> Int
    $cenumFrom :: MappingStyle -> [MappingStyle]
    enumFrom :: MappingStyle -> [MappingStyle]
    $cenumFromThen :: MappingStyle -> MappingStyle -> [MappingStyle]
    enumFromThen :: MappingStyle -> MappingStyle -> [MappingStyle]
    $cenumFromTo :: MappingStyle -> MappingStyle -> [MappingStyle]
    enumFromTo :: MappingStyle -> MappingStyle -> [MappingStyle]
    $cenumFromThenTo :: MappingStyle -> MappingStyle -> MappingStyle -> [MappingStyle]
    enumFromThenTo :: MappingStyle -> MappingStyle -> MappingStyle -> [MappingStyle]
    Enum, MappingStyle
    MappingStyle -> MappingStyle -> Bounded MappingStyle
    forall a. a -> a -> Bounded a
    $cminBound :: MappingStyle
    minBound :: MappingStyle
    $cmaxBound :: MappingStyle
    maxBound :: MappingStyle
    Bounded, Eq MappingStyle
    Eq MappingStyle =>
    (MappingStyle -> MappingStyle -> Ordering)
    -> (MappingStyle -> MappingStyle -> Bool)
    -> (MappingStyle -> MappingStyle -> Bool)
    -> (MappingStyle -> MappingStyle -> Bool)
    -> (MappingStyle -> MappingStyle -> Bool)
    -> (MappingStyle -> MappingStyle -> MappingStyle)
    -> (MappingStyle -> MappingStyle -> MappingStyle)
    -> Ord MappingStyle
    MappingStyle -> MappingStyle -> Bool
    MappingStyle -> MappingStyle -> Ordering
    MappingStyle -> MappingStyle -> MappingStyle
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MappingStyle -> MappingStyle -> Ordering
    compare :: MappingStyle -> MappingStyle -> Ordering
    $c< :: MappingStyle -> MappingStyle -> Bool
    < :: MappingStyle -> MappingStyle -> Bool
    $c<= :: MappingStyle -> MappingStyle -> Bool
    <= :: MappingStyle -> MappingStyle -> Bool
    $c> :: MappingStyle -> MappingStyle -> Bool
    > :: MappingStyle -> MappingStyle -> Bool
    $c>= :: MappingStyle -> MappingStyle -> Bool
    >= :: MappingStyle -> MappingStyle -> Bool
    $cmax :: MappingStyle -> MappingStyle -> MappingStyle
    max :: MappingStyle -> MappingStyle -> MappingStyle
    $cmin :: MappingStyle -> MappingStyle -> MappingStyle
    min :: MappingStyle -> MappingStyle -> MappingStyle
    Ord, Typeable MappingStyle
    Typeable MappingStyle =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> MappingStyle -> c MappingStyle)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c MappingStyle)
    -> (MappingStyle -> Constr)
    -> (MappingStyle -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c MappingStyle))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c MappingStyle))
    -> ((forall b. Data b => b -> b) -> MappingStyle -> MappingStyle)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r)
    -> (forall u. (forall d. Data d => d -> u) -> MappingStyle -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> MappingStyle -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle)
    -> Data MappingStyle
    MappingStyle -> Constr
    MappingStyle -> DataType
    (forall b. Data b => b -> b) -> MappingStyle -> MappingStyle
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> MappingStyle -> u
    forall u. (forall d. Data d => d -> u) -> MappingStyle -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MappingStyle
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MappingStyle -> c MappingStyle
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MappingStyle)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MappingStyle)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MappingStyle -> c MappingStyle
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MappingStyle -> c MappingStyle
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MappingStyle
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MappingStyle
    $ctoConstr :: MappingStyle -> Constr
    toConstr :: MappingStyle -> Constr
    $cdataTypeOf :: MappingStyle -> DataType
    dataTypeOf :: MappingStyle -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MappingStyle)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MappingStyle)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MappingStyle)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MappingStyle)
    $cgmapT :: (forall b. Data b => b -> b) -> MappingStyle -> MappingStyle
    gmapT :: (forall b. Data b => b -> b) -> MappingStyle -> MappingStyle
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MappingStyle -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> MappingStyle -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> MappingStyle -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MappingStyle -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MappingStyle -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MappingStyle -> m MappingStyle
    Data, Typeable)

    data Tag = StrTag
             | FloatTag
             | NullTag
             | BoolTag
             | SetTag
             | IntTag
             | SeqTag
             | MapTag
             | UriTag String
             | NoTag
        deriving (Int -> Tag -> ShowS
    [Tag] -> ShowS
    Tag -> String
    (Int -> Tag -> ShowS)
    -> (Tag -> String) -> ([Tag] -> ShowS) -> Show Tag
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Tag -> ShowS
    showsPrec :: Int -> Tag -> ShowS
    $cshow :: Tag -> String
    show :: Tag -> String
    $cshowList :: [Tag] -> ShowS
    showList :: [Tag] -> ShowS
    Show, Tag -> Tag -> Bool
    (Tag -> Tag -> Bool) -> (Tag -> Tag -> Bool) -> Eq Tag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Tag -> Tag -> Bool
    == :: Tag -> Tag -> Bool
    $c/= :: Tag -> Tag -> Bool
    /= :: Tag -> Tag -> Bool
    Eq, ReadPrec [Tag]
    ReadPrec Tag
    Int -> ReadS Tag
    ReadS [Tag]
    (Int -> ReadS Tag)
    -> ReadS [Tag] -> ReadPrec Tag -> ReadPrec [Tag] -> Read Tag
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Tag
    readsPrec :: Int -> ReadS Tag
    $creadList :: ReadS [Tag]
    readList :: ReadS [Tag]
    $creadPrec :: ReadPrec Tag
    readPrec :: ReadPrec Tag
    $creadListPrec :: ReadPrec [Tag]
    readListPrec :: ReadPrec [Tag]
    Read, Typeable Tag
    Typeable Tag =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Tag -> c Tag)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Tag)
    -> (Tag -> Constr)
    -> (Tag -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Tag))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag))
    -> ((forall b. Data b => b -> b) -> Tag -> Tag)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Tag -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Tag -> m Tag)
    -> Data Tag
    Tag -> Constr
    Tag -> DataType
    (forall b. Data b => b -> b) -> Tag -> Tag
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tag -> c Tag
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Tag
    $ctoConstr :: Tag -> Constr
    toConstr :: Tag -> Constr
    $cdataTypeOf :: Tag -> DataType
    dataTypeOf :: Tag -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Tag)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag)
    $cgmapT :: (forall b. Data b => b -> b) -> Tag -> Tag
    gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Tag -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Tag -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tag -> m Tag
    Data, Typeable)

    tagSuppressed :: Tag -> Bool
    tagSuppressed :: Tag -> Bool
    tagSuppressed (Tag
    NoTag) = Bool
    True
    tagSuppressed (UriTag String
    "") = Bool
    True
    tagSuppressed Tag
    _ = Bool
    False

    type AnchorName = String
    type Anchor = Maybe AnchorName

    tagToString :: Tag -> String
    tagToString :: Tag -> String
    tagToString Tag
    StrTag = String
    "tag:yaml.org,2002:str"
    tagToString Tag
    FloatTag = String
    "tag:yaml.org,2002:float"
    tagToString Tag
    NullTag = String
    "tag:yaml.org,2002:null"
    tagToString Tag
    BoolTag = String
    "tag:yaml.org,2002:bool"
    tagToString Tag
    SetTag = String
    "tag:yaml.org,2002:set"
    tagToString Tag
    IntTag = String
    "tag:yaml.org,2002:int"
    tagToString Tag
    SeqTag = String
    "tag:yaml.org,2002:seq"
    tagToString Tag
    MapTag = String
    "tag:yaml.org,2002:map"
    tagToString (UriTag String
    s) = String
    s
    tagToString Tag
    NoTag = String
    ""

    bsToTag :: ByteString -> Tag
    bsToTag :: ByteString -> Tag
    bsToTag = String -> Tag
    stringToTag (String -> Tag) -> (ByteString -> String) -> ByteString -> Tag
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> String
    B8.unpack

    stringToTag :: String -> Tag
    stringToTag :: String -> Tag
    stringToTag String
    "tag:yaml.org,2002:str" = Tag
    StrTag
    stringToTag String
    "tag:yaml.org,2002:float" = Tag
    FloatTag
    stringToTag String
    "tag:yaml.org,2002:null" = Tag
    NullTag
    stringToTag String
    "tag:yaml.org,2002:bool" = Tag
    BoolTag
    stringToTag String
    "tag:yaml.org,2002:set" = Tag
    SetTag
    stringToTag String
    "tag:yaml.org,2002:int" = Tag
    IntTag
    stringToTag String
    "tag:yaml.org,2002:seq" = Tag
    SeqTag
    stringToTag String
    "tag:yaml.org,2002:map" = Tag
    MapTag
    stringToTag String
    "" = Tag
    NoTag
    stringToTag String
    s = String -> Tag
    UriTag String
    s

    data ParserStruct
    type Parser = Ptr ParserStruct
    parserSize :: Int
    parserSize :: Int
    parserSize = Int
    480

    data EventRawStruct
    type EventRaw = Ptr EventRawStruct
    eventSize :: Int
    eventSize :: Int
    eventSize = Int
    104

    foreign import ccall unsafe "yaml_parser_initialize"
        c_yaml_parser_initialize :: Parser -> IO CInt

    foreign import ccall unsafe "yaml_parser_delete"
        c_yaml_parser_delete :: Parser -> IO ()

    foreign import ccall unsafe "yaml_parser_set_input_string"
        c_yaml_parser_set_input_string :: Parser
                                       -> Ptr CUChar
                                       -> CULong
                                       -> IO ()

    foreign import ccall unsafe "yaml_parser_set_input_file"
        c_yaml_parser_set_input_file :: Parser
                                     -> File
                                     -> IO ()

    data MarkRawStruct
    type MarkRaw = Ptr MarkRawStruct

    foreign import ccall unsafe "get_mark_index"
        c_get_mark_index :: MarkRaw -> IO CULong

    foreign import ccall unsafe "get_mark_line"
        c_get_mark_line :: MarkRaw -> IO CULong

    foreign import ccall unsafe "get_mark_column"
        c_get_mark_column :: MarkRaw -> IO CULong

    getMark :: MarkRaw -> IO YamlMark
    getMark :: MarkRaw -> IO YamlMark
    getMark MarkRaw
    m = Int -> Int -> Int -> YamlMark
    YamlMark
      (Int -> Int -> Int -> YamlMark)
    -> IO Int -> IO (Int -> Int -> YamlMark)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (CULong -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (CULong -> Int) -> IO CULong -> IO Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkRaw -> IO CULong
    c_get_mark_index MarkRaw
    m)
      IO (Int -> Int -> YamlMark) -> IO Int -> IO (Int -> YamlMark)
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (CULong -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (CULong -> Int) -> IO CULong -> IO Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkRaw -> IO CULong
    c_get_mark_line MarkRaw
    m)
      IO (Int -> YamlMark) -> IO Int -> IO YamlMark
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (CULong -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (CULong -> Int) -> IO CULong -> IO Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkRaw -> IO CULong
    c_get_mark_column MarkRaw
    m)

    data FileStruct
    type File = Ptr FileStruct

    #ifdef WINDOWS
    foreign import ccall unsafe "_fdopen"
    #else
    foreign import ccall unsafe "fdopen"
    #endif
        c_fdopen :: CInt
                 -> Ptr CChar
                 -> IO File
    foreign import ccall unsafe "fclose"
        c_fclose :: File
                 -> IO CInt

    foreign import ccall unsafe "fclose_helper"
        c_fclose_helper :: File -> IO CInt

    foreign import ccall unsafe "yaml_parser_parse"
        c_yaml_parser_parse :: Parser -> EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_event_delete"
        c_yaml_event_delete :: EventRaw -> IO ()

    foreign import ccall "get_parser_error_problem"
        c_get_parser_error_problem :: Parser -> IO (Ptr CUChar)

    foreign import ccall "get_parser_error_context"
        c_get_parser_error_context :: Parser -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_parser_error_mark"
        c_get_parser_error_mark :: Parser -> IO MarkRaw

    makeString :: MonadIO m => (a -> m (Ptr CUChar)) -> a -> m String
    makeString :: forall (m :: * -> *) a.
    MonadIO m =>
    (a -> m (Ptr CUChar)) -> a -> m String
    makeString a -> m (Ptr CUChar)
    f a
    a = do
        cchar <- Ptr CUChar -> CString
    forall a b. Ptr a -> Ptr b
    castPtr (Ptr CUChar -> CString) -> m (Ptr CUChar) -> m CString
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    `liftM` a -> m (Ptr CUChar)
    f a
    a
        if cchar == nullPtr
            then return ""
            else liftIO $ peekCString cchar

    data EventType = YamlNoEvent
                   | YamlStreamStartEvent
                   | YamlStreamEndEvent
                   | YamlDocumentStartEvent
                   | YamlDocumentEndEvent
                   | YamlAliasEvent
                   | YamlScalarEvent
                   | YamlSequenceStartEvent
                   | YamlSequenceEndEvent
                   | YamlMappingStartEvent
                   | YamlMappingEndEvent
                   deriving (Int -> EventType
    EventType -> Int
    EventType -> [EventType]
    EventType -> EventType
    EventType -> EventType -> [EventType]
    EventType -> EventType -> EventType -> [EventType]
    (EventType -> EventType)
    -> (EventType -> EventType)
    -> (Int -> EventType)
    -> (EventType -> Int)
    -> (EventType -> [EventType])
    -> (EventType -> EventType -> [EventType])
    -> (EventType -> EventType -> [EventType])
    -> (EventType -> EventType -> EventType -> [EventType])
    -> Enum EventType
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: EventType -> EventType
    succ :: EventType -> EventType
    $cpred :: EventType -> EventType
    pred :: EventType -> EventType
    $ctoEnum :: Int -> EventType
    toEnum :: Int -> EventType
    $cfromEnum :: EventType -> Int
    fromEnum :: EventType -> Int
    $cenumFrom :: EventType -> [EventType]
    enumFrom :: EventType -> [EventType]
    $cenumFromThen :: EventType -> EventType -> [EventType]
    enumFromThen :: EventType -> EventType -> [EventType]
    $cenumFromTo :: EventType -> EventType -> [EventType]
    enumFromTo :: EventType -> EventType -> [EventType]
    $cenumFromThenTo :: EventType -> EventType -> EventType -> [EventType]
    enumFromThenTo :: EventType -> EventType -> EventType -> [EventType]
    Enum,Int -> EventType -> ShowS
    [EventType] -> ShowS
    EventType -> String
    (Int -> EventType -> ShowS)
    -> (EventType -> String)
    -> ([EventType] -> ShowS)
    -> Show EventType
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> EventType -> ShowS
    showsPrec :: Int -> EventType -> ShowS
    $cshow :: EventType -> String
    show :: EventType -> String
    $cshowList :: [EventType] -> ShowS
    showList :: [EventType] -> ShowS
    Show)

    foreign import ccall unsafe "get_event_type"
        c_get_event_type :: EventRaw -> IO CInt

    foreign import ccall unsafe "get_start_mark"
        c_get_start_mark :: EventRaw -> IO MarkRaw

    foreign import ccall unsafe "get_end_mark"
        c_get_end_mark :: EventRaw -> IO MarkRaw

    foreign import ccall unsafe "get_scalar_value"
        c_get_scalar_value :: EventRaw -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_scalar_length"
        c_get_scalar_length :: EventRaw -> IO CULong

    foreign import ccall unsafe "get_scalar_tag"
        c_get_scalar_tag :: EventRaw -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_scalar_style"
        c_get_scalar_style :: EventRaw -> IO CInt

    foreign import ccall unsafe "get_scalar_anchor"
        c_get_scalar_anchor :: EventRaw -> IO CString

    foreign import ccall unsafe "get_sequence_start_anchor"
        c_get_sequence_start_anchor :: EventRaw -> IO CString

    foreign import ccall unsafe "get_sequence_start_style"
        c_get_sequence_start_style :: EventRaw -> IO CInt

    foreign import ccall unsafe "get_sequence_start_tag"
        c_get_sequence_start_tag :: EventRaw -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_mapping_start_anchor"
        c_get_mapping_start_anchor :: EventRaw -> IO CString

    foreign import ccall unsafe "get_mapping_start_style"
        c_get_mapping_start_style :: EventRaw -> IO CInt

    foreign import ccall unsafe "get_mapping_start_tag"
        c_get_mapping_start_tag :: EventRaw -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_alias_anchor"
        c_get_alias_anchor :: EventRaw -> IO CString

    readAnchor :: (EventRaw -> IO CString) -> EventRaw -> IO Anchor
    readAnchor :: (EventRaw -> IO CString) -> EventRaw -> IO Anchor
    readAnchor EventRaw -> IO CString
    getAnchor EventRaw
    er = do
      yanchor <- EventRaw -> IO CString
    getAnchor EventRaw
    er
      if yanchor == nullPtr
        then return Nothing
        else Just <$> peekCString yanchor

    readStyle :: (Enum a) => (EventRaw -> IO CInt) -> EventRaw -> IO a
    readStyle :: forall a. Enum a => (EventRaw -> IO CInt) -> EventRaw -> IO a
    readStyle EventRaw -> IO CInt
    getStyle EventRaw
    er = Int -> a
    forall a. Enum a => Int -> a
    toEnum (Int -> a) -> (CInt -> Int) -> CInt -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . CInt -> Int
    forall a. Enum a => a -> Int
    fromEnum (CInt -> a) -> IO CInt -> IO a
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> EventRaw -> IO CInt
    getStyle EventRaw
    er

    readTag :: (EventRaw -> IO (Ptr CUChar)) -> EventRaw -> IO Tag
    readTag :: (EventRaw -> IO (Ptr CUChar)) -> EventRaw -> IO Tag
    readTag EventRaw -> IO (Ptr CUChar)
    getTag EventRaw
    er = ByteString -> Tag
    bsToTag (ByteString -> Tag) -> IO ByteString -> IO Tag
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (EventRaw -> IO (Ptr CUChar)
    getTag EventRaw
    er IO (Ptr CUChar) -> (Ptr CUChar -> IO ByteString) -> IO ByteString
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= CString -> IO ByteString
    packCString (CString -> IO ByteString)
    -> (Ptr CUChar -> CString) -> Ptr CUChar -> IO ByteString
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr CUChar -> CString
    forall a b. Ptr a -> Ptr b
    castPtr)

    getEvent :: EventRaw -> IO (Maybe MarkedEvent)
    getEvent :: EventRaw -> IO (Maybe MarkedEvent)
    getEvent EventRaw
    er = do
        et <- EventRaw -> IO CInt
    c_get_event_type EventRaw
    er
        startMark <- c_get_start_mark er >>= getMark
        endMark <- c_get_end_mark er >>= getMark
        event <- case toEnum $ fromEnum et of
            EventType
    YamlNoEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe Event
    forall a. Maybe a
    Nothing
            EventType
    YamlStreamStartEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventStreamStart
            EventType
    YamlStreamEndEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventStreamEnd
            EventType
    YamlDocumentStartEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventDocumentStart
            EventType
    YamlDocumentEndEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventDocumentEnd
            EventType
    YamlAliasEvent -> do
                yanchor <- EventRaw -> IO CString
    c_get_alias_anchor EventRaw
    er
                anchor <- if yanchor == nullPtr
                              then error "got YamlAliasEvent with empty anchor"
                              else peekCString yanchor
                return $ Just $ EventAlias anchor
            EventType
    YamlScalarEvent -> do
                yvalue <- EventRaw -> IO (Ptr CUChar)
    c_get_scalar_value EventRaw
    er
                ylen <- c_get_scalar_length er
                let yvalue' = Ptr CUChar -> CString
    forall a b. Ptr a -> Ptr b
    castPtr Ptr CUChar
    yvalue
                let ylen' = CULong -> Int
    forall a. Enum a => a -> Int
    fromEnum CULong
    ylen
                bs <- packCStringLen (yvalue', ylen')
                tag <- readTag c_get_scalar_tag er
                style <- readStyle c_get_scalar_style er
                anchor <- readAnchor c_get_scalar_anchor er
                return $ Just $ EventScalar bs tag style anchor
            EventType
    YamlSequenceStartEvent -> do
                tag <- (EventRaw -> IO (Ptr CUChar)) -> EventRaw -> IO Tag
    readTag EventRaw -> IO (Ptr CUChar)
    c_get_sequence_start_tag EventRaw
    er
                style <- readStyle c_get_sequence_start_style er
                anchor <- readAnchor c_get_sequence_start_anchor er
                return $ Just $ EventSequenceStart tag style anchor
            EventType
    YamlSequenceEndEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventSequenceEnd
            EventType
    YamlMappingStartEvent -> do
                tag <- (EventRaw -> IO (Ptr CUChar)) -> EventRaw -> IO Tag
    readTag EventRaw -> IO (Ptr CUChar)
    c_get_mapping_start_tag EventRaw
    er
                style <- readStyle c_get_mapping_start_style er
                anchor <- readAnchor c_get_mapping_start_anchor er
                return $ Just $ EventMappingStart tag style anchor
            EventType
    YamlMappingEndEvent -> Maybe Event -> IO (Maybe Event)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Event -> IO (Maybe Event))
    -> Maybe Event -> IO (Maybe Event)
    forall a b. (a -> b) -> a -> b
    $ Event -> Maybe Event
    forall a. a -> Maybe a
    Just Event
    EventMappingEnd
        return $ (\Event
    e -> Event -> YamlMark -> YamlMark -> MarkedEvent
    MarkedEvent Event
    e YamlMark
    startMark YamlMark
    endMark) <$> event

    -- Emitter

    data EmitterStruct
    type Emitter = Ptr EmitterStruct
    emitterSize :: Int
    emitterSize :: Int
    emitterSize = Int
    432

    foreign import ccall unsafe "yaml_emitter_initialize"
        c_yaml_emitter_initialize :: Emitter -> IO CInt

    foreign import ccall unsafe "yaml_emitter_delete"
        c_yaml_emitter_delete :: Emitter -> IO ()

    data BufferStruct
    type Buffer = Ptr BufferStruct
    bufferSize :: Int
    bufferSize :: Int
    bufferSize = Int
    16

    foreign import ccall unsafe "buffer_init"
        c_buffer_init :: Buffer -> IO ()

    foreign import ccall unsafe "get_buffer_buff"
        c_get_buffer_buff :: Buffer -> IO (Ptr CUChar)

    foreign import ccall unsafe "get_buffer_used"
        c_get_buffer_used :: Buffer -> IO CULong

    foreign import ccall unsafe "my_emitter_set_output"
        c_my_emitter_set_output :: Emitter -> Buffer -> IO ()

    #ifndef __NO_UNICODE__
    foreign import ccall unsafe "yaml_emitter_set_unicode"
        c_yaml_emitter_set_unicode :: Emitter -> CInt -> IO ()
    #endif

    foreign import ccall unsafe "yaml_emitter_set_output_file"
        c_yaml_emitter_set_output_file :: Emitter -> File -> IO ()

    foreign import ccall unsafe "yaml_emitter_set_width"
        c_yaml_emitter_set_width :: Emitter -> CInt -> IO ()

    foreign import ccall unsafe "yaml_emitter_emit"
        c_yaml_emitter_emit :: Emitter -> EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_stream_start_event_initialize"
        c_yaml_stream_start_event_initialize :: EventRaw -> CInt -> IO CInt

    foreign import ccall unsafe "yaml_stream_end_event_initialize"
        c_yaml_stream_end_event_initialize :: EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_scalar_event_initialize"
        c_yaml_scalar_event_initialize
            :: EventRaw
            -> Ptr CUChar -- anchor
            -> Ptr CUChar -- tag
            -> Ptr CUChar -- value
            -> CInt       -- length
            -> CInt       -- plain_implicit
            -> CInt       -- quoted_implicit
            -> CInt       -- style
            -> IO CInt

    foreign import ccall unsafe "simple_document_start"
        c_simple_document_start :: EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_document_end_event_initialize"
        c_yaml_document_end_event_initialize :: EventRaw -> CInt -> IO CInt

    foreign import ccall unsafe "yaml_sequence_start_event_initialize"
        c_yaml_sequence_start_event_initialize
            :: EventRaw
            -> Ptr CUChar
            -> Ptr CUChar
            -> CInt
            -> CInt
            -> IO CInt

    foreign import ccall unsafe "yaml_sequence_end_event_initialize"
        c_yaml_sequence_end_event_initialize :: EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_mapping_start_event_initialize"
        c_yaml_mapping_start_event_initialize
            :: EventRaw
            -> Ptr CUChar
            -> Ptr CUChar
            -> CInt
            -> CInt
            -> IO CInt

    foreign import ccall unsafe "yaml_mapping_end_event_initialize"
        c_yaml_mapping_end_event_initialize :: EventRaw -> IO CInt

    foreign import ccall unsafe "yaml_alias_event_initialize"
        c_yaml_alias_event_initialize
            :: EventRaw
            -> Ptr CUChar
            -> IO CInt

    toEventRaw :: FormatOptions -> Event -> (EventRaw -> IO a) -> IO a
    toEventRaw :: forall a. FormatOptions -> Event -> (EventRaw -> IO a) -> IO a
    toEventRaw FormatOptions
    opts Event
    e EventRaw -> IO a
    f = Int -> (EventRaw -> IO a) -> IO a
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes Int
    eventSize ((EventRaw -> IO a) -> IO a) -> (EventRaw -> IO a) -> IO a
    forall a b. (a -> b) -> a -> b
    $ \EventRaw
    er -> do
        ret <- case Event
    e of
            Event
    EventStreamStart ->
                EventRaw -> CInt -> IO CInt
    c_yaml_stream_start_event_initialize
                    EventRaw
    er
                    CInt
    0 -- YAML_ANY_ENCODING
            Event
    EventStreamEnd ->
                EventRaw -> IO CInt
    c_yaml_stream_end_event_initialize EventRaw
    er
            Event
    EventDocumentStart ->
                EventRaw -> IO CInt
    c_simple_document_start EventRaw
    er
            Event
    EventDocumentEnd ->
                EventRaw -> CInt -> IO CInt
    c_yaml_document_end_event_initialize EventRaw
    er CInt
    1
            EventScalar ByteString
    bs Tag
    thetag Style
    style0 Anchor
    anchor -> do
                ByteString -> (CStringLen -> IO CInt) -> IO CInt
    forall a. ByteString -> (CStringLen -> IO a) -> IO a
    BU.unsafeUseAsCStringLen ByteString
    bs ((CStringLen -> IO CInt) -> IO CInt)
    -> (CStringLen -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \(CString
    value, Int
    len) -> do
                    let value' :: Ptr CUChar
    value' = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    value :: Ptr CUChar
                        len' :: CInt
    len' = Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    len :: CInt
                    let thetag' :: String
    thetag' = Tag -> String
    tagToString Tag
    thetag
                    String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString String
    thetag' ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    tag' -> do
                        let pi0 :: CInt
    pi0 = Event -> CInt
    tagsImplicit Event
    e
                            (CInt
    pi, Style
    style) =
                              case Style
    style0 of
                                Style
    PlainNoTag -> (CInt
    1, Style
    Plain)
                                Style
    x -> (CInt
    pi0, Style
    x)
                            style' :: CInt
    style' = Int -> CInt
    forall a. Enum a => Int -> a
    toEnum (Int -> CInt) -> Int -> CInt
    forall a b. (a -> b) -> a -> b
    $ Style -> Int
    forall a. Enum a => a -> Int
    fromEnum Style
    style
                            tagP :: Ptr CUChar
    tagP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    tag'
                        case Anchor
    anchor of
                            Anchor
    Nothing ->
                                EventRaw
    -> Ptr CUChar
    -> Ptr CUChar
    -> Ptr CUChar
    -> CInt
    -> CInt
    -> CInt
    -> CInt
    -> IO CInt
    c_yaml_scalar_event_initialize
                                    EventRaw
    er
                                    Ptr CUChar
    forall a. Ptr a
    nullPtr -- anchor
                                    Ptr CUChar
    tagP    -- tag
                                    Ptr CUChar
    value'  -- value
                                    CInt
    len'    -- length
                                    CInt
    pi      -- plain_implicit
                                    CInt
    pi      -- quoted_implicit
                                    CInt
    style'  -- style
                            Just String
    anchor' ->
                                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString String
    anchor' ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    anchorP' -> do
                                    let anchorP :: Ptr CUChar
    anchorP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    anchorP'
                                    EventRaw
    -> Ptr CUChar
    -> Ptr CUChar
    -> Ptr CUChar
    -> CInt
    -> CInt
    -> CInt
    -> CInt
    -> IO CInt
    c_yaml_scalar_event_initialize
                                        EventRaw
    er
                                        Ptr CUChar
    anchorP -- anchor
                                        Ptr CUChar
    tagP    -- tag
                                        Ptr CUChar
    value'  -- value
                                        CInt
    len'    -- length
                                        CInt
    0       -- plain_implicit
                                        CInt
    pi      -- quoted_implicit
                                        CInt
    style'  -- style
            EventSequenceStart Tag
    tag SequenceStyle
    style Anchor
    Nothing ->
                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString (Tag -> String
    tagToString Tag
    tag) ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    tag' -> do
                    let tagP :: Ptr CUChar
    tagP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    tag'
                    EventRaw -> Ptr CUChar -> Ptr CUChar -> CInt -> CInt -> IO CInt
    c_yaml_sequence_start_event_initialize
                      EventRaw
    er
                      Ptr CUChar
    forall a. Ptr a
    nullPtr
                      Ptr CUChar
    tagP
                      (Event -> CInt
    tagsImplicit Event
    e)
                      (Int -> CInt
    forall a. Enum a => Int -> a
    toEnum (Int -> CInt) -> Int -> CInt
    forall a b. (a -> b) -> a -> b
    $ SequenceStyle -> Int
    forall a. Enum a => a -> Int
    fromEnum SequenceStyle
    style)
            EventSequenceStart Tag
    tag SequenceStyle
    style (Just String
    anchor) ->
                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString (Tag -> String
    tagToString Tag
    tag) ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    tag' -> do
                    let tagP :: Ptr CUChar
    tagP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    tag'
                    String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString String
    anchor ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    anchor' -> do
                        let anchorP :: Ptr CUChar
    anchorP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    anchor'
                        EventRaw -> Ptr CUChar -> Ptr CUChar -> CInt -> CInt -> IO CInt
    c_yaml_sequence_start_event_initialize
                            EventRaw
    er
                            Ptr CUChar
    anchorP
                            Ptr CUChar
    tagP
                            (Event -> CInt
    tagsImplicit Event
    e)
                            (Int -> CInt
    forall a. Enum a => Int -> a
    toEnum (Int -> CInt) -> Int -> CInt
    forall a b. (a -> b) -> a -> b
    $ SequenceStyle -> Int
    forall a. Enum a => a -> Int
    fromEnum SequenceStyle
    style)
            Event
    EventSequenceEnd ->
                EventRaw -> IO CInt
    c_yaml_sequence_end_event_initialize EventRaw
    er
            EventMappingStart Tag
    tag MappingStyle
    style Anchor
    Nothing ->
                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString (Tag -> String
    tagToString Tag
    tag) ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    tag' -> do
                    let tagP :: Ptr CUChar
    tagP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    tag'
                    EventRaw -> Ptr CUChar -> Ptr CUChar -> CInt -> CInt -> IO CInt
    c_yaml_mapping_start_event_initialize
                        EventRaw
    er
                        Ptr CUChar
    forall a. Ptr a
    nullPtr
                        Ptr CUChar
    tagP
                        (Event -> CInt
    tagsImplicit Event
    e)
                        (Int -> CInt
    forall a. Enum a => Int -> a
    toEnum (Int -> CInt) -> Int -> CInt
    forall a b. (a -> b) -> a -> b
    $ MappingStyle -> Int
    forall a. Enum a => a -> Int
    fromEnum MappingStyle
    style)
            EventMappingStart Tag
    tag MappingStyle
    style (Just String
    anchor) ->
                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString (Tag -> String
    tagToString Tag
    tag) ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    tag' -> do
                    String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString String
    anchor ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    anchor' -> do
                        let tagP :: Ptr CUChar
    tagP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    tag'
                        let anchorP :: Ptr CUChar
    anchorP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    anchor'
                        EventRaw -> Ptr CUChar -> Ptr CUChar -> CInt -> CInt -> IO CInt
    c_yaml_mapping_start_event_initialize
                            EventRaw
    er
                            Ptr CUChar
    anchorP
                            Ptr CUChar
    tagP
                            (Event -> CInt
    tagsImplicit Event
    e)
                            (Int -> CInt
    forall a. Enum a => Int -> a
    toEnum (Int -> CInt) -> Int -> CInt
    forall a b. (a -> b) -> a -> b
    $ MappingStyle -> Int
    forall a. Enum a => a -> Int
    fromEnum MappingStyle
    style)
            Event
    EventMappingEnd ->
                EventRaw -> IO CInt
    c_yaml_mapping_end_event_initialize EventRaw
    er
            EventAlias String
    anchor ->
                String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    withCString String
    anchor ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    anchorP' -> do
                    let anchorP :: Ptr CUChar
    anchorP = CString -> Ptr CUChar
    forall a b. Ptr a -> Ptr b
    castPtr CString
    anchorP'
                    EventRaw -> Ptr CUChar -> IO CInt
    c_yaml_alias_event_initialize
                        EventRaw
    er
                        Ptr CUChar
    anchorP
        unless (ret == 1) $ throwIO $ ToEventRawException ret
        f er
      where
        tagsImplicit :: Event -> CInt
    tagsImplicit (EventScalar ByteString
    _ Tag
    t Style
    _ Anchor
    _) | Tag -> Bool
    tagSuppressed Tag
    t = CInt
    1
        tagsImplicit (EventMappingStart Tag
    t MappingStyle
    _ Anchor
    _) | Tag -> Bool
    tagSuppressed Tag
    t = CInt
    1
        tagsImplicit (EventSequenceStart Tag
    t SequenceStyle
    _ Anchor
    _) | Tag -> Bool
    tagSuppressed Tag
    t = CInt
    1
        tagsImplicit Event
    evt = TagRender -> CInt
    toImplicitParam (TagRender -> CInt) -> TagRender -> CInt
    forall a b. (a -> b) -> a -> b
    $ FormatOptions -> Event -> TagRender
    formatOptionsRenderTags FormatOptions
    opts Event
    evt

    newtype ToEventRawException = ToEventRawException CInt
        deriving (Int -> ToEventRawException -> ShowS
    [ToEventRawException] -> ShowS
    ToEventRawException -> String
    (Int -> ToEventRawException -> ShowS)
    -> (ToEventRawException -> String)
    -> ([ToEventRawException] -> ShowS)
    -> Show ToEventRawException
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ToEventRawException -> ShowS
    showsPrec :: Int -> ToEventRawException -> ShowS
    $cshow :: ToEventRawException -> String
    show :: ToEventRawException -> String
    $cshowList :: [ToEventRawException] -> ShowS
    showList :: [ToEventRawException] -> ShowS
    Show, Typeable)
    instance Exception ToEventRawException

    -- | Create a conduit that yields events from a bytestring.
    decode :: MonadResource m => B.ByteString -> ConduitM i Event m ()
    decode :: forall (m :: * -> *) i.
    MonadResource m =>
    ByteString -> ConduitM i Event m ()
    decode = (MarkedEvent -> Event)
    -> ConduitT i MarkedEvent m () -> ConduitT i Event m ()
    forall (m :: * -> *) o1 o2 i r.
    Monad m =>
    (o1 -> o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
    mapOutput MarkedEvent -> Event
    yamlEvent (ConduitT i MarkedEvent m () -> ConduitT i Event m ())
    -> (ByteString -> ConduitT i MarkedEvent m ())
    -> ByteString
    -> ConduitT i Event m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) i.
    MonadResource m =>
    ByteString -> ConduitM i MarkedEvent m ()
    decodeMarked

    -- | Create a conduit that yields marked events from a bytestring.
    --
    -- This conduit will yield identical events to that of "decode", but also
    -- includes start and end marks for each event.
    --
    -- @since 0.10.4.0
    decodeMarked :: MonadResource m => B.ByteString -> ConduitM i MarkedEvent m ()
    decodeMarked :: forall (m :: * -> *) i.
    MonadResource m =>
    ByteString -> ConduitM i MarkedEvent m ()
    decodeMarked ByteString
    bs | ByteString -> Bool
    B8.null ByteString
    bs = () -> ConduitT i MarkedEvent m ()
    forall a. a -> ConduitT i MarkedEvent m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    decodeMarked ByteString
    bs =
        IO (Ptr ParserStruct, ForeignPtr Word8)
    -> ((Ptr ParserStruct, ForeignPtr Word8) -> IO ())
    -> ((Ptr ParserStruct, ForeignPtr Word8)
        -> ConduitT i MarkedEvent m ())
    -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) a i o r.
    MonadResource m =>
    IO a -> (a -> IO ()) -> (a -> ConduitT i o m r) -> ConduitT i o m r
    bracketP IO (Ptr ParserStruct, ForeignPtr Word8)
    alloc (Ptr ParserStruct, ForeignPtr Word8) -> IO ()
    forall {a}. (Ptr ParserStruct, ForeignPtr a) -> IO ()
    cleanup (Ptr ParserStruct -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) i.
    MonadResource m =>
    Ptr ParserStruct -> ConduitM i MarkedEvent m ()
    runParser (Ptr ParserStruct -> ConduitT i MarkedEvent m ())
    -> ((Ptr ParserStruct, ForeignPtr Word8) -> Ptr ParserStruct)
    -> (Ptr ParserStruct, ForeignPtr Word8)
    -> ConduitT i MarkedEvent m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Ptr ParserStruct, ForeignPtr Word8) -> Ptr ParserStruct
    forall a b. (a, b) -> a
    fst)
      where
        alloc :: IO (Ptr ParserStruct, ForeignPtr Word8)
    alloc = IO (Ptr ParserStruct, ForeignPtr Word8)
    -> IO (Ptr ParserStruct, ForeignPtr Word8)
    forall a. IO a -> IO a
    mask_ (IO (Ptr ParserStruct, ForeignPtr Word8)
     -> IO (Ptr ParserStruct, ForeignPtr Word8))
    -> IO (Ptr ParserStruct, ForeignPtr Word8)
    -> IO (Ptr ParserStruct, ForeignPtr Word8)
    forall a b. (a -> b) -> a -> b
    $ do
            ptr <- Int -> IO (Ptr ParserStruct)
    forall a. Int -> IO (Ptr a)
    mallocBytes Int
    parserSize
            res <- c_yaml_parser_initialize ptr
            if res == 0
                then do
                    c_yaml_parser_delete ptr
                    free ptr
                    throwIO $ YamlException "Yaml out of memory"
                else do
                    let (bsfptr, offset, len) = B.toForeignPtr bs
                    let bsptrOrig = ForeignPtr Word8 -> Ptr Word8
    forall a. ForeignPtr a -> Ptr a
    unsafeForeignPtrToPtr ForeignPtr Word8
    bsfptr
                    let bsptr = Ptr Word8 -> Ptr (ZonkAny 0)
    forall a b. Ptr a -> Ptr b
    castPtr Ptr Word8
    bsptrOrig Ptr (ZonkAny 0) -> Int -> Ptr CUChar
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    offset
                    c_yaml_parser_set_input_string ptr bsptr (fromIntegral len)
                    return (ptr, bsfptr)
        cleanup :: (Ptr ParserStruct, ForeignPtr a) -> IO ()
    cleanup (Ptr ParserStruct
    ptr, ForeignPtr a
    bsfptr) = do
            ForeignPtr a -> IO ()
    forall a. ForeignPtr a -> IO ()
    touchForeignPtr ForeignPtr a
    bsfptr
            Ptr ParserStruct -> IO ()
    c_yaml_parser_delete Ptr ParserStruct
    ptr
            Ptr ParserStruct -> IO ()
    forall a. Ptr a -> IO ()
    free Ptr ParserStruct
    ptr

    -- XXX copied from GHC.IO.FD
    std_flags, read_flags, output_flags, write_flags :: CInt
    std_flags :: CInt
    std_flags    = CInt
    Posix.o_NOCTTY
    output_flags :: CInt
    output_flags = CInt
    std_flags    CInt -> CInt -> CInt
    forall a. Bits a => a -> a -> a
    .|. CInt
    Posix.o_CREAT CInt -> CInt -> CInt
    forall a. Bits a => a -> a -> a
    .|. CInt
    Posix.o_TRUNC
    read_flags :: CInt
    read_flags   = CInt
    std_flags    CInt -> CInt -> CInt
    forall a. Bits a => a -> a -> a
    .|. CInt
    Posix.o_RDONLY
    write_flags :: CInt
    write_flags  = CInt
    output_flags CInt -> CInt -> CInt
    forall a. Bits a => a -> a -> a
    .|. CInt
    Posix.o_WRONLY

    -- | Open a C FILE* from a file path, using internal GHC API to work correctly
    -- on all platforms, even on non-ASCII filenames. The opening mode must be
    -- indicated via both 'rawOpenFlags' and 'openMode'.
    openFile :: FilePath -> CInt -> String -> IO File
    openFile :: String -> CInt -> String -> IO File
    openFile String
    file CInt
    rawOpenFlags String
    openMode = do
      fd <- IO CInt -> IO CInt
    forall a. IO a -> IO a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO CInt -> IO CInt) -> IO CInt -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ String -> (CString -> IO CInt) -> IO CInt
    forall a. String -> (CString -> IO a) -> IO a
    Posix.withFilePath String
    file ((CString -> IO CInt) -> IO CInt)
    -> (CString -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \CString
    file' ->
        CString -> CInt -> CMode -> IO CInt
    Posix.c_open CString
    file' CInt
    rawOpenFlags CMode
    0o666
      if fd /= (-1)
        then withCString openMode $ \CString
    openMode' -> CInt -> CString -> IO File
    c_fdopen CInt
    fd CString
    openMode'
        else return nullPtr

    -- | Creata a conduit that yields events from a file.
    decodeFile :: MonadResource m => FilePath -> ConduitM i Event m ()
    decodeFile :: forall (m :: * -> *) i.
    MonadResource m =>
    String -> ConduitM i Event m ()
    decodeFile = (MarkedEvent -> Event)
    -> ConduitT i MarkedEvent m () -> ConduitT i Event m ()
    forall (m :: * -> *) o1 o2 i r.
    Monad m =>
    (o1 -> o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
    mapOutput MarkedEvent -> Event
    yamlEvent (ConduitT i MarkedEvent m () -> ConduitT i Event m ())
    -> (String -> ConduitT i MarkedEvent m ())
    -> String
    -> ConduitT i Event m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) i.
    MonadResource m =>
    String -> ConduitM i MarkedEvent m ()
    decodeFileMarked

    -- | Create a conduit that yields marked events from a file.
    --
    -- This conduit will yield identical events to that of "decodeFile", but also
    -- includes start and end marks for each event.
    --
    -- @since 0.10.4.0
    decodeFileMarked :: MonadResource m => FilePath -> ConduitM i MarkedEvent m ()
    decodeFileMarked :: forall (m :: * -> *) i.
    MonadResource m =>
    String -> ConduitM i MarkedEvent m ()
    decodeFileMarked String
    file =
        IO (Ptr ParserStruct, File)
    -> ((Ptr ParserStruct, File) -> IO ())
    -> ((Ptr ParserStruct, File) -> ConduitT i MarkedEvent m ())
    -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) a i o r.
    MonadResource m =>
    IO a -> (a -> IO ()) -> (a -> ConduitT i o m r) -> ConduitT i o m r
    bracketP IO (Ptr ParserStruct, File)
    alloc (Ptr ParserStruct, File) -> IO ()
    cleanup (Ptr ParserStruct -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) i.
    MonadResource m =>
    Ptr ParserStruct -> ConduitM i MarkedEvent m ()
    runParser (Ptr ParserStruct -> ConduitT i MarkedEvent m ())
    -> ((Ptr ParserStruct, File) -> Ptr ParserStruct)
    -> (Ptr ParserStruct, File)
    -> ConduitT i MarkedEvent m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Ptr ParserStruct, File) -> Ptr ParserStruct
    forall a b. (a, b) -> a
    fst)
      where
        alloc :: IO (Ptr ParserStruct, File)
    alloc = IO (Ptr ParserStruct, File) -> IO (Ptr ParserStruct, File)
    forall a. IO a -> IO a
    mask_ (IO (Ptr ParserStruct, File) -> IO (Ptr ParserStruct, File))
    -> IO (Ptr ParserStruct, File) -> IO (Ptr ParserStruct, File)
    forall a b. (a -> b) -> a -> b
    $ do
            ptr <- Int -> IO (Ptr ParserStruct)
    forall a. Int -> IO (Ptr a)
    mallocBytes Int
    parserSize
            res <- c_yaml_parser_initialize ptr
            if res == 0
                then do
                    c_yaml_parser_delete ptr
                    free ptr
                    throwIO $ YamlException "Yaml out of memory"
                else do
                    file' <- openFile file read_flags "r"
                    if file' == nullPtr
                        then do
                            c_yaml_parser_delete ptr
                            free ptr
                            throwIO $ YamlException
                                    $ "Yaml file not found: " ++ file
                        else do
                            c_yaml_parser_set_input_file ptr file'
                            return (ptr, file')
        cleanup :: (Ptr ParserStruct, File) -> IO ()
    cleanup (Ptr ParserStruct
    ptr, File
    file') = do
            res <- File -> IO CInt
    c_fclose_helper File
    file'
            when (res /= 0) $ throwIO $ YamlException $ "could not close file: " ++ file
            c_yaml_parser_delete ptr
            free ptr

    runParser :: MonadResource m => Parser -> ConduitM i MarkedEvent m ()
    runParser :: forall (m :: * -> *) i.
    MonadResource m =>
    Ptr ParserStruct -> ConduitM i MarkedEvent m ()
    runParser Ptr ParserStruct
    parser = do
        e <- IO (Either YamlException (Maybe MarkedEvent))
    -> ConduitT
         i MarkedEvent m (Either YamlException (Maybe MarkedEvent))
    forall a. IO a -> ConduitT i MarkedEvent m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Either YamlException (Maybe MarkedEvent))
     -> ConduitT
          i MarkedEvent m (Either YamlException (Maybe MarkedEvent)))
    -> IO (Either YamlException (Maybe MarkedEvent))
    -> ConduitT
         i MarkedEvent m (Either YamlException (Maybe MarkedEvent))
    forall a b. (a -> b) -> a -> b
    $ Ptr ParserStruct -> IO (Either YamlException (Maybe MarkedEvent))
    parserParseOne' Ptr ParserStruct
    parser
        case e of
            Left YamlException
    err -> IO () -> ConduitT i MarkedEvent m ()
    forall a. IO a -> ConduitT i MarkedEvent m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> ConduitT i MarkedEvent m ())
    -> IO () -> ConduitT i MarkedEvent m ()
    forall a b. (a -> b) -> a -> b
    $ YamlException -> IO ()
    forall e a. (HasCallStack, Exception e) => e -> IO a
    throwIO YamlException
    err
            Right Maybe MarkedEvent
    Nothing -> () -> ConduitT i MarkedEvent m ()
    forall a. a -> ConduitT i MarkedEvent m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
            Right (Just MarkedEvent
    ev) -> MarkedEvent -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
    yield MarkedEvent
    ev ConduitT i MarkedEvent m ()
    -> ConduitT i MarkedEvent m () -> ConduitT i MarkedEvent m ()
    forall a b.
    ConduitT i MarkedEvent m a
    -> ConduitT i MarkedEvent m b -> ConduitT i MarkedEvent m b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Ptr ParserStruct -> ConduitT i MarkedEvent m ()
    forall (m :: * -> *) i.
    MonadResource m =>
    Ptr ParserStruct -> ConduitM i MarkedEvent m ()
    runParser Ptr ParserStruct
    parser

    parserParseOne' :: Parser
                    -> IO (Either YamlException (Maybe MarkedEvent))
    parserParseOne' :: Ptr ParserStruct -> IO (Either YamlException (Maybe MarkedEvent))
    parserParseOne' Ptr ParserStruct
    parser = Int
    -> (EventRaw -> IO (Either YamlException (Maybe MarkedEvent)))
    -> IO (Either YamlException (Maybe MarkedEvent))
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes Int
    eventSize ((EventRaw -> IO (Either YamlException (Maybe MarkedEvent)))
     -> IO (Either YamlException (Maybe MarkedEvent)))
    -> (EventRaw -> IO (Either YamlException (Maybe MarkedEvent)))
    -> IO (Either YamlException (Maybe MarkedEvent))
    forall a b. (a -> b) -> a -> b
    $ \EventRaw
    er -> do
        res <- IO CInt -> IO CInt
    forall a. IO a -> IO a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO CInt -> IO CInt) -> IO CInt -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ Ptr ParserStruct -> EventRaw -> IO CInt
    c_yaml_parser_parse Ptr ParserStruct
    parser EventRaw
    er
        flip finally (c_yaml_event_delete er) $
          if res == 0
            then do
              problem <- makeString c_get_parser_error_problem parser
              context <- makeString c_get_parser_error_context parser
              problemMark <- c_get_parser_error_mark parser >>= getMark
              return $ Left $ YamlParseException problem context problemMark
            else Right <$> getEvent er

    -- | Whether a tag should be rendered explicitly in the output or left
    -- implicit.
    --
    -- @since 0.1.1.0
    data TagRender = Explicit | Implicit
      deriving (Int -> TagRender
    TagRender -> Int
    TagRender -> [TagRender]
    TagRender -> TagRender
    TagRender -> TagRender -> [TagRender]
    TagRender -> TagRender -> TagRender -> [TagRender]
    (TagRender -> TagRender)
    -> (TagRender -> TagRender)
    -> (Int -> TagRender)
    -> (TagRender -> Int)
    -> (TagRender -> [TagRender])
    -> (TagRender -> TagRender -> [TagRender])
    -> (TagRender -> TagRender -> [TagRender])
    -> (TagRender -> TagRender -> TagRender -> [TagRender])
    -> Enum TagRender
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: TagRender -> TagRender
    succ :: TagRender -> TagRender
    $cpred :: TagRender -> TagRender
    pred :: TagRender -> TagRender
    $ctoEnum :: Int -> TagRender
    toEnum :: Int -> TagRender
    $cfromEnum :: TagRender -> Int
    fromEnum :: TagRender -> Int
    $cenumFrom :: TagRender -> [TagRender]
    enumFrom :: TagRender -> [TagRender]
    $cenumFromThen :: TagRender -> TagRender -> [TagRender]
    enumFromThen :: TagRender -> TagRender -> [TagRender]
    $cenumFromTo :: TagRender -> TagRender -> [TagRender]
    enumFromTo :: TagRender -> TagRender -> [TagRender]
    $cenumFromThenTo :: TagRender -> TagRender -> TagRender -> [TagRender]
    enumFromThenTo :: TagRender -> TagRender -> TagRender -> [TagRender]
    Enum)

    toImplicitParam :: TagRender -> CInt
    toImplicitParam :: TagRender -> CInt
    toImplicitParam TagRender
    Explicit = CInt
    0
    toImplicitParam TagRender
    Implicit = CInt
    1

    -- | A value for 'formatOptionsRenderTags' that renders no
    -- collection tags but all scalar tags (unless suppressed with styles
    -- 'NoTag or 'PlainNoTag').
    --
    -- @since 0.1.1.0
    renderScalarTags :: Event -> TagRender
    renderScalarTags :: Event -> TagRender
    renderScalarTags (EventScalar ByteString
    _ Tag
    _ Style
    _ Anchor
    _) = TagRender
    Explicit
    renderScalarTags (EventSequenceStart Tag
    _ SequenceStyle
    _ Anchor
    _) = TagRender
    Implicit
    renderScalarTags (EventMappingStart Tag
    _ MappingStyle
    _ Anchor
    _) = TagRender
    Implicit
    renderScalarTags Event
    _ = TagRender
    Implicit

    -- | A value for 'formatOptionsRenderTags' that renders all
    -- tags (except 'NoTag' tag and 'PlainNoTag' style).
    --
    -- @since 0.1.1.0
    renderAllTags :: Event -> TagRender
    renderAllTags :: Event -> TagRender
    renderAllTags Event
    _ = TagRender
    Explicit

    -- | A value for 'formatOptionsRenderTags' that renders no
    -- tags.
    --
    -- @since 0.1.1.0
    renderNoTags :: Event -> TagRender
    renderNoTags :: Event -> TagRender
    renderNoTags Event
    _ = TagRender
    Implicit

    -- | A value for 'formatOptionsRenderCollectionTags' that renders tags
    -- which are instances of 'UriTag'
    --
    -- @since 0.1.1.0
    renderUriTags :: Event -> TagRender
    renderUriTags :: Event -> TagRender
    renderUriTags (EventScalar ByteString
    _ UriTag{} Style
    _ Anchor
    _) = TagRender
    Explicit
    renderUriTags (EventSequenceStart UriTag{} SequenceStyle
    _ Anchor
    _) = TagRender
    Explicit
    renderUriTags (EventMappingStart UriTag{} MappingStyle
    _ Anchor
    _) = TagRender
    Explicit
    renderUriTags Event
    _ = TagRender
    Implicit

    -- | Contains options relating to the formatting (indendation, width) of the YAML output.
    --
    -- @since 0.10.2.0
    data FormatOptions = FormatOptions
        { FormatOptions -> Maybe Int
    formatOptionsWidth :: Maybe Int
        , FormatOptions -> Event -> TagRender
    formatOptionsRenderTags :: Event -> TagRender
        }

    -- |
    -- @since 0.10.2.0
    defaultFormatOptions :: FormatOptions
    defaultFormatOptions :: FormatOptions
    defaultFormatOptions = FormatOptions
        { formatOptionsWidth :: Maybe Int
    formatOptionsWidth = Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    80 -- by default the width is set to 0 in the C code, which gets turned into 80 in yaml_emitter_emit_stream_start
        , formatOptionsRenderTags :: Event -> TagRender
    formatOptionsRenderTags = Event -> TagRender
    renderScalarTags
        }

    -- | Set the maximum number of columns in the YAML output, or 'Nothing' for infinite. By default, the limit is 80 characters.
    --
    -- @since 0.10.2.0
    setWidth :: Maybe Int -> FormatOptions -> FormatOptions
    setWidth :: Maybe Int -> FormatOptions -> FormatOptions
    setWidth Maybe Int
    w FormatOptions
    opts = FormatOptions
    opts { formatOptionsWidth = w }

    -- | Control when and whether tags are rendered to output.
    --
    -- @since 0.1.1.0
    setTagRendering :: (Event -> TagRender) -> FormatOptions -> FormatOptions
    setTagRendering :: (Event -> TagRender) -> FormatOptions -> FormatOptions
    setTagRendering Event -> TagRender
    f FormatOptions
    opts = FormatOptions
    opts { formatOptionsRenderTags = f }

    encode :: MonadResource m => ConduitM Event o m ByteString
    encode :: forall (m :: * -> *) o.
    MonadResource m =>
    ConduitM Event o m ByteString
    encode = FormatOptions -> ConduitM Event o m ByteString
    forall (m :: * -> *) o.
    MonadResource m =>
    FormatOptions -> ConduitM Event o m ByteString
    encodeWith FormatOptions
    defaultFormatOptions

    -- |
    -- @since 0.10.2.0
    encodeWith :: MonadResource m => FormatOptions -> ConduitM Event o m ByteString
    encodeWith :: forall (m :: * -> *) o.
    MonadResource m =>
    FormatOptions -> ConduitM Event o m ByteString
    encodeWith FormatOptions
    opts =
        FormatOptions
    -> (Emitter -> IO (ForeignPtr BufferStruct))
    -> (() -> ForeignPtr BufferStruct -> IO ByteString)
    -> ConduitM Event o m ByteString
    forall (m :: * -> *) a b o.
    MonadResource m =>
    FormatOptions
    -> (Emitter -> IO a) -> (() -> a -> IO b) -> ConduitM Event o m b
    runEmitter FormatOptions
    opts Emitter -> IO (ForeignPtr BufferStruct)
    alloc () -> ForeignPtr BufferStruct -> IO ByteString
    forall {p}. p -> ForeignPtr BufferStruct -> IO ByteString
    close
      where
        alloc :: Emitter -> IO (ForeignPtr BufferStruct)
    alloc Emitter
    emitter = do
            fbuf <- Int -> IO (ForeignPtr BufferStruct)
    forall a. Int -> IO (ForeignPtr a)
    mallocForeignPtrBytes Int
    bufferSize
            withForeignPtr fbuf c_buffer_init
            withForeignPtr fbuf $ c_my_emitter_set_output emitter
            return fbuf
        close :: p -> ForeignPtr BufferStruct -> IO ByteString
    close p
    _ ForeignPtr BufferStruct
    fbuf = ForeignPtr BufferStruct
    -> (Ptr BufferStruct -> IO ByteString) -> IO ByteString
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr BufferStruct
    fbuf ((Ptr BufferStruct -> IO ByteString) -> IO ByteString)
    -> (Ptr BufferStruct -> IO ByteString) -> IO ByteString
    forall a b. (a -> b) -> a -> b
    $ \Ptr BufferStruct
    b -> do
            ptr' <- Ptr BufferStruct -> IO (Ptr CUChar)
    c_get_buffer_buff Ptr BufferStruct
    b
            len <- c_get_buffer_used b
            fptr <- newForeignPtr_ $ castPtr ptr'
            return $ B.fromForeignPtr fptr 0 $ fromIntegral len

    encodeFile :: MonadResource m
               => FilePath
               -> ConduitM Event o m ()
    encodeFile :: forall (m :: * -> *) o.
    MonadResource m =>
    String -> ConduitM Event o m ()
    encodeFile = FormatOptions -> String -> ConduitM Event o m ()
    forall (m :: * -> *) o.
    MonadResource m =>
    FormatOptions -> String -> ConduitM Event o m ()
    encodeFileWith FormatOptions
    defaultFormatOptions

    -- |
    -- @since 0.10.2.0
    encodeFileWith :: MonadResource m
               => FormatOptions
               -> FilePath
               -> ConduitM Event o m ()
    encodeFileWith :: forall (m :: * -> *) o.
    MonadResource m =>
    FormatOptions -> String -> ConduitM Event o m ()
    encodeFileWith FormatOptions
    opts String
    filePath =
        IO File
    -> (File -> IO ())
    -> (File -> ConduitT Event o m ())
    -> ConduitT Event o m ()
    forall (m :: * -> *) a i o r.
    MonadResource m =>
    IO a -> (a -> IO ()) -> (a -> ConduitT i o m r) -> ConduitT i o m r
    bracketP IO File
    getFile File -> IO ()
    cleanup ((File -> ConduitT Event o m ()) -> ConduitT Event o m ())
    -> (File -> ConduitT Event o m ()) -> ConduitT Event o m ()
    forall a b. (a -> b) -> a -> b
    $ \File
    file -> FormatOptions
    -> (Emitter -> IO ())
    -> (() -> () -> IO ())
    -> ConduitT Event o m ()
    forall (m :: * -> *) a b o.
    MonadResource m =>
    FormatOptions
    -> (Emitter -> IO a) -> (() -> a -> IO b) -> ConduitM Event o m b
    runEmitter FormatOptions
    opts (File -> Emitter -> IO ()
    alloc File
    file) (\()
    u ()
    _ -> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    u)
      where
        cleanup :: File -> IO ()
    cleanup File
    file = do
          res <- File -> IO CInt
    c_fclose File
    file
          when (res /= 0) $ throwIO $ YamlException $ "could not close file: " ++ filePath

        getFile :: IO File
    getFile = do
    #if WINDOWS && __GLASGOW_HASKELL__ >= 806
            -- See: https://github.com/snoyberg/yaml/issues/178#issuecomment-550180027
            removeFile filePath `Control.Exception.catch`
              (\(_ :: Control.Exception.IOException) -> pure ())
    #endif
            file <- String -> CInt -> String -> IO File
    openFile String
    filePath CInt
    write_flags String
    "w"
            if file == nullPtr
                then throwIO $ YamlException $ "could not open file for write: " ++ filePath
                else return file

        alloc :: File -> Emitter -> IO ()
    alloc File
    file Emitter
    emitter = Emitter -> File -> IO ()
    c_yaml_emitter_set_output_file Emitter
    emitter File
    file

    runEmitter :: MonadResource m
               => FormatOptions
               -> (Emitter -> IO a) -- ^ alloc
               -> (() -> a -> IO b) -- ^ close
               -> ConduitM Event o m b
    runEmitter :: forall (m :: * -> *) a b o.
    MonadResource m =>
    FormatOptions
    -> (Emitter -> IO a) -> (() -> a -> IO b) -> ConduitM Event o m b
    runEmitter FormatOptions
    opts Emitter -> IO a
    allocI () -> a -> IO b
    closeI =
        IO (Emitter, a)
    -> ((Emitter, a) -> IO ())
    -> ((Emitter, a) -> ConduitT Event o m b)
    -> ConduitT Event o m b
    forall (m :: * -> *) a i o r.
    MonadResource m =>
    IO a -> (a -> IO ()) -> (a -> ConduitT i o m r) -> ConduitT i o m r
    bracketP IO (Emitter, a)
    alloc (Emitter, a) -> IO ()
    forall {b}. (Emitter, b) -> IO ()
    cleanup (Emitter, a) -> ConduitT Event o m b
    go
      where
        alloc :: IO (Emitter, a)
    alloc = IO (Emitter, a) -> IO (Emitter, a)
    forall a. IO a -> IO a
    mask_ (IO (Emitter, a) -> IO (Emitter, a))
    -> IO (Emitter, a) -> IO (Emitter, a)
    forall a b. (a -> b) -> a -> b
    $ do
            emitter <- Int -> IO Emitter
    forall a. Int -> IO (Ptr a)
    mallocBytes Int
    emitterSize
            res <- c_yaml_emitter_initialize emitter
            when (res == 0) $ throwIO $ YamlException "c_yaml_emitter_initialize failed"
    #ifndef __NO_UNICODE__
            c_yaml_emitter_set_unicode emitter 1
    #endif
            c_yaml_emitter_set_width emitter $ case formatOptionsWidth opts of
                Maybe Int
    Nothing -> -CInt
    1 --infinite
                Just Int
    width -> Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    width
            a <- allocI emitter
            return (emitter, a)
        cleanup :: (Emitter, b) -> IO ()
    cleanup (Emitter
    emitter, b
    _) = do
            Emitter -> IO ()
    c_yaml_emitter_delete Emitter
    emitter
            Emitter -> IO ()
    forall a. Ptr a -> IO ()
    free Emitter
    emitter

        go :: (Emitter, a) -> ConduitT Event o m b
    go (Emitter
    emitter, a
    a) =
            ConduitT Event o m b
    loop
          where
            loop :: ConduitT Event o m b
    loop = ConduitT Event o m (Maybe Event)
    forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
    await ConduitT Event o m (Maybe Event)
    -> (Maybe Event -> ConduitT Event o m b) -> ConduitT Event o m b
    forall a b.
    ConduitT Event o m a
    -> (a -> ConduitT Event o m b) -> ConduitT Event o m b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= ConduitT Event o m b
    -> (Event -> ConduitT Event o m b)
    -> Maybe Event
    -> ConduitT Event o m b
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (() -> ConduitT Event o m b
    close ()) Event -> ConduitT Event o m b
    push

            push :: Event -> ConduitT Event o m b
    push Event
    e = do
                _ <- IO CInt -> ConduitT Event o m CInt
    forall a. IO a -> ConduitT Event o m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO CInt -> ConduitT Event o m CInt)
    -> IO CInt -> ConduitT Event o m CInt
    forall a b. (a -> b) -> a -> b
    $ FormatOptions -> Event -> (EventRaw -> IO CInt) -> IO CInt
    forall a. FormatOptions -> Event -> (EventRaw -> IO a) -> IO a
    toEventRaw FormatOptions
    opts Event
    e ((EventRaw -> IO CInt) -> IO CInt)
    -> (EventRaw -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ Emitter -> EventRaw -> IO CInt
    c_yaml_emitter_emit Emitter
    emitter
                loop
            close :: () -> ConduitT Event o m b
    close ()
    u = IO b -> ConduitT Event o m b
    forall a. IO a -> ConduitT Event o m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO b -> ConduitT Event o m b) -> IO b -> ConduitT Event o m b
    forall a b. (a -> b) -> a -> b
    $ () -> a -> IO b
    closeI ()
    u a
    a

    -- | The pointer position
    data YamlMark = YamlMark { YamlMark -> Int
    yamlIndex :: Int, YamlMark -> Int
    yamlLine :: Int, YamlMark -> Int
    yamlColumn :: Int }
        deriving Int -> YamlMark -> ShowS
    [YamlMark] -> ShowS
    YamlMark -> String
    (Int -> YamlMark -> ShowS)
    -> (YamlMark -> String) -> ([YamlMark] -> ShowS) -> Show YamlMark
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> YamlMark -> ShowS
    showsPrec :: Int -> YamlMark -> ShowS
    $cshow :: YamlMark -> String
    show :: YamlMark -> String
    $cshowList :: [YamlMark] -> ShowS
    showList :: [YamlMark] -> ShowS
    Show

    data YamlException = YamlException String
                       -- | problem, context, index, position line, position column
                       | YamlParseException { YamlException -> String
    yamlProblem :: String, YamlException -> String
    yamlContext :: String, YamlException -> YamlMark
    yamlProblemMark :: YamlMark }
        deriving (Int -> YamlException -> ShowS
    [YamlException] -> ShowS
    YamlException -> String
    (Int -> YamlException -> ShowS)
    -> (YamlException -> String)
    -> ([YamlException] -> ShowS)
    -> Show YamlException
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> YamlException -> ShowS
    showsPrec :: Int -> YamlException -> ShowS
    $cshow :: YamlException -> String
    show :: YamlException -> String
    $cshowList :: [YamlException] -> ShowS
    showList :: [YamlException] -> ShowS
    Show, Typeable)
    instance Exception YamlException