on develop help sign in
Add MonadException for SpiderHost and associated monads
2db1685Ryan Trinkle
default.nix+2−2
@@ -1,12 +1,12 @@
1{ mkDerivation, dependent-map, dependent-sum
1{ mkDerivation, dependent-map, dependent-sum
2−, mtl, ref-tf, semigroups, these, MemoTrie
2+, mtl, ref-tf, semigroups, these, MemoTrie, exception-transformers
3}:
3}:
4mkDerivation {
4mkDerivation {
5 pname = "reflex";
5 pname = "reflex";
6 version = "0.1";
6 version = "0.1";
7 src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
7 src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
8 buildDepends = [
8 buildDepends = [
9− dependent-map dependent-sum mtl ref-tf semigroups these
9+ dependent-map dependent-sum mtl ref-tf semigroups these exception-transformers
10 ];
10 ];
11 testDepends = [
11 testDepends = [
12 MemoTrie
12 MemoTrie
reflex.cabal+2−1
@@ -25,7 +25,8 @@ library
25 these == 0.4.*,
25 these == 0.4.*,
26 primitive >= 0.5 && < 0.7,
26 primitive >= 0.5 && < 0.7,
27 template-haskell >= 2.9 && < 2.11,
27 template-haskell >= 2.9 && < 2.11,
28− ref-tf == 0.4.*
28+ ref-tf == 0.4.*,
29+ exception-transformers == 0.4.*
29
30
30 exposed-modules:
31 exposed-modules:
31 Reflex,
32 Reflex,
src/Reflex/Spider/Internal.hs+4−3
@@ -22,6 +22,7 @@ import Data.Maybe
22import Data.IntMap (IntMap)
22import Data.IntMap (IntMap)
23import qualified Data.IntMap as IntMap
23import qualified Data.IntMap as IntMap
24import Control.Monad.Ref
24import Control.Monad.Ref
25+import Control.Monad.Exception
25import Data.Monoid ((<>))
26import Data.Monoid ((<>))
26
27
27import System.IO.Unsafe
28import System.IO.Unsafe
@@ -223,7 +224,7 @@ data Root a
223data SomeHoldInit = forall a. SomeHoldInit (Event a) (Hold a)
224data SomeHoldInit = forall a. SomeHoldInit (Event a) (Hold a)
224
225
225-- EventM can do everything BehaviorM can, plus create holds
226-- EventM can do everything BehaviorM can, plus create holds
226−newtype EventM a = EventM { unEventM :: ReaderT EventEnv IO a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO) -- The environment should be Nothing if we are not in a frame, and Just if we are - in which case it is a list of assignments to be done after the frame is over
227+newtype EventM a = EventM { unEventM :: ReaderT EventEnv IO a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadException, MonadAsyncException) -- The environment should be Nothing if we are not in a frame, and Just if we are - in which case it is a list of assignments to be done after the frame is over
227
228
228data PushSubscribed a b
229data PushSubscribed a b
229 = PushSubscribed { pushSubscribedOccurrence :: !(IORef (Maybe b)) -- If the current height is less than our height, this should always be Nothing; during our height, this will get filled in at some point, always before our children are notified; after our height, this will be filled in with the correct value (Nothing if we are not firing, Just if we are)
230 = PushSubscribed { pushSubscribedOccurrence :: !(IORef (Maybe b)) -- If the current height is less than our height, this should always be Nothing; during our height, this will get filled in at some point, always before our children are notified; after our height, this will be filled in with the correct value (Nothing if we are not firing, Just if we are)
@@ -1345,9 +1346,9 @@ instance MonadAtomicRef EventM where
1345 {-# INLINE atomicModifyRef #-}
1346 {-# INLINE atomicModifyRef #-}
1346 atomicModifyRef r f = liftIO $ atomicModifyRef r f
1347 atomicModifyRef r f = liftIO $ atomicModifyRef r f
1347
1348
1348−newtype SpiderHost a = SpiderHost { runSpiderHost :: IO a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO)
1349+newtype SpiderHost a = SpiderHost { runSpiderHost :: IO a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadException, MonadAsyncException)
1349
1350
1350−newtype SpiderHostFrame a = SpiderHostFrame { runSpiderHostFrame :: EventM a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO)
1351+newtype SpiderHostFrame a = SpiderHostFrame { runSpiderHostFrame :: EventM a } deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadException, MonadAsyncException)
1351
1352
1352instance R.MonadSample Spider SpiderHostFrame where
1353instance R.MonadSample Spider SpiderHostFrame where
1353 sample = SpiderHostFrame . R.sample --TODO: This can cause problems with laziness, so we should get rid of it if we can
1354 sample = SpiderHostFrame . R.sample --TODO: This can cause problems with laziness, so we should get rid of it if we can