diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b16d2bb..98fd7d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,11 @@ defaults: run: shell: bash +# Cancel running actions when a new action on the same PR is started +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: cabal: name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} @@ -18,29 +23,38 @@ jobs: matrix: include: ### -- Linux -- - - { cabal: "3.4", os: ubuntu-latest, ghc: "7.10.3" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.0.2" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.2.2" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.4.4" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.6.5" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.8.4" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "8.10.7" } - - { cabal: "3.4", os: ubuntu-latest, ghc: "9.0.1" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "9.2.1", skip-bench: "true" } + - { cabal: "3.4", os: ubuntu-20.04, ghc: "7.10.3" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.0.2" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.2.2" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.4.4" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.6.5" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.8.4" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "8.10.7" } + - { cabal: "3.4", os: ubuntu-latest, ghc: "9.0.2" } + - { cabal: "3.6", os: ubuntu-latest, ghc: "9.2.8", skip-bench: "true" } + - { cabal: "3.10", os: ubuntu-latest, ghc: "9.4.7" } + - { cabal: "3.10", os: ubuntu-latest, ghc: "9.6.3" } + - { cabal: "3.10", os: ubuntu-latest, ghc: "9.8.1" } ## -- Win -- - - { cabal: "3.4", os: windows-latest, ghc: "8.4.4" } - - { cabal: "3.4", os: windows-latest, ghc: "8.6.5" } - - { cabal: "3.4", os: windows-latest, ghc: "8.8.4" } - - { cabal: "3.4", os: windows-latest, ghc: "8.10.7" } - - { cabal: "3.4", os: windows-latest, ghc: "9.0.1" } - - { cabal: "3.6", os: windows-latest, ghc: "9.2.1", skip-bench: "true" } + - { cabal: "3.4", os: windows-latest, ghc: "8.4.4" } + - { cabal: "3.4", os: windows-latest, ghc: "8.6.5" } + - { cabal: "3.4", os: windows-latest, ghc: "8.8.4" } + - { cabal: "3.4", os: windows-latest, ghc: "8.10.7" } + - { cabal: "3.4", os: windows-latest, ghc: "9.0.2" } + - { cabal: "3.6", os: windows-latest, ghc: "9.2.8", skip-bench: "true" } + - { cabal: "3.10", os: windows-latest, ghc: "9.4.7" } + - { cabal: "3.10", os: windows-latest, ghc: "9.6.3" } + - { cabal: "3.10", os: windows-latest, ghc: "9.8.1" } # MacOS - - { cabal: "3.4", os: macOS-latest, ghc: "8.4.4" } - - { cabal: "3.4", os: macOS-latest, ghc: "8.6.5" } - - { cabal: "3.4", os: macOS-latest, ghc: "8.8.4" } - - { cabal: "3.4", os: macOS-latest, ghc: "8.10.7" } - - { cabal: "3.4", os: macOS-latest, ghc: "9.0.1" } - - { cabal: "3.6", os: macOS-latest, ghc: "9.2.1", skip-bench: "true" } + - { cabal: "3.4", os: macOS-latest, ghc: "8.4.4" } + - { cabal: "3.4", os: macOS-latest, ghc: "8.6.5" } + - { cabal: "3.4", os: macOS-latest, ghc: "8.8.4" } + - { cabal: "3.4", os: macOS-latest, ghc: "8.10.7" } + - { cabal: "3.4", os: macOS-latest, ghc: "9.0.2" } + - { cabal: "3.6", os: macOS-latest, ghc: "9.2.8", skip-bench: "true" } + - { cabal: "3.10", os: macOS-latest, ghc: "9.4.7" } + - { cabal: "3.10", os: macOS-latest, ghc: "9.6.3" } + - { cabal: "3.10", os: macOS-latest, ghc: "9.8.1" } fail-fast: false steps: @@ -50,16 +64,16 @@ jobs: echo M1 ${{ matrix.ghc }} echo M2 ${{ matrix.skip-bench }} # ---------------- - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # ---------------- - - uses: haskell/actions/setup@v1 + - uses: haskell-actions/setup@v2 id: setup-haskell-cabal name: Setup Haskell with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} # ---------------- - - uses: actions/cache@v1 + - uses: actions/cache@v3 name: Cache ~/.cabal/store with: path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} diff --git a/System/Random/MWC.hs b/System/Random/MWC.hs index 0efbc1a..f94b3e5 100644 --- a/System/Random/MWC.hs +++ b/System/Random/MWC.hs @@ -1,6 +1,6 @@ {-# LANGUAGE BangPatterns, CPP, DeriveDataTypeable, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, MagicHash, Rank2Types, - ScopedTypeVariables, TypeFamilies, UnboxedTuples + ScopedTypeVariables, TypeFamilies, TypeOperators, UnboxedTuples #-} -- | -- Module : System.Random.MWC @@ -159,13 +159,16 @@ module System.Random.MWC #endif import Control.Monad (ap, liftM, unless) -import Control.Monad.Primitive (PrimMonad, PrimBase, PrimState, unsafePrimToIO, unsafeSTToPrim) +import Control.Monad.Primitive (PrimMonad, PrimBase, PrimState, unsafePrimToIO, stToPrim) import Control.Monad.ST (ST,runST) import Data.Bits ((.&.), (.|.), shiftL, shiftR, xor) import Data.Int (Int8, Int16, Int32, Int64) import Data.IORef (IORef, atomicModifyIORef, newIORef) import Data.Typeable (Typeable) import Data.Vector.Generic (Vector) +#if __GLASGOW_HASKELL__ >= 800 +import Data.Kind (Type) +#endif import Data.Word import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as GM @@ -462,7 +465,7 @@ instance (s ~ PrimState m, PrimMonad m) => Random.StatefulGen (Gen s) m where {-# INLINE uniformWord32 #-} uniformWord64 = uniform {-# INLINE uniformWord64 #-} - uniformShortByteString n g = unsafeSTToPrim (Random.genShortByteStringST n (uniform g)) + uniformShortByteString n g = stToPrim (Random.genShortByteStringST n (uniform g)) {-# INLINE uniformShortByteString #-} -- | @since 0.15.0.0 @@ -623,7 +626,11 @@ uniform2 f (Gen q) = do -- Type family for fixed size integrals. For signed data types it's -- its unsigned counterpart with same size and for unsigned data types -- it's same type +#if __GLASGOW_HASKELL__ >= 800 +type family Unsigned a :: Type +#else type family Unsigned a :: * +#endif type instance Unsigned Int8 = Word8 type instance Unsigned Int16 = Word16 diff --git a/System/Random/MWC/SeedSource.hs b/System/Random/MWC/SeedSource.hs index 6018ba0..fa4f333 100644 --- a/System/Random/MWC/SeedSource.hs +++ b/System/Random/MWC/SeedSource.hs @@ -22,15 +22,16 @@ import Foreign.Marshal.Array (peekArray) #if defined(mingw32_HOST_OS) import Foreign.Ptr import Foreign.C.Types +#else +import System.IO (IOMode(..), hGetBuf, withBinaryFile) #endif import System.CPUTime (cpuTimePrecision, getCPUTime) -import System.IO (IOMode(..), hGetBuf, withBinaryFile) -- Acquire seed from current time. This is horrible fallback for -- Windows system. acquireSeedTime :: IO [Word32] acquireSeedTime = do - c <- (numerator . (%cpuTimePrecision)) `liftM` getCPUTime + c <- (numerator . (% cpuTimePrecision)) `liftM` getCPUTime t <- toRational `liftM` getPOSIXTime let n = fromIntegral (numerator t) :: Word64 return [fromIntegral c, fromIntegral n, fromIntegral (n `shiftR` 32)] diff --git a/cabal.project b/cabal.project index 7d2ea14..74a6c9c 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,2 @@ packages: mwc-random.cabal - -allow-newer:QuickCheck:splitmix -allow-newer:QuickCheck:random diff --git a/mwc-random.cabal b/mwc-random.cabal index 88f2be3..7781a41 100644 --- a/mwc-random.cabal +++ b/mwc-random.cabal @@ -35,8 +35,13 @@ tested-with: || ==8.2.2 || ==8.4.4 || ==8.6.5 - || ==8.8.3 - || ==8.10.1 + || ==8.8.4 + || ==8.10.7 + || ==9.0.2 + || ==9.2.8 + || ==9.4.7 + || ==9.6.3 + || ==9.8.1 , GHCJS ==8.4 library @@ -103,7 +108,7 @@ test-suite mwc-doctests build-depends: base -any , mwc-random -any - , doctest >=0.15 && <0.20 + , doctest >=0.15 && <0.23 -- , bytestring , primitive diff --git a/stack.yaml b/stack.yaml index b67891c..c0f6cad 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,5 @@ -resolver: lts-15.2 +resolver: lts-21.17 packages: - '.' -extra-deps: -- github: idontgetoutmuch/random - commit: 86e06b8902d4d5c32b14b6a5ef44b964280bcc32 -- splitmix-0.1@sha256:d50c4d0801a35be7875a040470c09863342514930c82a7d25780a6c2efc4fda9,5249 +extra-deps: []