Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3a28af4

Browse files
authored
Merge pull request #8 from haskell-distributed/instances
Add usefull instances for Async
2 parents 08437a0 + 71556d8 commit 3a28af4

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

distributed-process-async.cabal

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ library
4242
stm >= 2.4 && < 2.5,
4343
time > 1.4 && < 1.6,
4444
transformers
45-
if impl(ghc <= 7.5)
46-
Build-Depends: template-haskell == 2.7.0.0,
47-
derive == 2.5.5,
48-
uniplate == 1.6.12,
49-
ghc-prim
5045
extensions: CPP
5146
InstanceSigs
5247
hs-source-dirs: src

src/Control/Distributed/Process/Async.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ module Control.Distributed.Process.Async
5959
, waitBoth
6060
) where
6161

62-
#if ! MIN_VERSION_base(4,6,0)
63-
import Prelude hiding (catch)
64-
#endif
65-
6662
import Control.Applicative
6763
import Control.Concurrent.STM hiding (check)
6864
import Control.Distributed.Process
@@ -74,6 +70,7 @@ import Data.Maybe
7470
)
7571

7672
import System.Timeout (timeout)
73+
import Prelude
7774

7875
-- | Wraps a regular @Process a@ as an 'AsyncTask'.
7976
task :: Process a -> AsyncTask a

src/Control/Distributed/Process/Async/Internal/Types.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{-# LANGUAGE RankNTypes #-}
55
{-# LANGUAGE ExistentialQuantification #-}
66
{-# LANGUAGE DeriveGeneric #-}
7+
{-# LANGUAGE DeriveFunctor #-}
78

89
-- | shared, internal types for the Async package
910
module Control.Distributed.Process.Async.Internal.Types
@@ -23,6 +24,7 @@ import Control.Distributed.Process.Serializable
2324
)
2425
import Data.Binary
2526
import Data.Typeable (Typeable)
27+
import Data.Monoid
2628

2729
import GHC.Generics
2830

@@ -40,11 +42,14 @@ data Async a = Async {
4042
_asyncWorker :: AsyncRef
4143
, _asyncMonitor :: AsyncRef
4244
, _asyncWait :: STM (AsyncResult a)
43-
}
45+
} deriving (Functor)
4446

4547
instance Eq (Async a) where
4648
Async a b _ == Async c d _ = a == c && b == d
4749

50+
instance Ord (Async a) where
51+
compare (Async a b _) (Async c d _) = a `compare` c <> b `compare` d
52+
4853
-- | A task to be performed asynchronously.
4954
data AsyncTask a =
5055
AsyncTask {
@@ -67,7 +72,8 @@ data AsyncResult a =
6772
| AsyncLinkFailed DiedReason -- ^ a link failure and the reason
6873
| AsyncCancelled -- ^ a cancelled action
6974
| AsyncPending -- ^ a pending action (that is still running)
70-
deriving (Typeable, Generic)
75+
deriving (Typeable, Generic, Functor)
76+
7177

7278
instance Serializable a => Binary (AsyncResult a) where
7379

0 commit comments

Comments
 (0)