on ae@dev-script help sign in
77 lines 2.6 kB history raw
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE DefaultSignatures #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE UndecidableInstances #-}
8#ifdef USE_REFLEX_OPTIMIZER
9{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
10#endif
11module Reflex.NotReady.Class
12 ( NotReady(..)
13 ) where
15import Control.Monad.Reader (ReaderT)
16import Control.Monad.Trans
17import Control.Monad.Trans.Writer (WriterT)
19import Reflex.BehaviorWriter.Base (BehaviorWriterT)
20import Reflex.Class
21import Reflex.DynamicWriter.Base (DynamicWriterT)
22import Reflex.EventWriter.Base (EventWriterT)
23import Reflex.Host.Class
24import Reflex.PerformEvent.Base (PerformEventT (..))
25import Reflex.PostBuild.Base (PostBuildT)
26import Reflex.Query.Base (QueryT)
27import Reflex.Requester.Base (RequesterT)
28import Reflex.TriggerEvent.Base (TriggerEventT)
30class Monad m => NotReady t m | m -> t where
31 notReadyUntil :: Event t a -> m ()
32 default notReadyUntil :: (MonadTrans f, m ~ f m', NotReady t m') => Event t a -> m ()
33 notReadyUntil = lift . notReadyUntil
35 notReady :: m ()
36 default notReady :: (MonadTrans f, m ~ f m', NotReady t m') => m ()
37 notReady = lift notReady
39instance NotReady t m => NotReady t (ReaderT r m) where
40 notReadyUntil = lift . notReadyUntil
41 notReady = lift notReady
43instance (NotReady t m, Monoid w) => NotReady t (WriterT w m) where
44 notReadyUntil = lift . notReadyUntil
45 notReady = lift notReady
47instance NotReady t m => NotReady t (PostBuildT t m) where
48 notReadyUntil = lift . notReadyUntil
49 notReady = lift notReady
51instance NotReady t m => NotReady t (EventWriterT t w m) where
52 notReadyUntil = lift . notReadyUntil
53 notReady = lift notReady
55instance NotReady t m => NotReady t (DynamicWriterT t w m) where
56 notReadyUntil = lift . notReadyUntil
57 notReady = lift notReady
59instance NotReady t m => NotReady t (BehaviorWriterT t w m) where
60 notReadyUntil = lift . notReadyUntil
61 notReady = lift notReady
63instance NotReady t m => NotReady t (QueryT t q m) where
64 notReadyUntil = lift . notReadyUntil
65 notReady = lift notReady
67instance (ReflexHost t, NotReady t (HostFrame t)) => NotReady t (PerformEventT t m) where
68 notReadyUntil = PerformEventT . notReadyUntil
69 notReady = PerformEventT notReady
71instance NotReady t m => NotReady t (RequesterT t request response m) where
72 notReadyUntil = lift . notReadyUntil
73 notReady = lift notReady
75instance NotReady t m => NotReady t (TriggerEventT t m) where
76 notReadyUntil = lift . notReadyUntil
77 notReady = lift notReady