@@ -1,21 +1,24 @@
1{-# LANGUAGE ExistentialQuantification, GADTs, ScopedTypeVariables, TypeFamilies, FlexibleInstances, MultiParamTypeClasses, GeneralizedNewtypeDeriving, RankNTypes, BangPatterns, UndecidableInstances, EmptyDataDecls, RecursiveDo, RoleAnnotations, FunctionalDependencies, FlexibleContexts #-}
1{-# LANGUAGE ExistentialQuantification, GADTs, ScopedTypeVariables, TypeFamilies, FlexibleInstances, MultiParamTypeClasses, GeneralizedNewtypeDeriving, RankNTypes, BangPatterns, UndecidableInstances, EmptyDataDecls, RecursiveDo, RoleAnnotations, FunctionalDependencies, FlexibleContexts #-}
2module Reflex.Host.Class where
2module Reflex.Host.Class where
4−import Prelude hiding (mapM, mapM_, sequence, sequence_, foldl)
6import Reflex.Class
4import Reflex.Class
6+import Control.Applicative
8import Control.Monad.Fix
7import Control.Monad.Fix
9import Control.Monad.Trans
8import Control.Monad.Trans
10−import Control.Monad.Reader (ReaderT())
9+import Control.Monad.Trans.Reader (ReaderT())
11−import Control.Monad.Writer (WriterT())
10+import Control.Monad.Trans.Writer (WriterT())
12−import Control.Monad.Cont (ContT())
11+import Control.Monad.Trans.Cont (ContT())
13−import Control.Monad.Except (ExceptT())
12+import Control.Monad.Trans.Except (ExceptT())
14−import Control.Monad.RWS (RWST())
13+import Control.Monad.Trans.RWS (RWST())
15−import Control.Monad.State (StateT())
14+import Control.Monad.Trans.State (StateT())
16import Data.Dependent.Sum (DSum)
15import Data.Dependent.Sum (DSum)
17import Control.Monad.Ref
17import Control.Monad.Ref
19+-- Note: this import must come last to silence warnings from AMP
20+import Prelude hiding (mapM, mapM_, sequence, sequence_, foldl)
19-- | Framework implementation support class for the reflex implementation represented by @t@.
22-- | Framework implementation support class for the reflex implementation represented by @t@.
20class (Reflex t, MonadReflexCreateTrigger t (HostFrame t), MonadSample t (HostFrame t), MonadHold t (HostFrame t), MonadFix (HostFrame t)) => ReflexHost t where
23class (Reflex t, MonadReflexCreateTrigger t (HostFrame t), MonadSample t (HostFrame t), MonadHold t (HostFrame t), MonadFix (HostFrame t)) => ReflexHost t where
21 type EventTrigger t :: * -> *
24 type EventTrigger t :: * -> *
@@ -23,7 +26,7 @@ class (Reflex t, MonadReflexCreateTrigger t (HostFrame t), MonadSample t (HostFr
23 type HostFrame t :: * -> *
26 type HostFrame t :: * -> *
25-- | Monad that allows to read events' values.
28-- | 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
27 -- | Read the value of an 'Event' from an 'EventHandle' (created by calling 'subscribeEvent').
30 -- | Read the value of an 'Event' from an 'EventHandle' (created by calling 'subscribeEvent').
29 -- After event propagation is done, all events can be in two states: either they are firing with some value or they are not firing.
32 -- 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
34 readEvent :: EventHandle t a -> m (Maybe (m a))
37 readEvent :: EventHandle t a -> m (Maybe (m a))
36-- | A monad where new events feed from external sources can be created.
39-- | 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
38 -- | Creates a root 'Event' (one that is not based on any other event).
41 -- | Creates a root 'Event' (one that is not based on any other event).
40 -- When a subscriber first subscribes to an event (building another event
43 -- When a subscriber first subscribes to an event (building another event
@@ -48,7 +51,7 @@ class Monad m => MonadReflexCreateTrigger t m | m -> t where
48 -- 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.
51 -- 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.
49 newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> m (Event t a)
52 newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> m (Event t a)
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
52 -- | Propagate some events firings and read the values of events afterwards.
55 -- | Propagate some events firings and read the values of events afterwards.
54 -- This function will create a new frame to fire the given events. It will then update all
57 -- This function will create a new frame to fire the given events. It will then update all