From 3c195907c7e7c41fa0888237b6e36cdbde67df59 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Mon, 5 Apr 2021 11:30:24 +0800 Subject: [PATCH] add support for basement compilation with 9.0.1 --- .haskell-ci | 17 +++++------------ basement/Basement/BoxedArray.hs | 1 + basement/Basement/Compat/Primitive.hs | 4 +++- basement/Basement/FinalPtr.hs | 18 +++++++++--------- basement/Basement/Monad.hs | 1 + stack.yaml | 4 ++-- 6 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.haskell-ci b/.haskell-ci index a9965f18..66f728c7 100644 --- a/.haskell-ci +++ b/.haskell-ci @@ -1,11 +1,7 @@ # compiler supported and their equivalent LTS -compiler: ghc-8.0 lts-9.21 -compiler: ghc-8.2 lts-11.22 -compiler: ghc-8.4 lts-12.9 -compiler: ghc-8.4-edge lts-12.26 -compiler: ghc-8.4-experimental lts-12.26 compiler: ghc-8.6 lts-14.4 -compiler: ghc-8.8 ghc-8.8.1 +compiler: ghc-8.8 lts-16.8 +compiler: ghc-8.10 nightly-2020-08-08 # options option: gaugedep extradep=gauge-0.2.1 @@ -13,14 +9,11 @@ option: checkbounds flag=foundation:bounds-check flag=foundation:linktest option: experimental flag=foundation:experimental # builds -build: ghc-8.2 checkbounds gaugedep -build: ghc-8.0 checkbounds gaugedep -build: ghc-8.4-edge checkbounds package=edge/ -build: ghc-8.4-experimental checkbounds experimental allowed-failure gaugedep build: ghc-8.6 os=osx,linux,windows build: ghc-8.6 os=win32 -build: ghc-8.6 checkbounds os=osx,linux,windows -build: ghc-8.8 os=osx,linux,windows extradep=gauge-0.2.4@sha256:b8b19a8c13ab79097726d0edf91297ccd3eede053d1de47e3ac67f1252cc33c2,3777 extradep=vector-0.12.0.3@sha256:1422b0bcf4e7675116ca8d9f473bf239850c58c4518a56010e3bfebeac345ace,7171 extradep=primitive-0.7.0.0@sha256:ee352d97cc390d8513530029a2213a95c179a66c406906b18d03702c1d9ab8e5,3416 +build: ghc-8.8 checkbounds os=osx,linux,windows +build: ghc-8.8 os=osx,linux,windows +build: ghc-8.10 os=osx,linux,windows # packages package: foundation/ diff --git a/basement/Basement/BoxedArray.hs b/basement/Basement/BoxedArray.hs index e73a0c4f..72d5de89 100644 --- a/basement/Basement/BoxedArray.hs +++ b/basement/Basement/BoxedArray.hs @@ -86,6 +86,7 @@ import qualified Basement.Alg.Class as Alg import qualified Basement.Alg.Mutable as Alg import Basement.Compat.MonadTrans import Basement.Compat.Semigroup +import Basement.Compat.Primitive import Basement.Types.OffsetSize import Basement.PrimType import Basement.NormalForm diff --git a/basement/Basement/Compat/Primitive.hs b/basement/Basement/Compat/Primitive.hs index 71d9d54d..14593c51 100644 --- a/basement/Basement/Compat/Primitive.hs +++ b/basement/Basement/Compat/Primitive.hs @@ -15,6 +15,7 @@ module Basement.Compat.Primitive , compatMkWeak# , compatIsByteArrayPinned# , compatIsMutableByteArrayPinned# + , unsafeCoerce# , Word(..) ) where @@ -26,7 +27,8 @@ import GHC.IO import Basement.Compat.PrimTypes --- GHC 8.8 | Base 4.13 +-- GHC 9.0 | Base 4.15 +-- GHC 8.8 | Base 4.13 4.14 -- GHC 8.6 | Base 4.12 -- GHC 8.4 | Base 4.11 -- GHC 8.2 | Base 4.10 diff --git a/basement/Basement/FinalPtr.hs b/basement/Basement/FinalPtr.hs index 1b3582ca..7136d677 100644 --- a/basement/Basement/FinalPtr.hs +++ b/basement/Basement/FinalPtr.hs @@ -25,7 +25,7 @@ module Basement.FinalPtr ) where import GHC.Ptr -import GHC.ForeignPtr +import qualified GHC.ForeignPtr as GHCF import GHC.IO import Basement.Monad import Basement.Compat.Primitive @@ -35,7 +35,7 @@ import Control.Monad.ST (runST) -- | Create a pointer with an associated finalizer data FinalPtr a = FinalPtr (Ptr a) - | FinalForeign (ForeignPtr a) + | FinalForeign (GHCF.ForeignPtr a) instance Show (FinalPtr a) where show f = runST $ withFinalPtr f (pure . show) instance Eq (FinalPtr a) where @@ -50,7 +50,7 @@ instance Ord (FinalPtr a) where -- same address, they should be the same final ptr finalPtrSameMemory :: FinalPtr a -> FinalPtr b -> Bool finalPtrSameMemory (FinalPtr p1) (FinalPtr p2) = p1 == castPtr p2 -finalPtrSameMemory (FinalForeign p1) (FinalForeign p2) = p1 == castForeignPtr p2 +finalPtrSameMemory (FinalForeign p1) (FinalForeign p2) = p1 == GHCF.castForeignPtr p2 finalPtrSameMemory (FinalForeign _) (FinalPtr _) = False finalPtrSameMemory (FinalPtr _) (FinalForeign _) = False @@ -62,17 +62,17 @@ toFinalPtr ptr finalizer = unsafePrimFromIO (primitive makeWithFinalizer) case compatMkWeak# ptr () (finalizer ptr) s of { (# s2, _ #) -> (# s2, FinalPtr ptr #) } -- | Create a new FinalPtr from a ForeignPtr -toFinalPtrForeign :: ForeignPtr a -> FinalPtr a +toFinalPtrForeign :: GHCF.ForeignPtr a -> FinalPtr a toFinalPtrForeign fptr = FinalForeign fptr -- | Cast a finalized pointer from type a to type b castFinalPtr :: FinalPtr a -> FinalPtr b castFinalPtr (FinalPtr a) = FinalPtr (castPtr a) -castFinalPtr (FinalForeign a) = FinalForeign (castForeignPtr a) +castFinalPtr (FinalForeign a) = FinalForeign (GHCF.castForeignPtr a) withFinalPtrNoTouch :: FinalPtr p -> (Ptr p -> a) -> a withFinalPtrNoTouch (FinalPtr ptr) f = f ptr -withFinalPtrNoTouch (FinalForeign fptr) f = f (unsafeForeignPtrToPtr fptr) +withFinalPtrNoTouch (FinalForeign fptr) f = f (GHCF.unsafeForeignPtrToPtr fptr) {-# INLINE withFinalPtrNoTouch #-} -- | Looks at the raw pointer inside a FinalPtr, making sure the @@ -83,14 +83,14 @@ withFinalPtr (FinalPtr ptr) f = do primTouch ptr pure r withFinalPtr (FinalForeign fptr) f = do - r <- f (unsafeForeignPtrToPtr fptr) - unsafePrimFromIO (touchForeignPtr fptr) + r <- f (GHCF.unsafeForeignPtrToPtr fptr) + unsafePrimFromIO (GHCF.touchForeignPtr fptr) pure r {-# INLINE withFinalPtr #-} touchFinalPtr :: PrimMonad prim => FinalPtr p -> prim () touchFinalPtr (FinalPtr ptr) = primTouch ptr -touchFinalPtr (FinalForeign fptr) = unsafePrimFromIO (touchForeignPtr fptr) +touchFinalPtr (FinalForeign fptr) = unsafePrimFromIO (GHCF.touchForeignPtr fptr) -- | Unsafe version of 'withFinalPtr' withUnsafeFinalPtr :: PrimMonad prim => FinalPtr p -> (Ptr p -> prim a) -> a diff --git a/basement/Basement/Monad.hs b/basement/Basement/Monad.hs index 6433f604..92a8d97e 100644 --- a/basement/Basement/Monad.hs +++ b/basement/Basement/Monad.hs @@ -35,6 +35,7 @@ import GHC.IORef import GHC.IO import GHC.Prim import Basement.Compat.Base (Exception, (.), ($), Applicative, Monad) +import Basement.Compat.Primitive -- | Primitive monad that can handle mutation. -- diff --git a/stack.yaml b/stack.yaml index c3c98ca4..26e8de93 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,3 +1,3 @@ -# ~*~ auto-generated by haskell-ci with config : 5fcf42690a95126489f593db1999c5b25084b4dec209b49ed45d1bdbc875ba2e ~*~ -{ resolver: lts-14.27, packages: [ foundation/, basement/ ], extra-deps: [], flags: {} } +# ~*~ auto-generated by haskell-ci with config : 3de811e97e86e191bcc37197cf3c81d3d54dcc04f2838ea87b9e78be24ac0adf ~*~ +{ resolver: nightly-2021-04-01, compiler: ghc-9.0.1, packages: [ foundation/, basement/ ], extra-deps: [], flags: {} }