botan-bindings-0.2.0.0: src/Botan/Bindings/ConstPtr.hs
{-# LANGUAGE CPP #-}
module Botan.Bindings.ConstPtr (
ConstPtr(..)
) where
#if MIN_VERSION_base (4,18,0)
import Foreign.C.ConstPtr
#else
import Data.Data
import Data.Kind
import Foreign.Ptr
import Foreign.Storable
#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 { unConstPtr :: Ptr a }
deriving stock (Data)
deriving newtype (Eq, Ord, Storable)
instance Show (ConstPtr a) where
showsPrec d (ConstPtr p) = showParen (d > 10) $ showString "ConstPtr " . showsPrec 11 p
#endif