@@ -1,21 +1,24 @@
11{-# LANGUAGE ExistentialQuantification, GADTs, ScopedTypeVariables, TypeFamilies, FlexibleInstances, MultiParamTypeClasses, GeneralizedNewtypeDeriving, RankNTypes, BangPatterns, UndecidableInstances, EmptyDataDecls, RecursiveDo, RoleAnnotations, FunctionalDependencies, FlexibleContexts #-}
22module Reflex.Host.Class where
33
4−import Prelude hiding (mapM, mapM_, sequence, sequence_, foldl)
5−
64import Reflex.Class
75
6+import Control.Applicative
87import Control.Monad.Fix
98import Control.Monad.Trans
10−import Control.Monad.Reader (ReaderT())
11−import Control.Monad.Writer (WriterT())
12−import Control.Monad.Cont (ContT())
13−import Control.Monad.Except (ExceptT())
14−import Control.Monad.RWS (RWST())
15−import Control.Monad.State (StateT())
9+import Control.Monad.Trans.Reader (ReaderT())
10+import Control.Monad.Trans.Writer (WriterT())
11+import Control.Monad.Trans.Cont (ContT())
12+import Control.Monad.Trans.Except (ExceptT())
13+import Control.Monad.Trans.RWS (RWST())
14+import Control.Monad.Trans.State (StateT())
1615import Data.Dependent.Sum (DSum)
16+import Data.Monoid
1717import Control.Monad.Ref
1818
19+-- Note: this import must come last to silence warnings from AMP
20+import Prelude hiding (mapM, mapM_, sequence, sequence_, foldl)
21+
1922-- | Framework implementation support class for the reflex implementation represented by @t@.
2023class (Reflex t, MonadReflexCreateTrigger t (HostFrame t), MonadSample t (HostFrame t), MonadHold t (HostFrame t), MonadFix (HostFrame t)) => ReflexHost t where
2124 type EventTrigger t :: * -> *
@@ -23,7 +26,7 @@ class (Reflex t, MonadReflexCreateTrigger t (HostFrame t), MonadSample t (HostFr
2326 type HostFrame t :: * -> *
2427
2528-- | Monad that allows to read events' values.
26−class (ReflexHost t, Monad m) => MonadReadEvent t m | m -> t where
29+class (ReflexHost t, Applicative m, Monad m) => MonadReadEvent t m | m -> t where
2730 -- | Read the value of an 'Event' from an 'EventHandle' (created by calling 'subscribeEvent').
2831 --
2932 -- After event propagation is done, all events can be in two states: either they are firing with some value or they are not firing.
@@ -34,7 +37,7 @@ class (ReflexHost t, Monad m) => MonadReadEvent t m | m -> t where
3437 readEvent :: EventHandle t a -> m (Maybe (m a))
3538
3639-- | A monad where new events feed from external sources can be created.
37−class Monad m => MonadReflexCreateTrigger t m | m -> t where
40+class (Applicative m, Monad m) => MonadReflexCreateTrigger t m | m -> t where
3841 -- | Creates a root 'Event' (one that is not based on any other event).
3942 --
4043 -- When a subscriber first subscribes to an event (building another event
@@ -48,7 +51,7 @@ class Monad m => MonadReflexCreateTrigger t m | m -> t where
4851 -- Note: An event may be set up multiple times. So after the teardown action is executed, the event may still be set up again in the future.
4952 newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> m (Event t a)
5053
51−class (Monad m, ReflexHost t, MonadReflexCreateTrigger t m) => MonadReflexHost t m | m -> t where
54+class (ReflexHost t, MonadReflexCreateTrigger t m) => MonadReflexHost t m | m -> t where
5255 -- | Propagate some events firings and read the values of events afterwards.
5356 --
5457 -- This function will create a new frame to fire the given events. It will then update all