From 3d3480847734dd09763b9c5c41c99294c2718618 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 4 Oct 2025 19:57:10 +0200 Subject: [PATCH 1/5] Make it compile with MicroHs --- Control/Parallel.hs | 4 ++-- Control/Parallel/Strategies.hs | 20 ++++++++++++++++---- Control/Seq.hs | 2 +- parallel.cabal | 4 +--- 4 files changed, 20 insertions(+), 10 deletions(-) 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..ba1c698 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 From 518a83a78b149a49fb2c95d9b0013e8073a8db8a Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 4 Oct 2025 20:15:05 +0200 Subject: [PATCH 2/5] Add MicroHs CI --- .github/workflows/ci.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55a63c9..a1bd94b 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,19 @@ jobs: key: ${{ runner.os }}-${{ matrix.ghc }} - name: Build run: cabal build + + mhs: + runs-on: ubuntu-latest + steps: + - name: Checkout MicroHs repository + uses: actions/checkout@v5 + with: + repository: augustss/MicroHs + ref: stable-7 + - name: Install MicroHs + run: make minstall + - uses: actions/checkout@v5 + - name: Build + run: | + PATH="$HOME/.mcabal/bin:$PATH" + mcabal -r build From db9577121367e594d1b0d9b6476af0fe6c093e36 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 4 Oct 2025 20:24:50 +0200 Subject: [PATCH 3/5] Fix typo --- Control/Parallel/Strategies.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Control/Parallel/Strategies.hs b/Control/Parallel/Strategies.hs index ba1c698..81aadd6 100644 --- a/Control/Parallel/Strategies.hs +++ b/Control/Parallel/Strategies.hs @@ -146,7 +146,7 @@ module Control.Parallel.Strategies ( NFData ) where -#if defined(__MHS) || !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) From e83784817eb2ed07d3cd295a3005714d26a1b0c2 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 4 Oct 2025 20:35:05 +0200 Subject: [PATCH 4/5] Update MicroHs CI --- .github/workflows/ci.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a1bd94b..2e15265 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,15 +34,20 @@ jobs: 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 - ref: stable-7 + path: mhs - name: Install MicroHs - run: make minstall - - uses: actions/checkout@v5 + run: | + cd mhs + make minstall - name: Build run: | + cd parallel PATH="$HOME/.mcabal/bin:$PATH" mcabal -r build From e5ec718e55da75348f7cb9dc7ea2db49e4182ae7 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 11 Oct 2025 15:42:50 +0200 Subject: [PATCH 5/5] Use `GITHUB_PATH` --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2e15265..03142a8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,8 +46,8 @@ jobs: run: | cd mhs make minstall + echo "$HOME/.mcabal/bin" >> $GITHUB_PATH - name: Build run: | cd parallel - PATH="$HOME/.mcabal/bin:$PATH" mcabal -r build