Skip to content

Commit 3d34808

Browse files
committed
Make it compile with MicroHs
1 parent 82b72a7 commit 3d34808

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Control/Parallel.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module Control.Parallel (
2828

2929
#ifdef __GLASGOW_HASKELL__
3030
import qualified GHC.Conc (par, pseq)
31+
#endif
3132

3233
infixr 0 `par`, `pseq`
33-
#endif
3434

3535
-- Maybe parIO and the like could be added here later.
3636

@@ -54,7 +54,7 @@ par :: a -> b -> b
5454
#ifdef __GLASGOW_HASKELL__
5555
par = GHC.Conc.par
5656
#else
57-
-- For now, Hugs does not support par properly.
57+
-- For now, Hugs and MicroHs don't support par properly.
5858
par a b = b
5959
#endif
6060

Control/Parallel/Strategies.hs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,17 @@ module Control.Parallel.Strategies (
146146
NFData
147147
) where
148148

149-
#if !MIN_VERSION_base(4,8,0)
149+
#if defined(__MHS) || !MIN_VERSION_base(4,8,0)
150150
import Data.Traversable
151+
#endif
152+
#if !MIN_VERSION_base(4,8,0)
151153
import Control.Applicative
152154
#endif
153155
import Control.Parallel
154156
import Control.DeepSeq (NFData(rnf))
155157
import Control.Monad.Fix (MonadFix (..))
156158

157-
#if MIN_VERSION_base(4,4,0)
159+
#if defined(__GLASGOW_HASKELL__) && MIN_VERSION_base(4,4,0)
158160
import System.IO.Unsafe (unsafeDupablePerformIO)
159161
import Control.Exception (evaluate)
160162
#else
@@ -164,8 +166,10 @@ import Control.Monad
164166

165167
import qualified Control.Seq
166168

169+
#ifdef __GLASGOW_HASKELL__
167170
import GHC.Exts
168171
import GHC.IO (IO (..))
172+
#endif
169173

170174
infixr 9 `dot` -- same as (.)
171175
infixl 0 `using` -- lowest precedence and associate to the left
@@ -280,7 +284,11 @@ instance Applicative Eval where
280284

281285
instance Monad Eval where
282286
return = pure
287+
# ifdef __GLASGOW_HASKELL__
283288
Done x >>= k = lazy (k x) -- Note: pattern 'Done x' makes '>>=' strict
289+
# else
290+
Done x >>= k = k x
291+
# endif
284292

285293
instance MonadFix Eval where
286294
mfix f = let r = f (runEval r) in r
@@ -463,10 +471,14 @@ rdeepseq x = do rseq (rnf x); return x
463471

464472
-- | 'rpar' sparks its argument (for evaluation in parallel).
465473
rpar :: Strategy a
474+
#ifdef __GLASGOW_HASKELL__
466475
#if __GLASGOW_HASKELL__ >= 702
467-
rpar x = Eval $ IO $ \s -> spark# x s
476+
rpar x = Eval $ IO $ \s -> spark# x s
477+
#else
478+
rpar x = case (par# x) of _ -> Done x
479+
#endif
468480
#else
469-
rpar x = case (par# x) of { _ -> Done x }
481+
rpar x = case par x () of () -> Done x
470482
#endif
471483
{-# INLINE rpar #-}
472484

Control/Seq.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module Control.Seq
5959
) where
6060

6161
import Control.DeepSeq (NFData, deepseq)
62-
#if MIN_VERSION_base(4,8,0)
62+
#if defined(__GLASGOW_HASKELL__) && MIN_VERSION_base(4,8,0)
6363
import Data.Foldable (toList)
6464
#else
6565
import Data.Foldable (Foldable, toList)

parallel.cabal

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tested-with:
2525
GHC == 8.4.4
2626
GHC == 8.2.2
2727
GHC == 8.0.2
28+
MHS
2829

2930
description:
3031
This package provides a library for parallel programming.
@@ -68,6 +69,3 @@ library
6869
if impl(ghc >= 6.11)
6970
-- To improve parallel performance:
7071
ghc-options: -feager-blackholing
71-
72-
if impl(ghc >= 7.2.1)
73-
build-depends: ghc-prim

0 commit comments

Comments
 (0)