diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55a63c9..03142a8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,13 +10,14 @@ on: jobs: build: + name: ghc-${{ matrix.ghc }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: ghc: ['8.0', '8.2', '8.4', '8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10', '9.12'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: haskell-actions/setup@v2 id: setup-haskell with: @@ -29,3 +30,24 @@ jobs: key: ${{ runner.os }}-${{ matrix.ghc }} - name: Build run: cabal build + + mhs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + path: parallel + - name: Checkout MicroHs repository + uses: actions/checkout@v5 + with: + repository: augustss/MicroHs + path: mhs + - name: Install MicroHs + run: | + cd mhs + make minstall + echo "$HOME/.mcabal/bin" >> $GITHUB_PATH + - name: Build + run: | + cd parallel + mcabal -r build diff --git a/Control/Parallel.hs b/Control/Parallel.hs index de3d929..390f3fc 100644 --- a/Control/Parallel.hs +++ b/Control/Parallel.hs @@ -28,9 +28,9 @@ module Control.Parallel ( #ifdef __GLASGOW_HASKELL__ import qualified GHC.Conc (par, pseq) +#endif infixr 0 `par`, `pseq` -#endif -- Maybe parIO and the like could be added here later. @@ -54,7 +54,7 @@ par :: a -> b -> b #ifdef __GLASGOW_HASKELL__ par = GHC.Conc.par #else --- For now, Hugs does not support par properly. +-- For now, Hugs and MicroHs don't support par properly. par a b = b #endif diff --git a/Control/Parallel/Strategies.hs b/Control/Parallel/Strategies.hs index ca3b700..81aadd6 100644 --- a/Control/Parallel/Strategies.hs +++ b/Control/Parallel/Strategies.hs @@ -146,15 +146,17 @@ module Control.Parallel.Strategies ( NFData ) where -#if !MIN_VERSION_base(4,8,0) +#if defined(__MHS__) || !MIN_VERSION_base(4,8,0) import Data.Traversable +#endif +#if !MIN_VERSION_base(4,8,0) import Control.Applicative #endif import Control.Parallel import Control.DeepSeq (NFData(rnf)) import Control.Monad.Fix (MonadFix (..)) -#if MIN_VERSION_base(4,4,0) +#if defined(__GLASGOW_HASKELL__) && MIN_VERSION_base(4,4,0) import System.IO.Unsafe (unsafeDupablePerformIO) import Control.Exception (evaluate) #else @@ -164,8 +166,10 @@ import Control.Monad import qualified Control.Seq +#ifdef __GLASGOW_HASKELL__ import GHC.Exts import GHC.IO (IO (..)) +#endif infixr 9 `dot` -- same as (.) infixl 0 `using` -- lowest precedence and associate to the left @@ -280,7 +284,11 @@ instance Applicative Eval where instance Monad Eval where return = pure +# ifdef __GLASGOW_HASKELL__ Done x >>= k = lazy (k x) -- Note: pattern 'Done x' makes '>>=' strict +# else + Done x >>= k = k x +# endif instance MonadFix Eval where mfix f = let r = f (runEval r) in r @@ -463,10 +471,14 @@ rdeepseq x = do rseq (rnf x); return x -- | 'rpar' sparks its argument (for evaluation in parallel). rpar :: Strategy a +#ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__ >= 702 -rpar x = Eval $ IO $ \s -> spark# x s +rpar x = Eval $ IO $ \s -> spark# x s +#else +rpar x = case (par# x) of _ -> Done x +#endif #else -rpar x = case (par# x) of { _ -> Done x } +rpar x = case par x () of () -> Done x #endif {-# INLINE rpar #-} diff --git a/Control/Seq.hs b/Control/Seq.hs index 04e1487..e09cc40 100644 --- a/Control/Seq.hs +++ b/Control/Seq.hs @@ -59,7 +59,7 @@ module Control.Seq ) where import Control.DeepSeq (NFData, deepseq) -#if MIN_VERSION_base(4,8,0) +#if defined(__GLASGOW_HASKELL__) && MIN_VERSION_base(4,8,0) import Data.Foldable (toList) #else import Data.Foldable (Foldable, toList) diff --git a/parallel.cabal b/parallel.cabal index 6d775f5..025c070 100644 --- a/parallel.cabal +++ b/parallel.cabal @@ -25,6 +25,7 @@ tested-with: GHC == 8.4.4 GHC == 8.2.2 GHC == 8.0.2 + MHS description: This package provides a library for parallel programming. @@ -68,6 +69,3 @@ library if impl(ghc >= 6.11) -- To improve parallel performance: ghc-options: -feager-blackholing - - if impl(ghc >= 7.2.1) - build-depends: ghc-prim