    {-# LANGUAGE DeriveDataTypeable, EmptyDataDecls #-}
    -- |
    -- Module      : Data.Text.ICU.Bidi.Internal
    -- Copyright   : (c) Ondrej Palkovsky 2018
    --
    -- License     : BSD-style
    -- Maintainer  : bos@serpentine.com
    -- Stability   : experimental
    -- Portability : GHC
    --
    -- Internal types for Unicode bidirectional algorithm

    module Data.Text.ICU.BiDi.Internal
        (
          BiDi(..)
        , UBiDi
        , withBiDi
        ) where

    import Data.Typeable (Typeable)
    import Foreign.ForeignPtr (ForeignPtr, withForeignPtr)
    import Foreign.Ptr (Ptr)

    data UBiDi

    -- | BiDi object.  /Note/: this structure is not
    -- thread safe. It is /not/ safe to use value of this type
    -- simultaneously from multiple threads.
    newtype BiDi = BiDi (ForeignPtr UBiDi)
                     deriving (BiDi -> BiDi -> Bool
    (BiDi -> BiDi -> Bool) -> (BiDi -> BiDi -> Bool) -> Eq BiDi
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: BiDi -> BiDi -> Bool
    == :: BiDi -> BiDi -> Bool
    $c/= :: BiDi -> BiDi -> Bool
    /= :: BiDi -> BiDi -> Bool
    Eq, Typeable)

    instance Show BiDi where
        show :: BiDi -> String
    show BiDi
    _ = String
    "BiDi"

    withBiDi :: BiDi -> (Ptr UBiDi -> IO a) -> IO a
    {-# INLINE withBiDi #-}
    withBiDi :: forall a. BiDi -> (Ptr UBiDi -> IO a) -> IO a
    withBiDi (BiDi ForeignPtr UBiDi
    cnv) = ForeignPtr UBiDi -> (Ptr UBiDi -> IO a) -> IO a
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr UBiDi
    cnv