@@ -123,6 +123,7 @@ import Data.Coerce (coerce, Coercible)
123import Data.Aeson
123import Data.Aeson
124 (defaultOptions, genericToEncoding, ToJSON(..), FromJSON(..), Value)
124 (defaultOptions, genericToEncoding, ToJSON(..), FromJSON(..), Value)
125import GHC.Generics (Generic)
125import GHC.Generics (Generic)
126+import Control.Monad.IO.Unlift (MonadUnliftIO)
128#if MIN_VERSION_base(4,9,0) && defined(CHECK_UNCHECKED)
129#if MIN_VERSION_base(4,9,0) && defined(CHECK_UNCHECKED)
@@ -164,7 +165,7 @@ data JSContextRef = JSContextRef {
164type JSM = IO
165type JSM = IO
166newtype JSM a = JSM { unJSM :: ReaderT JSContextRef IO a }
167newtype JSM a = JSM { unJSM :: ReaderT JSContextRef IO a }
167− deriving (Functor, Applicative, Monad, MonadIO, MonadFix, MonadThrow)
168+ deriving (Functor, Applicative, Monad, MonadIO, MonadFix, MonadThrow, MonadUnliftIO)
169instance MonadCatch JSM where
170instance MonadCatch JSM where
170 t `catch` c = JSM (unJSM (syncAfter t) `catch` \e -> unJSM (c e))
171 t `catch` c = JSM (unJSM (syncAfter t) `catch` \e -> unJSM (c e))
@@ -177,6 +178,7 @@ instance MonadMask JSM where
177 JSM $ uninterruptibleMask $ \unmask -> unJSM (a $ q unmask)
178 JSM $ uninterruptibleMask $ \unmask -> unJSM (a $ q unmask)
178 where q :: (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a) -> JSM a -> JSM a
179 where q :: (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a) -> JSM a -> JSM a
179 q unmask (JSM b) = syncAfter . JSM $ unmask b
180 q unmask (JSM b) = syncAfter . JSM $ unmask b
182-- | Forces execution of pending asyncronous code
184-- | Forces execution of pending asyncronous code