Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions Control/Parallel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down
20 changes: 16 additions & 4 deletions Control/Parallel/Strategies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 #-}

Expand Down
2 changes: 1 addition & 1 deletion Control/Seq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions parallel.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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