on develop help sign in
Add MonadException for SpiderHost and associated monads
commit2db16855c906571a9860061c70e73214ccead534 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSun 7 Jun 2015, 22:35 (11 years ago) parent09b6664
3 files changed+8−6
default.nix+2−2 reflex.cabal+2−1 src/Reflex/Spider/Internal.hs+4−3
default.nix+2−2
@@ -1,12 +1,12 @@
11{ mkDerivation, dependent-map, dependent-sum
2−, mtl, ref-tf, semigroups, these, MemoTrie
2+, mtl, ref-tf, semigroups, these, MemoTrie, exception-transformers
33}:
44mkDerivation {
55 pname = "reflex";
66 version = "0.1";
77 src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
88 buildDepends = [
9− dependent-map dependent-sum mtl ref-tf semigroups these
9+ dependent-map dependent-sum mtl ref-tf semigroups these exception-transformers
1010 ];
1111 testDepends = [
1212 MemoTrie
reflex.cabal+2−1
@@ -25,7 +25,8 @@ library
2525 these == 0.4.*,
2626 primitive >= 0.5 && < 0.7,
2727 template-haskell >= 2.9 && < 2.11,
28− ref-tf == 0.4.*
28+ ref-tf == 0.4.*,
29+ exception-transformers == 0.4.*
2930
3031 exposed-modules:
3132 Reflex,
src/Reflex/Spider/Internal.hs+4−3
@@ -22,6 +22,7 @@ import Data.Maybe
2222import Data.IntMap (IntMap)
2323import qualified Data.IntMap as IntMap
2424import Control.Monad.Ref
25+import Control.Monad.Exception
2526import Data.Monoid ((<>))
2627
2728import System.IO.Unsafe
@@ -223,7 +224,7 @@ data Root a
223224data SomeHoldInit = forall a. SomeHoldInit (Event a) (Hold a)
224225
225226-- 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
227228
228229data PushSubscribed a b
229230 = 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
13451346 {-# INLINE atomicModifyRef #-}
13461347 atomicModifyRef r f = liftIO $ atomicModifyRef r f
13471348
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)
13491350
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)
13511352
13521353instance R.MonadSample Spider SpiderHostFrame where
13531354 sample = SpiderHostFrame . R.sample --TODO: This can cause problems with laziness, so we should get rid of it if we can