{-# LANGUAGE ConstraintKinds            #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE UndecidableInstances       #-}
-- | This module contains a minimum yet convenient API needed to get started
-- writing reflex apps with sdl2.
--
-- For an example see
-- [app/Main.hs](https://github.com/schell/reflex-sdl2/blob/master/app/Main.hs)
module Reflex.SDL2
  ( -- * Running an app
    host

    -- * Gracefully shutting down an app
  , shutdownOn

    -- * The reflex-sdl2 class
  , HasSDL2Events (..)
    -- * Base transformer
  , ReflexSDL2T
    -- * Common constraints (most powerful but convenient)
  , ReflexSDL2
    -- * Concrete stack
  , ConcreteReflexSDL2

    -- * Higher order switching
  , holdView
  , dynView

    -- * Time and recurring timer events
  , TickInfo(..)
  , getDeltaTickEvent
  , performEventDelta

    -- * Async events
  , getAsyncEvent

    -- * Debugging
  , putDebugLnE

    -- * Re-exports
  , module SDL
  , MonadIO
  , liftIO
  ) where

import           Control.Concurrent       (newChan, newEmptyMVar, putMVar,
                                           readChan, takeMVar)
import           Control.Concurrent.Async (async, cancel)
import           Control.Monad            (forM_, unless, void, guard)
import           Control.Monad.Fix        (MonadFix)
import           Control.Monad.Identity   (Identity (..))
import           Control.Monad.Reader
import           Control.Monad.Ref        (readRef)
import           Data.Dependent.Sum       (DSum ((:=>)))
import           Data.Function            (fix)
import           Data.Word                (Word32)
import           GHC.Conc                 (atomically, newTVar, readTVar,
                                           readTVarIO, writeTVar)
import           Reflex
import           Reflex.Host.Class
import           SDL                      hiding (Event, delay)

import           Reflex.SDL2.Base
import           Reflex.SDL2.Class
import           Reflex.SDL2.Internal


------------------------------------------------------------------------------
-- | A collection of constraints that represent the default reflex-sdl2 network.
type ReflexSDL2 t m = ( Reflex t
                      , MonadHold t m
                      , MonadSample t m
                      , Adjustable t m
                      , PostBuild t m
                      , PerformEvent t m
                      , TriggerEvent t m
                      , MonadFix m
                      , MonadIO m
                      , MonadIO (Performable m)
                      , HasSDL2Events t m
                      )


--------------------------------------------------------------------------------
-- | Returns an event that fires each frame with the number of milliseconds
-- since the last frame.
-- Be aware that subscribing to this 'Event' (by using it in a monadic action)
-- will result in your app running sdl2's event loop every frame.
getDeltaTickEvent
  :: (MonadHold t m, MonadFix m, HasSDL2Events t m) => m (Event t Word32)
getDeltaTickEvent :: forall t (m :: * -> *).
(MonadHold t m, MonadFix m, HasSDL2Events t m) =>
m (Event t Word32)
getDeltaTickEvent = do
  let f :: (b, b) -> b -> (b, b)
f (b
lastTick, b
_) b
thisTick = (b
thisTick, b
thisTick b -> b -> b
forall a. Num a => a -> a -> a
- b
lastTick)
  Event t (Word32, Word32)
evTickAndDel <- ((Word32, Word32) -> Word32 -> (Word32, Word32))
-> (Word32, Word32)
-> Event t Word32
-> m (Event t (Word32, Word32))
forall {k} (t :: k) (f :: * -> *) (m :: * -> *) a b.
(Accumulator t f, MonadHold t m, MonadFix m) =>
(a -> b -> a) -> a -> Event t b -> m (f a)
forall (m :: * -> *) a b.
(MonadHold t m, MonadFix m) =>
(a -> b -> a) -> a -> Event t b -> m (Event t a)
accum (Word32, Word32) -> Word32 -> (Word32, Word32)
forall {b} {b}. Num b => (b, b) -> b -> (b, b)
f (Word32
0, Word32
0) (Event t Word32 -> m (Event t (Word32, Word32)))
-> m (Event t Word32) -> m (Event t (Word32, Word32))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m (Event t Word32)
forall t (m :: * -> *). HasSDL2Events t m => m (Event t Word32)
getTicksEvent
  Event t Word32 -> m (Event t Word32)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Event t Word32 -> m (Event t Word32))
-> Event t Word32 -> m (Event t Word32)
forall a b. (a -> b) -> a -> b
$ (Word32, Word32) -> Word32
forall a b. (a, b) -> b
snd ((Word32, Word32) -> Word32)
-> Event t (Word32, Word32) -> Event t Word32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t (Word32, Word32)
evTickAndDel


-- | Populate the event value with the time in milliseconds since the last time
-- the event fired.
performEventDelta :: ReflexSDL2 t m => Event t a -> m (Event t Word32)
performEventDelta :: forall t (m :: * -> *) a.
ReflexSDL2 t m =>
Event t a -> m (Event t Word32)
performEventDelta Event t a
ev = do
  Word32
tnow <- m Word32
forall (m :: * -> *). MonadIO m => m Word32
ticks
  Event t Word32
evTicks <- Event t (Performable m Word32) -> m (Event t Word32)
forall a. Event t (Performable m a) -> m (Event t a)
forall t (m :: * -> *) a.
PerformEvent t m =>
Event t (Performable m a) -> m (Event t a)
performEvent (Event t (Performable m Word32) -> m (Event t Word32))
-> Event t (Performable m Word32) -> m (Event t Word32)
forall a b. (a -> b) -> a -> b
$ Performable m Word32
forall (m :: * -> *). MonadIO m => m Word32
ticks Performable m Word32 -> Event t a -> Event t (Performable m Word32)
forall a b. a -> Event t b -> Event t a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Event t a
ev
  ((Word32, Word32) -> Word32)
-> Event t (Word32, Word32) -> Event t Word32
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Word32, Word32) -> Word32
forall a b. (a, b) -> a
fst (Event t (Word32, Word32) -> Event t Word32)
-> m (Event t (Word32, Word32)) -> m (Event t Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Word32, Word32) -> Word32 -> (Word32, Word32))
-> (Word32, Word32)
-> Event t Word32
-> m (Event t (Word32, Word32))
forall {k} (t :: k) (f :: * -> *) (m :: * -> *) a b.
(Accumulator t f, MonadHold t m, MonadFix m) =>
(a -> b -> a) -> a -> Event t b -> m (f a)
forall (m :: * -> *) a b.
(MonadHold t m, MonadFix m) =>
(a -> b -> a) -> a -> Event t b -> m (Event t a)
accum (\(Word32
_, Word32
prev) Word32
now -> (Word32
now Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
prev, Word32
now)) (Word32
0, Word32
tnow) Event t Word32
evTicks


--------------------------------------------------------------------------------
getAsyncEvent :: ReflexSDL2 t m => IO a -> m (Event t a)
getAsyncEvent :: forall t (m :: * -> *) a. ReflexSDL2 t m => IO a -> m (Event t a)
getAsyncEvent IO a
f = do
  (Event t a
ev, a -> IO ()
g) <- m (Event t a, a -> IO ())
forall a. m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
  m (Async ()) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (Async ()) -> m ()) -> m (Async ()) -> m ()
forall a b. (a -> b) -> a -> b
$ IO (Async ()) -> m (Async ())
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Async ()) -> m (Async ())) -> IO (Async ()) -> m (Async ())
forall a b. (a -> b) -> a -> b
$ IO () -> IO (Async ())
forall a. IO a -> IO (Async a)
async (IO () -> IO (Async ())) -> IO () -> IO (Async ())
forall a b. (a -> b) -> a -> b
$ IO a
f IO a -> (a -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> IO ()
g
  Event t a -> m (Event t a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Event t a
ev


--------------------------------------------------------------------------------
-- $grace
-- | Will exit the main reflex-sdl2 loop when the given Event fires. This allows
-- the programmer to shut down the network before shutting down SDL.
shutdownOn
  :: (PerformEvent t m, MonadIO (Performable m), HasSDL2Events t m)
  => Event t ()
  -> m ()
shutdownOn :: forall t (m :: * -> *).
(PerformEvent t m, MonadIO (Performable m), HasSDL2Events t m) =>
Event t () -> m ()
shutdownOn Event t ()
ev = do
  MVar ()
var <- m (MVar ())
forall t (m :: * -> *). HasSDL2Events t m => m (MVar ())
getQuitVar
  Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_ (Event t (Performable m ()) -> m ())
-> Event t (Performable m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ IO () -> Performable m ()
forall a. IO a -> Performable m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (MVar () -> () -> IO ()
forall a. MVar a -> a -> IO ()
putMVar MVar ()
var ()) Performable m () -> Event t () -> Event t (Performable m ())
forall a b. a -> Event t b -> Event t a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Event t ()
ev


--------------------------------------------------------------------------------
-- | The monomorphic type used to run reflex-sdl2 apps.
type ConcreteReflexSDL2 = ReflexSDL2T Spider (TriggerEventT Spider (PostBuildT Spider (PerformEventT Spider (SpiderHost Global))))


------------------------------------------------------------------------------
-- | Host a reflex-sdl2 app.
host
  :: ConcreteReflexSDL2 ()
  -- ^ A concrete reflex-sdl2 network to run.
  -> IO ()
host :: ConcreteReflexSDL2 () -> IO ()
host ConcreteReflexSDL2 ()
app = SpiderHost Global () -> IO ()
forall a. SpiderHost Global a -> IO a
runSpiderHost (SpiderHost Global () -> IO ()) -> SpiderHost Global () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
  -- Get events and trigger refs for all things that can happen.
  (Event Spider ()
sysPostBuildEvent,                                 IORef (Maybe (EventTrigger Spider ()))
trPostBuildRef) <- SpiderHost
  Global (Event Spider (), IORef (Maybe (EventTrigger Spider ())))
SpiderHost
  Global
  (Event Spider (),
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider ())))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider EventPayload
sysAnySDLEvent,                                       IORef (Maybe (EventTrigger Spider EventPayload))
trAnySDLRef) <- SpiderHost
  Global
  (Event Spider EventPayload,
   IORef (Maybe (EventTrigger Spider EventPayload)))
SpiderHost
  Global
  (Event Spider EventPayload,
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider EventPayload)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider Word32
sysTicksEvent,                                         IORef (Maybe (EventTrigger Spider Word32))
trTicksRef) <- SpiderHost
  Global
  (Event Spider Word32, IORef (Maybe (EventTrigger Spider Word32)))
SpiderHost
  Global
  (Event Spider Word32,
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider Word32)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowShownEventData
sysWindowShownEvent,                             IORef (Maybe (EventTrigger Spider WindowShownEventData))
trWindowShownRef) <- SpiderHost
  Global
  (Event Spider WindowShownEventData,
   IORef (Maybe (EventTrigger Spider WindowShownEventData)))
SpiderHost
  Global
  (Event Spider WindowShownEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowShownEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowHiddenEventData
sysWindowHiddenEvent,                           IORef (Maybe (EventTrigger Spider WindowHiddenEventData))
trWindowHiddenRef) <- SpiderHost
  Global
  (Event Spider WindowHiddenEventData,
   IORef (Maybe (EventTrigger Spider WindowHiddenEventData)))
SpiderHost
  Global
  (Event Spider WindowHiddenEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowHiddenEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowExposedEventData
sysWindowExposedEvent,                         IORef (Maybe (EventTrigger Spider WindowExposedEventData))
trWindowExposedRef) <- SpiderHost
  Global
  (Event Spider WindowExposedEventData,
   IORef (Maybe (EventTrigger Spider WindowExposedEventData)))
SpiderHost
  Global
  (Event Spider WindowExposedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowExposedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowMovedEventData
sysWindowMovedEvent,                             IORef (Maybe (EventTrigger Spider WindowMovedEventData))
trWindowMovedRef) <- SpiderHost
  Global
  (Event Spider WindowMovedEventData,
   IORef (Maybe (EventTrigger Spider WindowMovedEventData)))
SpiderHost
  Global
  (Event Spider WindowMovedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowMovedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowResizedEventData
sysWindowResizedEvent,                         IORef (Maybe (EventTrigger Spider WindowResizedEventData))
trWindowResizedRef) <- SpiderHost
  Global
  (Event Spider WindowResizedEventData,
   IORef (Maybe (EventTrigger Spider WindowResizedEventData)))
SpiderHost
  Global
  (Event Spider WindowResizedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowResizedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowSizeChangedEventData
sysWindowSizeChangedEvent,                 IORef (Maybe (EventTrigger Spider WindowSizeChangedEventData))
trWindowSizeChangedRef) <- SpiderHost
  Global
  (Event Spider WindowSizeChangedEventData,
   IORef (Maybe (EventTrigger Spider WindowSizeChangedEventData)))
SpiderHost
  Global
  (Event Spider WindowSizeChangedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowSizeChangedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowMinimizedEventData
sysWindowMinimizedEvent,                     IORef (Maybe (EventTrigger Spider WindowMinimizedEventData))
trWindowMinimizedRef) <- SpiderHost
  Global
  (Event Spider WindowMinimizedEventData,
   IORef (Maybe (EventTrigger Spider WindowMinimizedEventData)))
SpiderHost
  Global
  (Event Spider WindowMinimizedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowMinimizedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowMaximizedEventData
sysWindowMaximizedEvent,                     IORef (Maybe (EventTrigger Spider WindowMaximizedEventData))
trWindowMaximizedRef) <- SpiderHost
  Global
  (Event Spider WindowMaximizedEventData,
   IORef (Maybe (EventTrigger Spider WindowMaximizedEventData)))
SpiderHost
  Global
  (Event Spider WindowMaximizedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowMaximizedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowRestoredEventData
sysWindowRestoredEvent,                       IORef (Maybe (EventTrigger Spider WindowRestoredEventData))
trWindowRestoredRef) <- SpiderHost
  Global
  (Event Spider WindowRestoredEventData,
   IORef (Maybe (EventTrigger Spider WindowRestoredEventData)))
SpiderHost
  Global
  (Event Spider WindowRestoredEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowRestoredEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowGainedMouseFocusEventData
sysWindowGainedMouseFocusEvent,       IORef (Maybe (EventTrigger Spider WindowGainedMouseFocusEventData))
trWindowGainedMouseFocusRef) <- SpiderHost
  Global
  (Event Spider WindowGainedMouseFocusEventData,
   IORef
     (Maybe (EventTrigger Spider WindowGainedMouseFocusEventData)))
SpiderHost
  Global
  (Event Spider WindowGainedMouseFocusEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowGainedMouseFocusEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowLostMouseFocusEventData
sysWindowLostMouseFocusEvent,           IORef (Maybe (EventTrigger Spider WindowLostMouseFocusEventData))
trWindowLostMouseFocusRef) <- SpiderHost
  Global
  (Event Spider WindowLostMouseFocusEventData,
   IORef (Maybe (EventTrigger Spider WindowLostMouseFocusEventData)))
SpiderHost
  Global
  (Event Spider WindowLostMouseFocusEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowLostMouseFocusEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowGainedKeyboardFocusEventData
sysWindowGainedKeyboardFocusEvent, IORef
  (Maybe (EventTrigger Spider WindowGainedKeyboardFocusEventData))
trWindowGainedKeyboardFocusRef) <- SpiderHost
  Global
  (Event Spider WindowGainedKeyboardFocusEventData,
   IORef
     (Maybe (EventTrigger Spider WindowGainedKeyboardFocusEventData)))
SpiderHost
  Global
  (Event Spider WindowGainedKeyboardFocusEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowGainedKeyboardFocusEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowLostKeyboardFocusEventData
sysWindowLostKeyboardFocusEvent,     IORef
  (Maybe (EventTrigger Spider WindowLostKeyboardFocusEventData))
trWindowLostKeyboardFocusRef) <- SpiderHost
  Global
  (Event Spider WindowLostKeyboardFocusEventData,
   IORef
     (Maybe (EventTrigger Spider WindowLostKeyboardFocusEventData)))
SpiderHost
  Global
  (Event Spider WindowLostKeyboardFocusEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowLostKeyboardFocusEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider WindowClosedEventData
sysWindowClosedEvent,                           IORef (Maybe (EventTrigger Spider WindowClosedEventData))
trWindowClosedRef) <- SpiderHost
  Global
  (Event Spider WindowClosedEventData,
   IORef (Maybe (EventTrigger Spider WindowClosedEventData)))
SpiderHost
  Global
  (Event Spider WindowClosedEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider WindowClosedEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider KeyboardEventData
sysKeyboardEvent,                                   IORef (Maybe (EventTrigger Spider KeyboardEventData))
trKeyboardRef) <- SpiderHost
  Global
  (Event Spider KeyboardEventData,
   IORef (Maybe (EventTrigger Spider KeyboardEventData)))
SpiderHost
  Global
  (Event Spider KeyboardEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider KeyboardEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider TextEditingEventData
sysTextEditingEvent,                             IORef (Maybe (EventTrigger Spider TextEditingEventData))
trTextEditingRef) <- SpiderHost
  Global
  (Event Spider TextEditingEventData,
   IORef (Maybe (EventTrigger Spider TextEditingEventData)))
SpiderHost
  Global
  (Event Spider TextEditingEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider TextEditingEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider TextInputEventData
sysTextInputEvent,                                 IORef (Maybe (EventTrigger Spider TextInputEventData))
trTextInputRef) <- SpiderHost
  Global
  (Event Spider TextInputEventData,
   IORef (Maybe (EventTrigger Spider TextInputEventData)))
SpiderHost
  Global
  (Event Spider TextInputEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider TextInputEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ()
sysKeymapChangedEvent,                         IORef (Maybe (EventTrigger Spider ()))
trKeymapChangedRef) <- SpiderHost
  Global (Event Spider (), IORef (Maybe (EventTrigger Spider ())))
SpiderHost
  Global
  (Event Spider (),
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider ())))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider MouseMotionEventData
sysMouseMotionEvent,                             IORef (Maybe (EventTrigger Spider MouseMotionEventData))
trMouseMotionRef) <- SpiderHost
  Global
  (Event Spider MouseMotionEventData,
   IORef (Maybe (EventTrigger Spider MouseMotionEventData)))
SpiderHost
  Global
  (Event Spider MouseMotionEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider MouseMotionEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider MouseButtonEventData
sysMouseButtonEvent,                             IORef (Maybe (EventTrigger Spider MouseButtonEventData))
trMouseButtonRef) <- SpiderHost
  Global
  (Event Spider MouseButtonEventData,
   IORef (Maybe (EventTrigger Spider MouseButtonEventData)))
SpiderHost
  Global
  (Event Spider MouseButtonEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider MouseButtonEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider MouseWheelEventData
sysMouseWheelEvent,                               IORef (Maybe (EventTrigger Spider MouseWheelEventData))
trMouseWheelRef) <- SpiderHost
  Global
  (Event Spider MouseWheelEventData,
   IORef (Maybe (EventTrigger Spider MouseWheelEventData)))
SpiderHost
  Global
  (Event Spider MouseWheelEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider MouseWheelEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider JoyAxisEventData
sysJoyAxisEvent,                                     IORef (Maybe (EventTrigger Spider JoyAxisEventData))
trJoyAxisRef) <- SpiderHost
  Global
  (Event Spider JoyAxisEventData,
   IORef (Maybe (EventTrigger Spider JoyAxisEventData)))
SpiderHost
  Global
  (Event Spider JoyAxisEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider JoyAxisEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider JoyBallEventData
sysJoyBallEvent,                                     IORef (Maybe (EventTrigger Spider JoyBallEventData))
trJoyBallRef) <- SpiderHost
  Global
  (Event Spider JoyBallEventData,
   IORef (Maybe (EventTrigger Spider JoyBallEventData)))
SpiderHost
  Global
  (Event Spider JoyBallEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider JoyBallEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider JoyHatEventData
sysJoyHatEvent,                                       IORef (Maybe (EventTrigger Spider JoyHatEventData))
trJoyHatRef) <- SpiderHost
  Global
  (Event Spider JoyHatEventData,
   IORef (Maybe (EventTrigger Spider JoyHatEventData)))
SpiderHost
  Global
  (Event Spider JoyHatEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider JoyHatEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider JoyButtonEventData
sysJoyButtonEvent,                                 IORef (Maybe (EventTrigger Spider JoyButtonEventData))
trJoyButtonRef) <- SpiderHost
  Global
  (Event Spider JoyButtonEventData,
   IORef (Maybe (EventTrigger Spider JoyButtonEventData)))
SpiderHost
  Global
  (Event Spider JoyButtonEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider JoyButtonEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider JoyDeviceEventData
sysJoyDeviceEvent,                                 IORef (Maybe (EventTrigger Spider JoyDeviceEventData))
trJoyDeviceRef) <- SpiderHost
  Global
  (Event Spider JoyDeviceEventData,
   IORef (Maybe (EventTrigger Spider JoyDeviceEventData)))
SpiderHost
  Global
  (Event Spider JoyDeviceEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider JoyDeviceEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ControllerAxisEventData
sysControllerAxisEvent,                       IORef (Maybe (EventTrigger Spider ControllerAxisEventData))
trControllerAxisRef) <- SpiderHost
  Global
  (Event Spider ControllerAxisEventData,
   IORef (Maybe (EventTrigger Spider ControllerAxisEventData)))
SpiderHost
  Global
  (Event Spider ControllerAxisEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider ControllerAxisEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ControllerButtonEventData
sysControllerButtonEvent,                   IORef (Maybe (EventTrigger Spider ControllerButtonEventData))
trControllerButtonRef) <- SpiderHost
  Global
  (Event Spider ControllerButtonEventData,
   IORef (Maybe (EventTrigger Spider ControllerButtonEventData)))
SpiderHost
  Global
  (Event Spider ControllerButtonEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider ControllerButtonEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ControllerDeviceEventData
sysControllerDeviceEvent,                   IORef (Maybe (EventTrigger Spider ControllerDeviceEventData))
trControllerDeviceRef) <- SpiderHost
  Global
  (Event Spider ControllerDeviceEventData,
   IORef (Maybe (EventTrigger Spider ControllerDeviceEventData)))
SpiderHost
  Global
  (Event Spider ControllerDeviceEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider ControllerDeviceEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider AudioDeviceEventData
sysAudioDeviceEvent,                             IORef (Maybe (EventTrigger Spider AudioDeviceEventData))
trAudioDeviceRef) <- SpiderHost
  Global
  (Event Spider AudioDeviceEventData,
   IORef (Maybe (EventTrigger Spider AudioDeviceEventData)))
SpiderHost
  Global
  (Event Spider AudioDeviceEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider AudioDeviceEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ()
sysQuitEvent,                                           IORef (Maybe (EventTrigger Spider ()))
trQuitRef) <- SpiderHost
  Global (Event Spider (), IORef (Maybe (EventTrigger Spider ())))
SpiderHost
  Global
  (Event Spider (),
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider ())))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider UserEventData
sysUserEvent,                                           IORef (Maybe (EventTrigger Spider UserEventData))
trUserRef) <- SpiderHost
  Global
  (Event Spider UserEventData,
   IORef (Maybe (EventTrigger Spider UserEventData)))
SpiderHost
  Global
  (Event Spider UserEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider UserEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider SysWMEventData
sysSysWMEvent,                                         IORef (Maybe (EventTrigger Spider SysWMEventData))
trSysWMRef) <- SpiderHost
  Global
  (Event Spider SysWMEventData,
   IORef (Maybe (EventTrigger Spider SysWMEventData)))
SpiderHost
  Global
  (Event Spider SysWMEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider SysWMEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider TouchFingerEventData
sysTouchFingerEvent,                             IORef (Maybe (EventTrigger Spider TouchFingerEventData))
trTouchFingerRef) <- SpiderHost
  Global
  (Event Spider TouchFingerEventData,
   IORef (Maybe (EventTrigger Spider TouchFingerEventData)))
SpiderHost
  Global
  (Event Spider TouchFingerEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider TouchFingerEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider TouchFingerMotionEventData
sysTouchFingerMotionEvent,                 IORef (Maybe (EventTrigger Spider TouchFingerMotionEventData))
trTouchFingerMotionRef) <- SpiderHost
  Global
  (Event Spider TouchFingerMotionEventData,
   IORef (Maybe (EventTrigger Spider TouchFingerMotionEventData)))
SpiderHost
  Global
  (Event Spider TouchFingerMotionEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider TouchFingerMotionEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider MultiGestureEventData
sysMultiGestureEvent,                           IORef (Maybe (EventTrigger Spider MultiGestureEventData))
trMultiGestureRef) <- SpiderHost
  Global
  (Event Spider MultiGestureEventData,
   IORef (Maybe (EventTrigger Spider MultiGestureEventData)))
SpiderHost
  Global
  (Event Spider MultiGestureEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider MultiGestureEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider DollarGestureEventData
sysDollarGestureEvent,                         IORef (Maybe (EventTrigger Spider DollarGestureEventData))
trDollarGestureRef) <- SpiderHost
  Global
  (Event Spider DollarGestureEventData,
   IORef (Maybe (EventTrigger Spider DollarGestureEventData)))
SpiderHost
  Global
  (Event Spider DollarGestureEventData,
   Ref
     (SpiderHost Global)
     (Maybe (EventTrigger Spider DollarGestureEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider DropEventData
sysDropEvent,                                           IORef (Maybe (EventTrigger Spider DropEventData))
trDropRef) <- SpiderHost
  Global
  (Event Spider DropEventData,
   IORef (Maybe (EventTrigger Spider DropEventData)))
SpiderHost
  Global
  (Event Spider DropEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider DropEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider ()
sysClipboardUpdateEvent,                     IORef (Maybe (EventTrigger Spider ()))
trClipboardUpdateRef) <- SpiderHost
  Global (Event Spider (), IORef (Maybe (EventTrigger Spider ())))
SpiderHost
  Global
  (Event Spider (),
   Ref (SpiderHost Global) (Maybe (EventTrigger Spider ())))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
  (Event Spider UnknownEventData
sysUnknownEvent,                                     IORef (Maybe (EventTrigger Spider UnknownEventData))
trUnknownRef) <- SpiderHost
  Global
  (Event Spider UnknownEventData,
   IORef (Maybe (EventTrigger Spider UnknownEventData)))
SpiderHost
  Global
  (Event Spider UnknownEventData,
   Ref
     (SpiderHost Global) (Maybe (EventTrigger Spider UnknownEventData)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef

  -- Build the network and get our firing command to trigger the post build event,
  -- then loop forever in another thread, dequeueing triggers from our chan and
  -- placing them into a TVar. Push a new user event into the SDL event queue that
  -- will set off a read of the TVar and the firing of the triggers within the
  -- main loop.
  -- Also - create som quit vars to communicate when our loops should absolutely end.
  Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
chan        <- IO (Chan [DSum (EventTriggerRef Spider) TriggerInvocation])
-> SpiderHost
     Global (Chan [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Chan [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a. IO (Chan a)
newChan
  TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
triggersVar <- IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
-> SpiderHost
     Global (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
 -> SpiderHost
      Global (TVar [DSum (EventTriggerRef Spider) TriggerInvocation]))
-> IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
-> SpiderHost
     Global (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a b. (a -> b) -> a -> b
$ STM (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
-> IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a. STM a -> IO a
atomically (STM (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
 -> IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation]))
-> STM (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
-> IO (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a b. (a -> b) -> a -> b
$ [DSum (EventTriggerRef Spider) TriggerInvocation]
-> STM (TVar [DSum (EventTriggerRef Spider) TriggerInvocation])
forall a. a -> STM (TVar a)
newTVar []
  MVar ()
sysQuitVar  <- IO (MVar ()) -> SpiderHost Global (MVar ())
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (MVar ())
forall a. IO (MVar a)
newEmptyMVar
  TVar Bool
mainQuitVar <- IO (TVar Bool) -> SpiderHost Global (TVar Bool)
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (TVar Bool) -> SpiderHost Global (TVar Bool))
-> IO (TVar Bool) -> SpiderHost Global (TVar Bool)
forall a b. (a -> b) -> a -> b
$ STM (TVar Bool) -> IO (TVar Bool)
forall a. STM a -> IO a
atomically (STM (TVar Bool) -> IO (TVar Bool))
-> STM (TVar Bool) -> IO (TVar Bool)
forall a b. (a -> b) -> a -> b
$ Bool -> STM (TVar Bool)
forall a. a -> STM (TVar a)
newTVar Bool
False
  let reservedTriggerCode :: Int32
reservedTriggerCode = Int32
31337
      isJustTriggerData :: RegisteredEventData -> Word32 -> IO (Maybe ())
isJustTriggerData RegisteredEventData
dat Word32
_ =
        Maybe () -> IO (Maybe ())
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe () -> IO (Maybe ())) -> Maybe () -> IO (Maybe ())
forall a b. (a -> b) -> a -> b
$ Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ RegisteredEventData -> Int32
registeredEventCode RegisteredEventData
dat Int32 -> Int32 -> Bool
forall a. Eq a => a -> a -> Bool
== Int32
reservedTriggerCode
      fromData :: () -> IO RegisteredEventData
fromData () = RegisteredEventData -> IO RegisteredEventData
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return RegisteredEventData
emptyRegisteredEvent{ registeredEventCode :: Int32
registeredEventCode  = Int32
reservedTriggerCode }
  () -> IO EventPushResult
pushTrig <- (RegisteredEventData -> Word32 -> IO (Maybe ()))
-> (() -> IO RegisteredEventData)
-> SpiderHost Global (Maybe (RegisteredEventType ()))
forall (m :: * -> *) a.
MonadIO m =>
(RegisteredEventData -> Word32 -> IO (Maybe a))
-> (a -> IO RegisteredEventData)
-> m (Maybe (RegisteredEventType a))
registerEvent RegisteredEventData -> Word32 -> IO (Maybe ())
isJustTriggerData () -> IO RegisteredEventData
fromData SpiderHost Global (Maybe (RegisteredEventType ()))
-> (Maybe (RegisteredEventType ())
    -> SpiderHost Global (() -> IO EventPushResult))
-> SpiderHost Global (() -> IO EventPushResult)
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
    Maybe (RegisteredEventType ())
Nothing -> [Char] -> SpiderHost Global (() -> IO EventPushResult)
forall a. HasCallStack => [Char] -> a
error [Char]
"Could not register an sdl event for TriggerEvent."
    Just (RegisteredEventType () -> IO EventPushResult
pushTrig Event -> IO (Maybe ())
_) -> (() -> IO EventPushResult)
-> SpiderHost Global (() -> IO EventPushResult)
forall a. a -> SpiderHost Global a
forall (m :: * -> *) a. Monad m => a -> m a
return () -> IO EventPushResult
pushTrig
  Async Any
asyncTrigger <- IO (Async Any) -> SpiderHost Global (Async Any)
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Async Any) -> SpiderHost Global (Async Any))
-> IO (Async Any) -> SpiderHost Global (Async Any)
forall a b. (a -> b) -> a -> b
$ IO Any -> IO (Async Any)
forall a. IO a -> IO (Async a)
async (IO Any -> IO (Async Any)) -> IO Any -> IO (Async Any)
forall a b. (a -> b) -> a -> b
$ (IO Any -> IO Any) -> IO Any
forall a. (a -> a) -> a
fix ((IO Any -> IO Any) -> IO Any) -> (IO Any -> IO Any) -> IO Any
forall a b. (a -> b) -> a -> b
$ \IO Any
loop -> do
    [DSum (EventTriggerRef Spider) TriggerInvocation]
trigs <- Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
-> IO [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. Chan a -> IO a
readChan Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
chan
    STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
      [DSum (EventTriggerRef Spider) TriggerInvocation]
prevTrigs <- TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
-> STM [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. TVar a -> STM a
readTVar TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
triggersVar
      TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
-> [DSum (EventTriggerRef Spider) TriggerInvocation] -> STM ()
forall a. TVar a -> a -> STM ()
writeTVar TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
triggersVar ([DSum (EventTriggerRef Spider) TriggerInvocation] -> STM ())
-> [DSum (EventTriggerRef Spider) TriggerInvocation] -> STM ()
forall a b. (a -> b) -> a -> b
$ [DSum (EventTriggerRef Spider) TriggerInvocation]
prevTrigs [DSum (EventTriggerRef Spider) TriggerInvocation]
-> [DSum (EventTriggerRef Spider) TriggerInvocation]
-> [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. [a] -> [a] -> [a]
++ [DSum (EventTriggerRef Spider) TriggerInvocation]
trigs
    () -> IO EventPushResult
pushTrig () IO EventPushResult -> (EventPushResult -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
      EventPushResult
EventPushSuccess   -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      EventPushResult
EventPushFiltered  -> [Char] -> IO ()
putStrLn [Char]
"trigger push filtered"
      EventPushFailure Text
t -> Text -> IO ()
forall a. Show a => a -> IO ()
print Text
t
    IO Any
loop
  SpiderHost Global (Async ()) -> SpiderHost Global ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (SpiderHost Global (Async ()) -> SpiderHost Global ())
-> SpiderHost Global (Async ()) -> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ IO (Async ()) -> SpiderHost Global (Async ())
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Async ()) -> SpiderHost Global (Async ()))
-> IO (Async ()) -> SpiderHost Global (Async ())
forall a b. (a -> b) -> a -> b
$ IO () -> IO (Async ())
forall a. IO a -> IO (Async a)
async (IO () -> IO (Async ())) -> IO () -> IO (Async ())
forall a b. (a -> b) -> a -> b
$ do
    MVar () -> IO ()
forall a. MVar a -> IO a
takeMVar MVar ()
sysQuitVar
    STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TVar Bool -> Bool -> STM ()
forall a. TVar a -> a -> STM ()
writeTVar TVar Bool
mainQuitVar Bool
True
    IO EventPushResult -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO EventPushResult -> IO ()) -> IO EventPushResult -> IO ()
forall a b. (a -> b) -> a -> b
$ () -> IO EventPushResult
pushTrig ()
    Async Any -> IO ()
forall a. Async a -> IO ()
cancel Async Any
asyncTrigger

  ((), FireCommand forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire) <-
    PerformEventT Spider (SpiderHost Global) ()
-> SpiderHost Global ((), FireCommand Spider (SpiderHost Global))
forall t (m :: * -> *) a.
(Monad m, MonadSubscribeEvent t m, MonadReflexHost t m, MonadRef m,
 Ref m ~ Ref IO) =>
PerformEventT t m a -> m (a, FireCommand t m)
hostPerformEventT (PerformEventT Spider (SpiderHost Global) ()
 -> SpiderHost Global ((), FireCommand Spider (SpiderHost Global)))
-> PerformEventT Spider (SpiderHost Global) ()
-> SpiderHost Global ((), FireCommand Spider (SpiderHost Global))
forall a b. (a -> b) -> a -> b
$ (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
 -> Event Spider () -> PerformEventT Spider (SpiderHost Global) ())
-> Event Spider ()
-> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
-> PerformEventT Spider (SpiderHost Global) ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
-> Event Spider () -> PerformEventT Spider (SpiderHost Global) ()
forall t (m :: * -> *) a. PostBuildT t m a -> Event t () -> m a
runPostBuildT Event Spider ()
sysPostBuildEvent
                      (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
 -> PerformEventT Spider (SpiderHost Global) ())
-> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
-> PerformEventT Spider (SpiderHost Global) ()
forall a b. (a -> b) -> a -> b
$ (TriggerEventT
   Spider
   (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
   ()
 -> Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
 -> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ())
-> Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
-> TriggerEventT
     Spider
     (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
     ()
-> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip TriggerEventT
  Spider
  (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
  ()
-> Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
-> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
forall t (m :: * -> *) a.
TriggerEventT t m a
-> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
runTriggerEventT Chan [DSum (EventTriggerRef Spider) TriggerInvocation]
chan
                      (TriggerEventT
   Spider
   (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
   ()
 -> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ())
-> TriggerEventT
     Spider
     (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
     ()
-> PostBuildT Spider (PerformEventT Spider (SpiderHost Global)) ()
forall a b. (a -> b) -> a -> b
$ ConcreteReflexSDL2 ()
-> SystemEvents Spider
-> TriggerEventT
     Spider
     (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
     ()
forall t (m :: * -> *) a.
ReflexSDL2T t m a -> SystemEvents t -> m a
runReflexSDL2T ConcreteReflexSDL2 ()
app SystemEvents{MVar ()
Event Spider Word32
Event Spider ()
Event Spider UnknownEventData
Event Spider DropEventData
Event Spider DollarGestureEventData
Event Spider MultiGestureEventData
Event Spider TouchFingerMotionEventData
Event Spider TouchFingerEventData
Event Spider SysWMEventData
Event Spider UserEventData
Event Spider AudioDeviceEventData
Event Spider ControllerDeviceEventData
Event Spider ControllerButtonEventData
Event Spider ControllerAxisEventData
Event Spider JoyDeviceEventData
Event Spider JoyButtonEventData
Event Spider JoyHatEventData
Event Spider JoyBallEventData
Event Spider JoyAxisEventData
Event Spider MouseWheelEventData
Event Spider MouseButtonEventData
Event Spider MouseMotionEventData
Event Spider TextInputEventData
Event Spider TextEditingEventData
Event Spider KeyboardEventData
Event Spider WindowClosedEventData
Event Spider WindowLostKeyboardFocusEventData
Event Spider WindowGainedKeyboardFocusEventData
Event Spider WindowLostMouseFocusEventData
Event Spider WindowGainedMouseFocusEventData
Event Spider WindowRestoredEventData
Event Spider WindowMaximizedEventData
Event Spider WindowMinimizedEventData
Event Spider WindowSizeChangedEventData
Event Spider WindowResizedEventData
Event Spider WindowMovedEventData
Event Spider WindowExposedEventData
Event Spider WindowHiddenEventData
Event Spider WindowShownEventData
Event Spider EventPayload
sysPostBuildEvent :: Event Spider ()
sysAnySDLEvent :: Event Spider EventPayload
sysTicksEvent :: Event Spider Word32
sysWindowShownEvent :: Event Spider WindowShownEventData
sysWindowHiddenEvent :: Event Spider WindowHiddenEventData
sysWindowExposedEvent :: Event Spider WindowExposedEventData
sysWindowMovedEvent :: Event Spider WindowMovedEventData
sysWindowResizedEvent :: Event Spider WindowResizedEventData
sysWindowSizeChangedEvent :: Event Spider WindowSizeChangedEventData
sysWindowMinimizedEvent :: Event Spider WindowMinimizedEventData
sysWindowMaximizedEvent :: Event Spider WindowMaximizedEventData
sysWindowRestoredEvent :: Event Spider WindowRestoredEventData
sysWindowGainedMouseFocusEvent :: Event Spider WindowGainedMouseFocusEventData
sysWindowLostMouseFocusEvent :: Event Spider WindowLostMouseFocusEventData
sysWindowGainedKeyboardFocusEvent :: Event Spider WindowGainedKeyboardFocusEventData
sysWindowLostKeyboardFocusEvent :: Event Spider WindowLostKeyboardFocusEventData
sysWindowClosedEvent :: Event Spider WindowClosedEventData
sysKeyboardEvent :: Event Spider KeyboardEventData
sysTextEditingEvent :: Event Spider TextEditingEventData
sysTextInputEvent :: Event Spider TextInputEventData
sysKeymapChangedEvent :: Event Spider ()
sysMouseMotionEvent :: Event Spider MouseMotionEventData
sysMouseButtonEvent :: Event Spider MouseButtonEventData
sysMouseWheelEvent :: Event Spider MouseWheelEventData
sysJoyAxisEvent :: Event Spider JoyAxisEventData
sysJoyBallEvent :: Event Spider JoyBallEventData
sysJoyHatEvent :: Event Spider JoyHatEventData
sysJoyButtonEvent :: Event Spider JoyButtonEventData
sysJoyDeviceEvent :: Event Spider JoyDeviceEventData
sysControllerAxisEvent :: Event Spider ControllerAxisEventData
sysControllerButtonEvent :: Event Spider ControllerButtonEventData
sysControllerDeviceEvent :: Event Spider ControllerDeviceEventData
sysAudioDeviceEvent :: Event Spider AudioDeviceEventData
sysQuitEvent :: Event Spider ()
sysUserEvent :: Event Spider UserEventData
sysSysWMEvent :: Event Spider SysWMEventData
sysTouchFingerEvent :: Event Spider TouchFingerEventData
sysTouchFingerMotionEvent :: Event Spider TouchFingerMotionEventData
sysMultiGestureEvent :: Event Spider MultiGestureEventData
sysDollarGestureEvent :: Event Spider DollarGestureEventData
sysDropEvent :: Event Spider DropEventData
sysClipboardUpdateEvent :: Event Spider ()
sysUnknownEvent :: Event Spider UnknownEventData
sysQuitVar :: MVar ()
sysPostBuildEvent :: Event Spider ()
sysTicksEvent :: Event Spider Word32
sysAnySDLEvent :: Event Spider EventPayload
sysWindowShownEvent :: Event Spider WindowShownEventData
sysWindowHiddenEvent :: Event Spider WindowHiddenEventData
sysWindowExposedEvent :: Event Spider WindowExposedEventData
sysWindowMovedEvent :: Event Spider WindowMovedEventData
sysWindowResizedEvent :: Event Spider WindowResizedEventData
sysWindowSizeChangedEvent :: Event Spider WindowSizeChangedEventData
sysWindowMinimizedEvent :: Event Spider WindowMinimizedEventData
sysWindowMaximizedEvent :: Event Spider WindowMaximizedEventData
sysWindowRestoredEvent :: Event Spider WindowRestoredEventData
sysWindowGainedMouseFocusEvent :: Event Spider WindowGainedMouseFocusEventData
sysWindowLostMouseFocusEvent :: Event Spider WindowLostMouseFocusEventData
sysWindowGainedKeyboardFocusEvent :: Event Spider WindowGainedKeyboardFocusEventData
sysWindowLostKeyboardFocusEvent :: Event Spider WindowLostKeyboardFocusEventData
sysWindowClosedEvent :: Event Spider WindowClosedEventData
sysKeyboardEvent :: Event Spider KeyboardEventData
sysTextEditingEvent :: Event Spider TextEditingEventData
sysTextInputEvent :: Event Spider TextInputEventData
sysKeymapChangedEvent :: Event Spider ()
sysMouseMotionEvent :: Event Spider MouseMotionEventData
sysMouseButtonEvent :: Event Spider MouseButtonEventData
sysMouseWheelEvent :: Event Spider MouseWheelEventData
sysJoyAxisEvent :: Event Spider JoyAxisEventData
sysJoyBallEvent :: Event Spider JoyBallEventData
sysJoyHatEvent :: Event Spider JoyHatEventData
sysJoyButtonEvent :: Event Spider JoyButtonEventData
sysJoyDeviceEvent :: Event Spider JoyDeviceEventData
sysControllerAxisEvent :: Event Spider ControllerAxisEventData
sysControllerButtonEvent :: Event Spider ControllerButtonEventData
sysControllerDeviceEvent :: Event Spider ControllerDeviceEventData
sysAudioDeviceEvent :: Event Spider AudioDeviceEventData
sysQuitEvent :: Event Spider ()
sysUserEvent :: Event Spider UserEventData
sysSysWMEvent :: Event Spider SysWMEventData
sysTouchFingerEvent :: Event Spider TouchFingerEventData
sysTouchFingerMotionEvent :: Event Spider TouchFingerMotionEventData
sysMultiGestureEvent :: Event Spider MultiGestureEventData
sysDollarGestureEvent :: Event Spider DollarGestureEventData
sysDropEvent :: Event Spider DropEventData
sysClipboardUpdateEvent :: Event Spider ()
sysUnknownEvent :: Event Spider UnknownEventData
sysQuitVar :: MVar ()
..}

  -- Trigger the post build event.
  (Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
-> SpiderHost Global (Maybe (RootTrigger Global ()))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ()))
Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
trPostBuildRef SpiderHost Global (Maybe (RootTrigger Global ()))
-> (Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ()) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global () -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global () -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ()) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global () -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ()
tr ->
    [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ()
tr RootTrigger Global ()
-> Identity () -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> () -> Identity ()
forall a. a -> Identity a
Identity ()] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

  -- Loop forever doing all of our main loop stuff.
  (SpiderHost Global () -> SpiderHost Global ())
-> SpiderHost Global ()
forall a. (a -> a) -> a
fix ((SpiderHost Global () -> SpiderHost Global ())
 -> SpiderHost Global ())
-> (SpiderHost Global () -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \SpiderHost Global ()
loop -> do
    -- Fire any tick events if anyone is listening.
    -- If someone _is_ listening, we need to fire an
    -- event every frame - otherwise we can wait around
    -- for an sdl event to update the network.
    Bool
shouldWait <- Ref (SpiderHost Global) (Maybe (RootTrigger Global Word32))
-> SpiderHost Global (Maybe (RootTrigger Global Word32))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider Word32))
Ref (SpiderHost Global) (Maybe (RootTrigger Global Word32))
trTicksRef SpiderHost Global (Maybe (RootTrigger Global Word32))
-> (Maybe (RootTrigger Global Word32) -> SpiderHost Global Bool)
-> SpiderHost Global Bool
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
      Maybe (RootTrigger Global Word32)
Nothing -> Bool -> SpiderHost Global Bool
forall a. a -> SpiderHost Global a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
      Just RootTrigger Global Word32
tr -> do
        Word32
t <- SpiderHost Global Word32
forall (m :: * -> *). MonadIO m => m Word32
ticks
        SpiderHost Global [()] -> SpiderHost Global ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (SpiderHost Global [()] -> SpiderHost Global ())
-> SpiderHost Global [()] -> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global Word32
tr RootTrigger Global Word32
-> Identity Word32 -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> Word32 -> Identity Word32
forall a. a -> Identity a
Identity Word32
t] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Bool -> SpiderHost Global Bool
forall a. a -> SpiderHost Global a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False

    [EventPayload]
payloads <- (Event -> EventPayload) -> [Event] -> [EventPayload]
forall a b. (a -> b) -> [a] -> [b]
map Event -> EventPayload
eventPayload ([Event] -> [EventPayload])
-> SpiderHost Global [Event] -> SpiderHost Global [EventPayload]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> if Bool
shouldWait
                                     then (:) (Event -> [Event] -> [Event])
-> SpiderHost Global Event
-> SpiderHost Global ([Event] -> [Event])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SpiderHost Global Event
forall (m :: * -> *). MonadIO m => m Event
waitEvent
                                              SpiderHost Global ([Event] -> [Event])
-> SpiderHost Global [Event] -> SpiderHost Global [Event]
forall a b.
SpiderHost Global (a -> b)
-> SpiderHost Global a -> SpiderHost Global b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SpiderHost Global [Event]
forall (m :: * -> *). MonadIO m => m [Event]
pollEvents
                                     else SpiderHost Global [Event]
forall (m :: * -> *). MonadIO m => m [Event]
pollEvents

    [EventPayload]
-> (EventPayload -> SpiderHost Global ()) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [EventPayload]
payloads ((EventPayload -> SpiderHost Global ()) -> SpiderHost Global ())
-> (EventPayload -> SpiderHost Global ()) -> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \case
      WindowShownEvent WindowShownEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowShownEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowShownEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowShownEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowShownEventData))
trWindowShownRef SpiderHost Global (Maybe (RootTrigger Global WindowShownEventData))
-> (Maybe (RootTrigger Global WindowShownEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowShownEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowShownEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowShownEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowShownEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowShownEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowShownEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowShownEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowShownEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowShownEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowShownEventData
tr RootTrigger Global WindowShownEventData
-> Identity WindowShownEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowShownEventData -> Identity WindowShownEventData
forall a. a -> Identity a
Identity WindowShownEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowHiddenEvent WindowHiddenEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowHiddenEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowHiddenEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowHiddenEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowHiddenEventData))
trWindowHiddenRef SpiderHost
  Global (Maybe (RootTrigger Global WindowHiddenEventData))
-> (Maybe (RootTrigger Global WindowHiddenEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowHiddenEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowHiddenEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowHiddenEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowHiddenEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowHiddenEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowHiddenEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowHiddenEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowHiddenEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowHiddenEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowHiddenEventData
tr RootTrigger Global WindowHiddenEventData
-> Identity WindowHiddenEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowHiddenEventData -> Identity WindowHiddenEventData
forall a. a -> Identity a
Identity WindowHiddenEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowExposedEvent WindowExposedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowExposedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowExposedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowExposedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowExposedEventData))
trWindowExposedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowExposedEventData))
-> (Maybe (RootTrigger Global WindowExposedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowExposedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowExposedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowExposedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowExposedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowExposedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowExposedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowExposedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowExposedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowExposedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowExposedEventData
tr RootTrigger Global WindowExposedEventData
-> Identity WindowExposedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowExposedEventData -> Identity WindowExposedEventData
forall a. a -> Identity a
Identity WindowExposedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowMovedEvent WindowMovedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMovedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowMovedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowMovedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMovedEventData))
trWindowMovedRef SpiderHost Global (Maybe (RootTrigger Global WindowMovedEventData))
-> (Maybe (RootTrigger Global WindowMovedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowMovedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowMovedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowMovedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowMovedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowMovedEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowMovedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowMovedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowMovedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowMovedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowMovedEventData
tr RootTrigger Global WindowMovedEventData
-> Identity WindowMovedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowMovedEventData -> Identity WindowMovedEventData
forall a. a -> Identity a
Identity WindowMovedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowResizedEvent WindowResizedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowResizedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowResizedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowResizedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowResizedEventData))
trWindowResizedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowResizedEventData))
-> (Maybe (RootTrigger Global WindowResizedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowResizedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowResizedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowResizedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowResizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowResizedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowResizedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowResizedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowResizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowResizedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowResizedEventData
tr RootTrigger Global WindowResizedEventData
-> Identity WindowResizedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowResizedEventData -> Identity WindowResizedEventData
forall a. a -> Identity a
Identity WindowResizedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowSizeChangedEvent WindowSizeChangedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowSizeChangedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowSizeChangedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowSizeChangedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowSizeChangedEventData))
trWindowSizeChangedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowSizeChangedEventData))
-> (Maybe (RootTrigger Global WindowSizeChangedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowSizeChangedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowSizeChangedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowSizeChangedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowSizeChangedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowSizeChangedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowSizeChangedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowSizeChangedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowSizeChangedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowSizeChangedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowSizeChangedEventData
tr RootTrigger Global WindowSizeChangedEventData
-> Identity WindowSizeChangedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowSizeChangedEventData -> Identity WindowSizeChangedEventData
forall a. a -> Identity a
Identity WindowSizeChangedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowMinimizedEvent WindowMinimizedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMinimizedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowMinimizedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowMinimizedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMinimizedEventData))
trWindowMinimizedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowMinimizedEventData))
-> (Maybe (RootTrigger Global WindowMinimizedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowMinimizedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowMinimizedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowMinimizedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowMinimizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowMinimizedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowMinimizedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowMinimizedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowMinimizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowMinimizedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowMinimizedEventData
tr RootTrigger Global WindowMinimizedEventData
-> Identity WindowMinimizedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowMinimizedEventData -> Identity WindowMinimizedEventData
forall a. a -> Identity a
Identity WindowMinimizedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowMaximizedEvent WindowMaximizedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMaximizedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowMaximizedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowMaximizedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowMaximizedEventData))
trWindowMaximizedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowMaximizedEventData))
-> (Maybe (RootTrigger Global WindowMaximizedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowMaximizedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowMaximizedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowMaximizedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowMaximizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowMaximizedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowMaximizedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowMaximizedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowMaximizedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowMaximizedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowMaximizedEventData
tr RootTrigger Global WindowMaximizedEventData
-> Identity WindowMaximizedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowMaximizedEventData -> Identity WindowMaximizedEventData
forall a. a -> Identity a
Identity WindowMaximizedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowRestoredEvent WindowRestoredEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowRestoredEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowRestoredEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowRestoredEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowRestoredEventData))
trWindowRestoredRef SpiderHost
  Global (Maybe (RootTrigger Global WindowRestoredEventData))
-> (Maybe (RootTrigger Global WindowRestoredEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowRestoredEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowRestoredEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowRestoredEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowRestoredEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowRestoredEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowRestoredEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowRestoredEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowRestoredEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowRestoredEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowRestoredEventData
tr RootTrigger Global WindowRestoredEventData
-> Identity WindowRestoredEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowRestoredEventData -> Identity WindowRestoredEventData
forall a. a -> Identity a
Identity WindowRestoredEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowGainedMouseFocusEvent WindowGainedMouseFocusEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowGainedMouseFocusEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowGainedMouseFocusEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowGainedMouseFocusEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowGainedMouseFocusEventData))
trWindowGainedMouseFocusRef SpiderHost
  Global (Maybe (RootTrigger Global WindowGainedMouseFocusEventData))
-> (Maybe (RootTrigger Global WindowGainedMouseFocusEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowGainedMouseFocusEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowGainedMouseFocusEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowGainedMouseFocusEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowGainedMouseFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowGainedMouseFocusEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowGainedMouseFocusEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowGainedMouseFocusEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowGainedMouseFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowGainedMouseFocusEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowGainedMouseFocusEventData
tr RootTrigger Global WindowGainedMouseFocusEventData
-> Identity WindowGainedMouseFocusEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowGainedMouseFocusEventData
-> Identity WindowGainedMouseFocusEventData
forall a. a -> Identity a
Identity WindowGainedMouseFocusEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowLostMouseFocusEvent WindowLostMouseFocusEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowLostMouseFocusEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowLostMouseFocusEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowLostMouseFocusEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowLostMouseFocusEventData))
trWindowLostMouseFocusRef SpiderHost
  Global (Maybe (RootTrigger Global WindowLostMouseFocusEventData))
-> (Maybe (RootTrigger Global WindowLostMouseFocusEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowLostMouseFocusEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowLostMouseFocusEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowLostMouseFocusEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowLostMouseFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowLostMouseFocusEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowLostMouseFocusEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowLostMouseFocusEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowLostMouseFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowLostMouseFocusEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowLostMouseFocusEventData
tr RootTrigger Global WindowLostMouseFocusEventData
-> Identity WindowLostMouseFocusEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowLostMouseFocusEventData
-> Identity WindowLostMouseFocusEventData
forall a. a -> Identity a
Identity WindowLostMouseFocusEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowGainedKeyboardFocusEvent WindowGainedKeyboardFocusEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData))
-> SpiderHost
     Global
     (Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef
  (Maybe (EventTrigger Spider WindowGainedKeyboardFocusEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData))
trWindowGainedKeyboardFocusRef SpiderHost
  Global
  (Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData))
-> (Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowGainedKeyboardFocusEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowGainedKeyboardFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowGainedKeyboardFocusEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowGainedKeyboardFocusEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowGainedKeyboardFocusEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowGainedKeyboardFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowGainedKeyboardFocusEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowGainedKeyboardFocusEventData
tr RootTrigger Global WindowGainedKeyboardFocusEventData
-> Identity WindowGainedKeyboardFocusEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowGainedKeyboardFocusEventData
-> Identity WindowGainedKeyboardFocusEventData
forall a. a -> Identity a
Identity WindowGainedKeyboardFocusEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowLostKeyboardFocusEvent WindowLostKeyboardFocusEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowLostKeyboardFocusEventData))
-> SpiderHost
     Global
     (Maybe (RootTrigger Global WindowLostKeyboardFocusEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef
  (Maybe (EventTrigger Spider WindowLostKeyboardFocusEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowLostKeyboardFocusEventData))
trWindowLostKeyboardFocusRef SpiderHost
  Global
  (Maybe (RootTrigger Global WindowLostKeyboardFocusEventData))
-> (Maybe (RootTrigger Global WindowLostKeyboardFocusEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowLostKeyboardFocusEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowLostKeyboardFocusEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowLostKeyboardFocusEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowLostKeyboardFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowLostKeyboardFocusEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowLostKeyboardFocusEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowLostKeyboardFocusEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowLostKeyboardFocusEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowLostKeyboardFocusEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowLostKeyboardFocusEventData
tr RootTrigger Global WindowLostKeyboardFocusEventData
-> Identity WindowLostKeyboardFocusEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowLostKeyboardFocusEventData
-> Identity WindowLostKeyboardFocusEventData
forall a. a -> Identity a
Identity WindowLostKeyboardFocusEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      WindowClosedEvent WindowClosedEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowClosedEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global WindowClosedEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider WindowClosedEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global WindowClosedEventData))
trWindowClosedRef SpiderHost
  Global (Maybe (RootTrigger Global WindowClosedEventData))
-> (Maybe (RootTrigger Global WindowClosedEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global WindowClosedEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global WindowClosedEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global WindowClosedEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global WindowClosedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global WindowClosedEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global WindowClosedEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global WindowClosedEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global WindowClosedEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global WindowClosedEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global WindowClosedEventData
tr RootTrigger Global WindowClosedEventData
-> Identity WindowClosedEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> WindowClosedEventData -> Identity WindowClosedEventData
forall a. a -> Identity a
Identity WindowClosedEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      KeyboardEvent KeyboardEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global KeyboardEventData))
-> SpiderHost Global (Maybe (RootTrigger Global KeyboardEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider KeyboardEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global KeyboardEventData))
trKeyboardRef SpiderHost Global (Maybe (RootTrigger Global KeyboardEventData))
-> (Maybe (RootTrigger Global KeyboardEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global KeyboardEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global KeyboardEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global KeyboardEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global KeyboardEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global KeyboardEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global KeyboardEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global KeyboardEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global KeyboardEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global KeyboardEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global KeyboardEventData
tr RootTrigger Global KeyboardEventData
-> Identity KeyboardEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> KeyboardEventData -> Identity KeyboardEventData
forall a. a -> Identity a
Identity KeyboardEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      TextEditingEvent TextEditingEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TextEditingEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global TextEditingEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider TextEditingEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TextEditingEventData))
trTextEditingRef SpiderHost Global (Maybe (RootTrigger Global TextEditingEventData))
-> (Maybe (RootTrigger Global TextEditingEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global TextEditingEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global TextEditingEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global TextEditingEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global TextEditingEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global TextEditingEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global TextEditingEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global TextEditingEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global TextEditingEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global TextEditingEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global TextEditingEventData
tr RootTrigger Global TextEditingEventData
-> Identity TextEditingEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> TextEditingEventData -> Identity TextEditingEventData
forall a. a -> Identity a
Identity TextEditingEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      TextInputEvent TextInputEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global TextInputEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global TextInputEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider TextInputEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global TextInputEventData))
trTextInputRef SpiderHost Global (Maybe (RootTrigger Global TextInputEventData))
-> (Maybe (RootTrigger Global TextInputEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global TextInputEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global TextInputEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global TextInputEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global TextInputEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global TextInputEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global TextInputEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global TextInputEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global TextInputEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global TextInputEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global TextInputEventData
tr RootTrigger Global TextInputEventData
-> Identity TextInputEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> TextInputEventData -> Identity TextInputEventData
forall a. a -> Identity a
Identity TextInputEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      EventPayload
KeymapChangedEvent -> (Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
-> SpiderHost Global (Maybe (RootTrigger Global ()))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ()))
Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
trKeymapChangedRef SpiderHost Global (Maybe (RootTrigger Global ()))
-> (Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ()) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global () -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global () -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ()) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global () -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ()
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ()
tr RootTrigger Global ()
-> Identity () -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> () -> Identity ()
forall a. a -> Identity a
Identity ()] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      MouseMotionEvent MouseMotionEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseMotionEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global MouseMotionEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider MouseMotionEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseMotionEventData))
trMouseMotionRef SpiderHost Global (Maybe (RootTrigger Global MouseMotionEventData))
-> (Maybe (RootTrigger Global MouseMotionEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global MouseMotionEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global MouseMotionEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global MouseMotionEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global MouseMotionEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global MouseMotionEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global MouseMotionEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global MouseMotionEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global MouseMotionEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global MouseMotionEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global MouseMotionEventData
tr RootTrigger Global MouseMotionEventData
-> Identity MouseMotionEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> MouseMotionEventData -> Identity MouseMotionEventData
forall a. a -> Identity a
Identity MouseMotionEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      MouseButtonEvent MouseButtonEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseButtonEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global MouseButtonEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider MouseButtonEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseButtonEventData))
trMouseButtonRef SpiderHost Global (Maybe (RootTrigger Global MouseButtonEventData))
-> (Maybe (RootTrigger Global MouseButtonEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global MouseButtonEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global MouseButtonEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global MouseButtonEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global MouseButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global MouseButtonEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global MouseButtonEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global MouseButtonEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global MouseButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global MouseButtonEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global MouseButtonEventData
tr RootTrigger Global MouseButtonEventData
-> Identity MouseButtonEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> MouseButtonEventData -> Identity MouseButtonEventData
forall a. a -> Identity a
Identity MouseButtonEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      MouseWheelEvent MouseWheelEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseWheelEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global MouseWheelEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider MouseWheelEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MouseWheelEventData))
trMouseWheelRef SpiderHost Global (Maybe (RootTrigger Global MouseWheelEventData))
-> (Maybe (RootTrigger Global MouseWheelEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global MouseWheelEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global MouseWheelEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global MouseWheelEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global MouseWheelEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global MouseWheelEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global MouseWheelEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global MouseWheelEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global MouseWheelEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global MouseWheelEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global MouseWheelEventData
tr RootTrigger Global MouseWheelEventData
-> Identity MouseWheelEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> MouseWheelEventData -> Identity MouseWheelEventData
forall a. a -> Identity a
Identity MouseWheelEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      JoyAxisEvent JoyAxisEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyAxisEventData))
-> SpiderHost Global (Maybe (RootTrigger Global JoyAxisEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider JoyAxisEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyAxisEventData))
trJoyAxisRef SpiderHost Global (Maybe (RootTrigger Global JoyAxisEventData))
-> (Maybe (RootTrigger Global JoyAxisEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global JoyAxisEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global JoyAxisEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global JoyAxisEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global JoyAxisEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global JoyAxisEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global JoyAxisEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global JoyAxisEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global JoyAxisEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global JoyAxisEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global JoyAxisEventData
tr RootTrigger Global JoyAxisEventData
-> Identity JoyAxisEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> JoyAxisEventData -> Identity JoyAxisEventData
forall a. a -> Identity a
Identity JoyAxisEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      JoyBallEvent JoyBallEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyBallEventData))
-> SpiderHost Global (Maybe (RootTrigger Global JoyBallEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider JoyBallEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyBallEventData))
trJoyBallRef SpiderHost Global (Maybe (RootTrigger Global JoyBallEventData))
-> (Maybe (RootTrigger Global JoyBallEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global JoyBallEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global JoyBallEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global JoyBallEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global JoyBallEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global JoyBallEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global JoyBallEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global JoyBallEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global JoyBallEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global JoyBallEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global JoyBallEventData
tr RootTrigger Global JoyBallEventData
-> Identity JoyBallEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> JoyBallEventData -> Identity JoyBallEventData
forall a. a -> Identity a
Identity JoyBallEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      JoyHatEvent JoyHatEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyHatEventData))
-> SpiderHost Global (Maybe (RootTrigger Global JoyHatEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider JoyHatEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyHatEventData))
trJoyHatRef SpiderHost Global (Maybe (RootTrigger Global JoyHatEventData))
-> (Maybe (RootTrigger Global JoyHatEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global JoyHatEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global JoyHatEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global JoyHatEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global JoyHatEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global JoyHatEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global JoyHatEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global JoyHatEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global JoyHatEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global JoyHatEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global JoyHatEventData
tr RootTrigger Global JoyHatEventData
-> Identity JoyHatEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> JoyHatEventData -> Identity JoyHatEventData
forall a. a -> Identity a
Identity JoyHatEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      JoyButtonEvent JoyButtonEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyButtonEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global JoyButtonEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider JoyButtonEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyButtonEventData))
trJoyButtonRef SpiderHost Global (Maybe (RootTrigger Global JoyButtonEventData))
-> (Maybe (RootTrigger Global JoyButtonEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global JoyButtonEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global JoyButtonEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global JoyButtonEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global JoyButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global JoyButtonEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global JoyButtonEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global JoyButtonEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global JoyButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global JoyButtonEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global JoyButtonEventData
tr RootTrigger Global JoyButtonEventData
-> Identity JoyButtonEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> JoyButtonEventData -> Identity JoyButtonEventData
forall a. a -> Identity a
Identity JoyButtonEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      JoyDeviceEvent JoyDeviceEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyDeviceEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global JoyDeviceEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider JoyDeviceEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global JoyDeviceEventData))
trJoyDeviceRef SpiderHost Global (Maybe (RootTrigger Global JoyDeviceEventData))
-> (Maybe (RootTrigger Global JoyDeviceEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global JoyDeviceEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global JoyDeviceEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global JoyDeviceEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global JoyDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global JoyDeviceEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global JoyDeviceEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global JoyDeviceEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global JoyDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global JoyDeviceEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global JoyDeviceEventData
tr RootTrigger Global JoyDeviceEventData
-> Identity JoyDeviceEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> JoyDeviceEventData -> Identity JoyDeviceEventData
forall a. a -> Identity a
Identity JoyDeviceEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      ControllerAxisEvent ControllerAxisEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerAxisEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global ControllerAxisEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ControllerAxisEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerAxisEventData))
trControllerAxisRef SpiderHost
  Global (Maybe (RootTrigger Global ControllerAxisEventData))
-> (Maybe (RootTrigger Global ControllerAxisEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ControllerAxisEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global ControllerAxisEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ControllerAxisEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global ControllerAxisEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global ControllerAxisEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ControllerAxisEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global ControllerAxisEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global ControllerAxisEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ControllerAxisEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ControllerAxisEventData
tr RootTrigger Global ControllerAxisEventData
-> Identity ControllerAxisEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> ControllerAxisEventData -> Identity ControllerAxisEventData
forall a. a -> Identity a
Identity ControllerAxisEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      ControllerButtonEvent ControllerButtonEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerButtonEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global ControllerButtonEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ControllerButtonEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerButtonEventData))
trControllerButtonRef SpiderHost
  Global (Maybe (RootTrigger Global ControllerButtonEventData))
-> (Maybe (RootTrigger Global ControllerButtonEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ControllerButtonEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global ControllerButtonEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ControllerButtonEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global ControllerButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global ControllerButtonEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ControllerButtonEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global ControllerButtonEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global ControllerButtonEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ControllerButtonEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ControllerButtonEventData
tr RootTrigger Global ControllerButtonEventData
-> Identity ControllerButtonEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> ControllerButtonEventData -> Identity ControllerButtonEventData
forall a. a -> Identity a
Identity ControllerButtonEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      ControllerDeviceEvent ControllerDeviceEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerDeviceEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global ControllerDeviceEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ControllerDeviceEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global ControllerDeviceEventData))
trControllerDeviceRef SpiderHost
  Global (Maybe (RootTrigger Global ControllerDeviceEventData))
-> (Maybe (RootTrigger Global ControllerDeviceEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ControllerDeviceEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global ControllerDeviceEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ControllerDeviceEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global ControllerDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global ControllerDeviceEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ControllerDeviceEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global ControllerDeviceEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global ControllerDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ControllerDeviceEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ControllerDeviceEventData
tr RootTrigger Global ControllerDeviceEventData
-> Identity ControllerDeviceEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> ControllerDeviceEventData -> Identity ControllerDeviceEventData
forall a. a -> Identity a
Identity ControllerDeviceEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      AudioDeviceEvent AudioDeviceEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global AudioDeviceEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global AudioDeviceEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider AudioDeviceEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global AudioDeviceEventData))
trAudioDeviceRef SpiderHost Global (Maybe (RootTrigger Global AudioDeviceEventData))
-> (Maybe (RootTrigger Global AudioDeviceEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global AudioDeviceEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global AudioDeviceEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global AudioDeviceEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global AudioDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global AudioDeviceEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global AudioDeviceEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global AudioDeviceEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global AudioDeviceEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global AudioDeviceEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global AudioDeviceEventData
tr RootTrigger Global AudioDeviceEventData
-> Identity AudioDeviceEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> AudioDeviceEventData -> Identity AudioDeviceEventData
forall a. a -> Identity a
Identity AudioDeviceEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      EventPayload
QuitEvent -> (Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
-> SpiderHost Global (Maybe (RootTrigger Global ()))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ()))
Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
trQuitRef SpiderHost Global (Maybe (RootTrigger Global ()))
-> (Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ()) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global () -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global () -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ()) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global () -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ()
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ()
tr RootTrigger Global ()
-> Identity () -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> () -> Identity ()
forall a. a -> Identity a
Identity ()] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      UserEvent UserEventData
dat ->
        -- We've found some triggered reflex events, read them and fire them.
        if UserEventData -> Int32
userEventCode UserEventData
dat Int32 -> Int32 -> Bool
forall a. Eq a => a -> a -> Bool
== Int32
reservedTriggerCode
        then do
          [DSum (EventTriggerRef Spider) TriggerInvocation]
triggers <- IO [DSum (EventTriggerRef Spider) TriggerInvocation]
-> SpiderHost
     Global [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [DSum (EventTriggerRef Spider) TriggerInvocation]
 -> SpiderHost
      Global [DSum (EventTriggerRef Spider) TriggerInvocation])
-> IO [DSum (EventTriggerRef Spider) TriggerInvocation]
-> SpiderHost
     Global [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a b. (a -> b) -> a -> b
$ STM [DSum (EventTriggerRef Spider) TriggerInvocation]
-> IO [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. STM a -> IO a
atomically (STM [DSum (EventTriggerRef Spider) TriggerInvocation]
 -> IO [DSum (EventTriggerRef Spider) TriggerInvocation])
-> STM [DSum (EventTriggerRef Spider) TriggerInvocation]
-> IO [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a b. (a -> b) -> a -> b
$ do
            [DSum (EventTriggerRef Spider) TriggerInvocation]
trigs <- TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
-> STM [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. TVar a -> STM a
readTVar TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
triggersVar
            TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
-> [DSum (EventTriggerRef Spider) TriggerInvocation] -> STM ()
forall a. TVar a -> a -> STM ()
writeTVar TVar [DSum (EventTriggerRef Spider) TriggerInvocation]
triggersVar []
            [DSum (EventTriggerRef Spider) TriggerInvocation]
-> STM [DSum (EventTriggerRef Spider) TriggerInvocation]
forall a. a -> STM a
forall (m :: * -> *) a. Monad m => a -> m a
return [DSum (EventTriggerRef Spider) TriggerInvocation]
trigs
          [DSum (EventTriggerRef Spider) TriggerInvocation]
-> (DSum (EventTriggerRef Spider) TriggerInvocation
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [DSum (EventTriggerRef Spider) TriggerInvocation]
triggers ((DSum (EventTriggerRef Spider) TriggerInvocation
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> (DSum (EventTriggerRef Spider) TriggerInvocation
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \(EventTriggerRef IORef (Maybe (EventTrigger Spider a))
ref :=> TriggerInvocation a
a IO ()
_cb) ->
            (Ref (SpiderHost Global) (Maybe (RootTrigger Global a))
-> SpiderHost Global (Maybe (RootTrigger Global a))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider a))
Ref (SpiderHost Global) (Maybe (RootTrigger Global a))
ref SpiderHost Global (Maybe (RootTrigger Global a))
-> (Maybe (RootTrigger Global a) -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global a) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global a -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global a) -> SpiderHost Global ())
-> (RootTrigger Global a -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global a -> SpiderHost Global [()])
-> Maybe (RootTrigger Global a) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global a -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global a -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global a
tr -> [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global a
tr RootTrigger Global a
-> Identity a -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> a -> Identity a
forall a. a -> Identity a
Identity a
a] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
          -- Run the callbacks of those triggered events.
          [DSum (EventTriggerRef Spider) TriggerInvocation]
-> (DSum (EventTriggerRef Spider) TriggerInvocation
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [DSum (EventTriggerRef Spider) TriggerInvocation]
triggers ((DSum (EventTriggerRef Spider) TriggerInvocation
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> (DSum (EventTriggerRef Spider) TriggerInvocation
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \(EventTriggerRef Spider a
_ :=> TriggerInvocation a
_a IO ()
cb) -> IO () -> SpiderHost Global ()
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
cb
        else (Ref (SpiderHost Global) (Maybe (RootTrigger Global UserEventData))
-> SpiderHost Global (Maybe (RootTrigger Global UserEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider UserEventData))
Ref (SpiderHost Global) (Maybe (RootTrigger Global UserEventData))
trUserRef SpiderHost Global (Maybe (RootTrigger Global UserEventData))
-> (Maybe (RootTrigger Global UserEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global UserEventData) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global UserEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global UserEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global UserEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global UserEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global UserEventData) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global UserEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global UserEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global UserEventData
tr -> [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global UserEventData
tr RootTrigger Global UserEventData
-> Identity UserEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> UserEventData -> Identity UserEventData
forall a. a -> Identity a
Identity UserEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      SysWMEvent SysWMEventData
dat -> (Ref (SpiderHost Global) (Maybe (RootTrigger Global SysWMEventData))
-> SpiderHost Global (Maybe (RootTrigger Global SysWMEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider SysWMEventData))
Ref (SpiderHost Global) (Maybe (RootTrigger Global SysWMEventData))
trSysWMRef SpiderHost Global (Maybe (RootTrigger Global SysWMEventData))
-> (Maybe (RootTrigger Global SysWMEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global SysWMEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global SysWMEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global SysWMEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global SysWMEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global SysWMEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global SysWMEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global SysWMEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global SysWMEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global SysWMEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global SysWMEventData
tr RootTrigger Global SysWMEventData
-> Identity SysWMEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> SysWMEventData -> Identity SysWMEventData
forall a. a -> Identity a
Identity SysWMEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      TouchFingerEvent TouchFingerEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TouchFingerEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global TouchFingerEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider TouchFingerEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TouchFingerEventData))
trTouchFingerRef SpiderHost Global (Maybe (RootTrigger Global TouchFingerEventData))
-> (Maybe (RootTrigger Global TouchFingerEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global TouchFingerEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global TouchFingerEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global TouchFingerEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global TouchFingerEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global TouchFingerEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global TouchFingerEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global TouchFingerEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global TouchFingerEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global TouchFingerEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global TouchFingerEventData
tr RootTrigger Global TouchFingerEventData
-> Identity TouchFingerEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> TouchFingerEventData -> Identity TouchFingerEventData
forall a. a -> Identity a
Identity TouchFingerEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      TouchFingerMotionEvent TouchFingerMotionEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TouchFingerMotionEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global TouchFingerMotionEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider TouchFingerMotionEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global TouchFingerMotionEventData))
trTouchFingerMotionRef SpiderHost
  Global (Maybe (RootTrigger Global TouchFingerMotionEventData))
-> (Maybe (RootTrigger Global TouchFingerMotionEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global TouchFingerMotionEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global TouchFingerMotionEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global TouchFingerMotionEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global TouchFingerMotionEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global TouchFingerMotionEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global TouchFingerMotionEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global TouchFingerMotionEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global TouchFingerMotionEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global TouchFingerMotionEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global TouchFingerMotionEventData
tr RootTrigger Global TouchFingerMotionEventData
-> Identity TouchFingerMotionEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> TouchFingerMotionEventData -> Identity TouchFingerMotionEventData
forall a. a -> Identity a
Identity TouchFingerMotionEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      MultiGestureEvent MultiGestureEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MultiGestureEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global MultiGestureEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider MultiGestureEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global MultiGestureEventData))
trMultiGestureRef SpiderHost
  Global (Maybe (RootTrigger Global MultiGestureEventData))
-> (Maybe (RootTrigger Global MultiGestureEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global MultiGestureEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global MultiGestureEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global MultiGestureEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global MultiGestureEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global MultiGestureEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global MultiGestureEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global MultiGestureEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global MultiGestureEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global MultiGestureEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global MultiGestureEventData
tr RootTrigger Global MultiGestureEventData
-> Identity MultiGestureEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> MultiGestureEventData -> Identity MultiGestureEventData
forall a. a -> Identity a
Identity MultiGestureEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      DollarGestureEvent DollarGestureEventData
dat -> (Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global DollarGestureEventData))
-> SpiderHost
     Global (Maybe (RootTrigger Global DollarGestureEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider DollarGestureEventData))
Ref
  (SpiderHost Global)
  (Maybe (RootTrigger Global DollarGestureEventData))
trDollarGestureRef SpiderHost
  Global (Maybe (RootTrigger Global DollarGestureEventData))
-> (Maybe (RootTrigger Global DollarGestureEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global DollarGestureEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global DollarGestureEventData
     -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global DollarGestureEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global DollarGestureEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global DollarGestureEventData
 -> SpiderHost Global [()])
-> Maybe (RootTrigger Global DollarGestureEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global DollarGestureEventData
  -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global DollarGestureEventData
    -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global DollarGestureEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global DollarGestureEventData
tr RootTrigger Global DollarGestureEventData
-> Identity DollarGestureEventData
-> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> DollarGestureEventData -> Identity DollarGestureEventData
forall a. a -> Identity a
Identity DollarGestureEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      DropEvent DropEventData
dat -> (Ref (SpiderHost Global) (Maybe (RootTrigger Global DropEventData))
-> SpiderHost Global (Maybe (RootTrigger Global DropEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider DropEventData))
Ref (SpiderHost Global) (Maybe (RootTrigger Global DropEventData))
trDropRef SpiderHost Global (Maybe (RootTrigger Global DropEventData))
-> (Maybe (RootTrigger Global DropEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global DropEventData) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global DropEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global DropEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global DropEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global DropEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global DropEventData) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global DropEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global DropEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global DropEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global DropEventData
tr RootTrigger Global DropEventData
-> Identity DropEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> DropEventData -> Identity DropEventData
forall a. a -> Identity a
Identity DropEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      EventPayload
ClipboardUpdateEvent -> (Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
-> SpiderHost Global (Maybe (RootTrigger Global ()))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider ()))
Ref (SpiderHost Global) (Maybe (RootTrigger Global ()))
trClipboardUpdateRef SpiderHost Global (Maybe (RootTrigger Global ()))
-> (Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global ()) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global () -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global ()) -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global () -> SpiderHost Global [()])
-> Maybe (RootTrigger Global ()) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global () -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global () -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global ()
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global ()
tr RootTrigger Global ()
-> Identity () -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> () -> Identity ()
forall a. a -> Identity a
Identity ()] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      UnknownEvent UnknownEventData
dat -> (Ref
  (SpiderHost Global) (Maybe (RootTrigger Global UnknownEventData))
-> SpiderHost Global (Maybe (RootTrigger Global UnknownEventData))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider UnknownEventData))
Ref
  (SpiderHost Global) (Maybe (RootTrigger Global UnknownEventData))
trUnknownRef SpiderHost Global (Maybe (RootTrigger Global UnknownEventData))
-> (Maybe (RootTrigger Global UnknownEventData)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global UnknownEventData)
  -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global UnknownEventData -> SpiderHost Global [()])
    -> Maybe (RootTrigger Global UnknownEventData)
    -> SpiderHost Global ())
-> (RootTrigger Global UnknownEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global UnknownEventData -> SpiderHost Global [()])
-> Maybe (RootTrigger Global UnknownEventData)
-> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global UnknownEventData -> SpiderHost Global [()])
 -> SpiderHost Global ())
-> (RootTrigger Global UnknownEventData -> SpiderHost Global [()])
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global UnknownEventData
tr ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global UnknownEventData
tr RootTrigger Global UnknownEventData
-> Identity UnknownEventData -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> UnknownEventData -> Identity UnknownEventData
forall a. a -> Identity a
Identity UnknownEventData
dat] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

    -- Fire an event for the wrapped payload as well.
    (Ref (SpiderHost Global) (Maybe (RootTrigger Global EventPayload))
-> SpiderHost Global (Maybe (RootTrigger Global EventPayload))
forall a. Ref (SpiderHost Global) a -> SpiderHost Global a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef IORef (Maybe (EventTrigger Spider EventPayload))
Ref (SpiderHost Global) (Maybe (RootTrigger Global EventPayload))
trAnySDLRef SpiderHost Global (Maybe (RootTrigger Global EventPayload))
-> (Maybe (RootTrigger Global EventPayload)
    -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b.
SpiderHost Global a
-> (a -> SpiderHost Global b) -> SpiderHost Global b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=) ((Maybe (RootTrigger Global EventPayload) -> SpiderHost Global ())
 -> SpiderHost Global ())
-> ((RootTrigger Global EventPayload -> SpiderHost Global ())
    -> Maybe (RootTrigger Global EventPayload) -> SpiderHost Global ())
-> (RootTrigger Global EventPayload -> SpiderHost Global ())
-> SpiderHost Global ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RootTrigger Global EventPayload -> SpiderHost Global ())
-> Maybe (RootTrigger Global EventPayload) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((RootTrigger Global EventPayload -> SpiderHost Global ())
 -> SpiderHost Global ())
-> (RootTrigger Global EventPayload -> SpiderHost Global ())
-> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \RootTrigger Global EventPayload
tr ->
      [EventPayload]
-> (EventPayload -> SpiderHost Global [()]) -> SpiderHost Global ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [EventPayload]
payloads ((EventPayload -> SpiderHost Global [()]) -> SpiderHost Global ())
-> (EventPayload -> SpiderHost Global [()]) -> SpiderHost Global ()
forall a b. (a -> b) -> a -> b
$ \EventPayload
payload ->
        [DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a.
[DSum (EventTrigger Spider) Identity]
-> ReadPhase (SpiderHost Global) a -> SpiderHost Global [a]
fire [RootTrigger Global EventPayload
tr RootTrigger Global EventPayload
-> Identity EventPayload -> DSum (RootTrigger Global) Identity
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> EventPayload -> Identity EventPayload
forall a. a -> Identity a
Identity EventPayload
payload] (ReadPhase (SpiderHost Global) () -> SpiderHost Global [()])
-> ReadPhase (SpiderHost Global) () -> SpiderHost Global [()]
forall a b. (a -> b) -> a -> b
$ () -> ReadPhase Global ()
forall a. a -> ReadPhase Global a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

    Bool
shouldQuit <- IO Bool -> SpiderHost Global Bool
forall a. IO a -> SpiderHost Global a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> SpiderHost Global Bool)
-> IO Bool -> SpiderHost Global Bool
forall a b. (a -> b) -> a -> b
$ TVar Bool -> IO Bool
forall a. TVar a -> IO a
readTVarIO TVar Bool
mainQuitVar
    Bool -> SpiderHost Global () -> SpiderHost Global ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
shouldQuit SpiderHost Global ()
loop


------------------------------------------------------------------------------
-- | Like 'putStrLn', but for 'Event's.
putDebugLnE
  :: (PerformEvent t m, Reflex t, MonadIO (Performable m))
  => Event t a
  -- ^ The 'Event' to trigger the print.
  -> (a -> String)
  -- ^ A function to show the 'Event's value.
  -> m ()
putDebugLnE :: forall t (m :: * -> *) a.
(PerformEvent t m, Reflex t, MonadIO (Performable m)) =>
Event t a -> (a -> [Char]) -> m ()
putDebugLnE Event t a
ev a -> [Char]
showf = Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_ (Event t (Performable m ()) -> m ())
-> Event t (Performable m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ IO () -> Performable m ()
forall a. IO a -> Performable m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Performable m ())
-> (a -> IO ()) -> a -> Performable m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> IO ()
putStrLn ([Char] -> IO ()) -> (a -> [Char]) -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [Char]
showf (a -> Performable m ()) -> Event t a -> Event t (Performable m ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t a
ev


------------------------------------------------------------------------------
-- | Run a placeholder network until the given 'Event' fires, then replace it
-- with the network of the 'Event's value. This process is repeated each time
-- the 'Event' fires a new network. Returns a 'Dynamic' of the inner network's
-- result that updates any time the 'Event' fires.
holdView :: ReflexSDL2 t m => m a -> Event t (m a) -> m (Dynamic t a)
holdView :: forall t (m :: * -> *) a.
ReflexSDL2 t m =>
m a -> Event t (m a) -> m (Dynamic t a)
holdView m a
child0 Event t (m a)
newChild = do
  (a
result0, Event t a
newResult) <- m a -> Event t (m a) -> m (a, Event t a)
forall a b. m a -> Event t (m b) -> m (a, Event t b)
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace m a
child0 Event t (m a)
newChild
  a -> Event t a -> m (Dynamic t a)
forall a. a -> Event t a -> m (Dynamic t a)
forall {k} (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Dynamic t a)
holdDyn a
result0 Event t a
newResult


------------------------------------------------------------------------------
-- | Run a 'Dynamic'ally changing network, replacing the current one with the
-- new one every time the 'Dynamic' updates. Returns an 'Event' of the inner
-- network's result value that fires every time the 'Dynamic' changes.
dynView :: ReflexSDL2 t m => Dynamic t (m a) -> m (Event t a)
dynView :: forall t (m :: * -> *) a.
ReflexSDL2 t m =>
Dynamic t (m a) -> m (Event t a)
dynView Dynamic t (m a)
child = do
  Event t ()
evPB <- m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
  let newChild :: Event t (m a)
newChild = [Event t (m a)] -> Event t (m a)
forall {k} (t :: k) a. Reflex t => [Event t a] -> Event t a
leftmost [Dynamic t (m a) -> Event t (m a)
forall a. Dynamic t a -> Event t a
forall {k} (t :: k) a. Reflex t => Dynamic t a -> Event t a
updated Dynamic t (m a)
child, Behavior t (m a) -> Event t () -> Event t (m a)
forall {k} (t :: k) b a.
Reflex t =>
Behavior t b -> Event t a -> Event t b
tagCheap (Dynamic t (m a) -> Behavior t (m a)
forall a. Dynamic t a -> Behavior t a
forall {k} (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current Dynamic t (m a)
child) Event t ()
evPB]
  ((), Event t a) -> Event t a
forall a b. (a, b) -> b
snd (((), Event t a) -> Event t a)
-> m ((), Event t a) -> m (Event t a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m () -> Event t (m a) -> m ((), Event t a)
forall a b. m a -> Event t (m b) -> m (a, Event t b)
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace (() -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) Event t (m a)
newChild