packages feed

base-compat-constptr (empty) → 0.1.0.0

raw patch · 2 files changed

+74/−0 lines, 2 filesdep +base

Dependencies added: base

Files

+ base-compat-constptr.cabal view
@@ -0,0 +1,39 @@+cabal-version: 3.0+name:          base-compat-constptr+version:       0.1.0.0+synopsis:      Backport of 'Foreign.C.ConstPtr'+description:   Backport of 'Foreign.C.ConstPtr'.+license:       AGPL-3.0-only+author:        Wen Kokke+maintainer:    wenkokke@users.noreply.github.com+category:      Foreign+build-type:    Simple+tested-with:+  GHC ==8.10.7+   || ==9.0.2+   || ==9.2.8+   || ==9.4.8+   || ==9.6.7+   || ==9.8.4+   || ==9.10.2+   || ==9.12.2++common language+  ghc-options:+    -Wall -Wcompat -Widentities -Wprepositive-qualified-module+    -Wredundant-constraints -Wunticked-promoted-constructors+    -Wunused-packages++  default-language:   Haskell2010+  default-extensions: ImportQualifiedPost++  if impl(ghc <9.6.1)+    ghc-options:+      -optc=-Wno-discarded-qualifiers+      -optc=-Wno-incompatible-pointer-types-discards-qualifiers++library+  import:          language+  exposed-modules: Foreign.C.ConstPtr.Compat+  build-depends:   base >=4.13 && <5+  hs-source-dirs:  src
+ src/Foreign/C/ConstPtr/Compat.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE CPP #-}+#if MIN_VERSION_base(4,18,0)+#else+{-# LANGUAGE RoleAnnotations #-}+#endif+{-| The t'ConstPtr' type was introduced in GHC 9.6.1. However, it is required+  when writing C bindings to a function involving the const annotation using+  the CApi calling convention (see 'Foreign.C.ConstPtr.ConstPtr').+  This module defines t'ConstPtr' for compatibility with earlier versions of+  GHC. Unfortunately, older versions of GHC do not emit the 'const' qualifier+  when emitting the C header files. Therefore, it is also necessary to add+  the following conditional option to your Cabal file:++  @+  if impl(ghc <9.6.1)+    ghc-options: -optc=-Wno-incompatible-pointer-types-discards-qualifiers -optc=-Wno-discarded-qualifiers+  @+-}+module Foreign.C.ConstPtr.Compat (+  ConstPtr (..),+) where++#if MIN_VERSION_base(4,18,0)+import Foreign.C.ConstPtr (ConstPtr(..))+#else+import Foreign.Ptr (Ptr)++type role ConstPtr phantom+newtype ConstPtr a = ConstPtr { unConstPtr :: Ptr a }+    deriving (Eq, Ord)++-- doesn't use record syntax+instance Show (ConstPtr a) where+    showsPrec d (ConstPtr p) = showParen (d > 10) $ showString "ConstPtr " . showsPrec 11 p+#endif