{-# LANGUAGE CApiFFI
           , CPP
           #-}

module Botan.Bindings.Prelude
( module Prelude
-- , module Data.ByteString
, module Data.String
, module Data.Word
, module System.IO
, module Foreign.C.String
, module Foreign.C.Types
, module Foreign.ForeignPtr
, module Foreign.Marshal.Alloc
, module Foreign.Marshal.Array
, module Foreign.Ptr
, module Foreign.Storable
, ConstPtr(..)
) where

import Prelude

-- import Data.ByteString (ByteString)
import Data.String (IsString(..))
import Data.Word

import System.IO

import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Marshal.Alloc
import Foreign.Marshal.Array
import Foreign.Ptr
import Foreign.Storable


#if MIN_VERSION_base (4,18,0)
import Foreign.C.ConstPtr
#else
import Data.Data
import Data.Kind
#endif

#if !(MIN_VERSION_base (4,18,0))

-- NOTE: Taken from Foreign.C.ConstPtr, more or less
-- NOTE: Raises a warning on older base / compilers if the shim
--       is a `newtype` instead of a `type`, because the special
--       logic for const pointers didn't exist yet
-- SEE: https://gitlab.haskell.org/ghc/ghc/-/issues/22043
-- AFFECTS:
--  botan_error_description
--  botan_error_last_exception_message
--  botan_x509_cert_validation_status
--  botan_version_string
type ConstPtr :: Type -> Type
type role ConstPtr phantom
newtype ConstPtr a = ConstPtr { forall a. ConstPtr a -> Ptr a
unConstPtr :: Ptr a }
    deriving stock (Typeable (ConstPtr a)
Typeable (ConstPtr a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (ConstPtr a))
-> (ConstPtr a -> Constr)
-> (ConstPtr a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (ConstPtr a)))
-> ((forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r)
-> (forall u. (forall d. Data d => d -> u) -> ConstPtr a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ConstPtr a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a))
-> Data (ConstPtr a)
ConstPtr a -> Constr
ConstPtr a -> DataType
(forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a
forall {a}. Data a => Typeable (ConstPtr a)
forall a. Data a => ConstPtr a -> Constr
forall a. Data a => ConstPtr a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ConstPtr a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> ConstPtr a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ConstPtr a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ConstPtr a))
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) -> ConstPtr a -> u
forall u. (forall d. Data d => d -> u) -> ConstPtr a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ConstPtr a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ConstPtr a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ConstPtr a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ConstPtr a)
$ctoConstr :: forall a. Data a => ConstPtr a -> Constr
toConstr :: ConstPtr a -> Constr
$cdataTypeOf :: forall a. Data a => ConstPtr a -> DataType
dataTypeOf :: ConstPtr a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ConstPtr a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ConstPtr a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a
gmapT :: (forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> ConstPtr a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ConstPtr a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ConstPtr a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConstPtr a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a)
Data)
    deriving newtype (ConstPtr a -> ConstPtr a -> Bool
(ConstPtr a -> ConstPtr a -> Bool)
-> (ConstPtr a -> ConstPtr a -> Bool) -> Eq (ConstPtr a)
forall a. ConstPtr a -> ConstPtr a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. ConstPtr a -> ConstPtr a -> Bool
== :: ConstPtr a -> ConstPtr a -> Bool
$c/= :: forall a. ConstPtr a -> ConstPtr a -> Bool
/= :: ConstPtr a -> ConstPtr a -> Bool
Eq, Eq (ConstPtr a)
Eq (ConstPtr a)
-> (ConstPtr a -> ConstPtr a -> Ordering)
-> (ConstPtr a -> ConstPtr a -> Bool)
-> (ConstPtr a -> ConstPtr a -> Bool)
-> (ConstPtr a -> ConstPtr a -> Bool)
-> (ConstPtr a -> ConstPtr a -> Bool)
-> (ConstPtr a -> ConstPtr a -> ConstPtr a)
-> (ConstPtr a -> ConstPtr a -> ConstPtr a)
-> Ord (ConstPtr a)
ConstPtr a -> ConstPtr a -> Bool
ConstPtr a -> ConstPtr a -> Ordering
ConstPtr a -> ConstPtr a -> ConstPtr a
forall a. Eq (ConstPtr a)
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
forall a. ConstPtr a -> ConstPtr a -> Bool
forall a. ConstPtr a -> ConstPtr a -> Ordering
forall a. ConstPtr a -> ConstPtr a -> ConstPtr a
$ccompare :: forall a. ConstPtr a -> ConstPtr a -> Ordering
compare :: ConstPtr a -> ConstPtr a -> Ordering
$c< :: forall a. ConstPtr a -> ConstPtr a -> Bool
< :: ConstPtr a -> ConstPtr a -> Bool
$c<= :: forall a. ConstPtr a -> ConstPtr a -> Bool
<= :: ConstPtr a -> ConstPtr a -> Bool
$c> :: forall a. ConstPtr a -> ConstPtr a -> Bool
> :: ConstPtr a -> ConstPtr a -> Bool
$c>= :: forall a. ConstPtr a -> ConstPtr a -> Bool
>= :: ConstPtr a -> ConstPtr a -> Bool
$cmax :: forall a. ConstPtr a -> ConstPtr a -> ConstPtr a
max :: ConstPtr a -> ConstPtr a -> ConstPtr a
$cmin :: forall a. ConstPtr a -> ConstPtr a -> ConstPtr a
min :: ConstPtr a -> ConstPtr a -> ConstPtr a
Ord, Ptr (ConstPtr a) -> IO (ConstPtr a)
Ptr (ConstPtr a) -> Int -> IO (ConstPtr a)
Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO ()
Ptr (ConstPtr a) -> ConstPtr a -> IO ()
ConstPtr a -> Int
(ConstPtr a -> Int)
-> (ConstPtr a -> Int)
-> (Ptr (ConstPtr a) -> Int -> IO (ConstPtr a))
-> (Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO ())
-> (forall b. Ptr b -> Int -> IO (ConstPtr a))
-> (forall b. Ptr b -> Int -> ConstPtr a -> IO ())
-> (Ptr (ConstPtr a) -> IO (ConstPtr a))
-> (Ptr (ConstPtr a) -> ConstPtr a -> IO ())
-> Storable (ConstPtr a)
forall b. Ptr b -> Int -> IO (ConstPtr a)
forall b. Ptr b -> Int -> ConstPtr a -> IO ()
forall a. Ptr (ConstPtr a) -> IO (ConstPtr a)
forall a. Ptr (ConstPtr a) -> Int -> IO (ConstPtr a)
forall a. Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO ()
forall a. Ptr (ConstPtr a) -> ConstPtr a -> IO ()
forall a. ConstPtr a -> Int
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
forall a b. Ptr b -> Int -> IO (ConstPtr a)
forall a b. Ptr b -> Int -> ConstPtr a -> IO ()
$csizeOf :: forall a. ConstPtr a -> Int
sizeOf :: ConstPtr a -> Int
$calignment :: forall a. ConstPtr a -> Int
alignment :: ConstPtr a -> Int
$cpeekElemOff :: forall a. Ptr (ConstPtr a) -> Int -> IO (ConstPtr a)
peekElemOff :: Ptr (ConstPtr a) -> Int -> IO (ConstPtr a)
$cpokeElemOff :: forall a. Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO ()
pokeElemOff :: Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO ()
$cpeekByteOff :: forall a b. Ptr b -> Int -> IO (ConstPtr a)
peekByteOff :: forall b. Ptr b -> Int -> IO (ConstPtr a)
$cpokeByteOff :: forall a b. Ptr b -> Int -> ConstPtr a -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> ConstPtr a -> IO ()
$cpeek :: forall a. Ptr (ConstPtr a) -> IO (ConstPtr a)
peek :: Ptr (ConstPtr a) -> IO (ConstPtr a)
$cpoke :: forall a. Ptr (ConstPtr a) -> ConstPtr a -> IO ()
poke :: Ptr (ConstPtr a) -> ConstPtr a -> IO ()
Storable)

instance Show (ConstPtr a) where
    showsPrec :: Int -> ConstPtr a -> ShowS
showsPrec Int
d (ConstPtr Ptr a
p) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"ConstPtr " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Ptr a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Ptr a
p

#endif