maoe / lifted-async

Run lifted IO operations asynchronously and wait for their results
http://hackage.haskell.org/package/lifted-async
BSD 3-Clause "New" or "Revised" License
29 stars 13 forks source link

lifted-async-0.3.0 compile error with GHC 7.10.1RC #9

Closed hvr closed 9 years ago

hvr commented 9 years ago
Downloading lifted-async-0.3.0...
Configuring lifted-async-0.3.0...
Building lifted-async-0.3.0...
Preprocessing library lifted-async-0.3.0...
[1 of 2] Compiling Control.Concurrent.Async.Lifted ( src/Control/Concurrent/Async/Lifted.hs, dist/dist-sandbox-494f498f/build/Control/Concurrent/Async/Lifted.o )

src/Control/Concurrent/Async/Lifted.hs:389:10:
    Couldn't match type ‘b’ with ‘IO’
      ‘b’ is a rigid type variable bound by
          the instance declaration
          at src/Control/Concurrent/Async/Lifted.hs:389:10
    In the instance declaration for ‘Monad (Concurrently b m)’
Failed to install lifted-async-0.3.0
cabal: Error: some packages failed to install:
lifted-async-0.3.0 failed during the building phase. The exception was:
ExitFailure 1
maoe commented 9 years ago

Thanks for reporting. I don't have GHC 7.10 at the moment. I'll set it up and fix the issue.

hvr commented 9 years ago

@maoe the problem is the line

instance Monad m => Monad (Concurrently b m) where
  return = Concurrently . return
  Concurrently a >>= f = Concurrently $ a >>= runConcurrently . f

changing that to

instance Monad m => Monad (Concurrently IO m) where
   ...

let's it compile, but I'm not sure if this is the proper fix

UPDATE: nevermind -- something's still wrong

hvr commented 9 years ago

Here's what I had to change to make it compile, but I'm not sure this is the proper way:

diff --git a/src/Control/Concurrent/Async/Lifted.hs b/src/Control/Concurrent/Async/Lifted.hs
index 00677a7..b3961ad 100644
--- a/src/Control/Concurrent/Async/Lifted.hs
+++ b/src/Control/Concurrent/Async/Lifted.hs
@@ -386,7 +386,7 @@ instance (b ~ IO, MonadBaseControl b m) => Alternative (Concurrently b m) where
   Concurrently as <|> Concurrently bs =
     Concurrently $ either id id <$> race as bs

-instance Monad m => Monad (Concurrently b m) where
+instance (b ~ IO, MonadBaseControl b m) => Monad (Concurrently b m) where
   return = Concurrently . return
   Concurrently a >>= f = Concurrently $ a >>= runConcurrently . f

diff --git a/src/Control/Concurrent/Async/Lifted/Safe.hs b/src/Control/Concurrent/Async/Lifted/Safe.hs
index ab366b6..21eb5bb 100644
--- a/src/Control/Concurrent/Async/Lifted/Safe.hs
+++ b/src/Control/Concurrent/Async/Lifted/Safe.hs
@@ -325,7 +325,7 @@ instance (base ~ IO, MonadBaseControl base m, Forall (Pure m)) =>
         \\ (inst :: Forall (Pure m) :- Pure m a)
         \\ (inst :: Forall (Pure m) :- Pure m b)

-instance (Monad m, Forall (Pure m)) => Monad (Concurrently base m) where
+instance (base ~ IO, MonadBaseControl base m, Forall (Pure m)) => Monad (Concurrently base m) where
   return = Concurrently . return
   Concurrently a >>= f = Concurrently $ a >>= runConcurrently . f
 #endif
maoe commented 9 years ago

Ah I see. I think we have to add those constraints for 7.10 due to the AMP change. I'll fix and make a release shortly.

maoe commented 9 years ago

Fixed the issue and just released as v0.4.0.