@@ -0,0 +1,67 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE DefaultSignatures #-}
3+{-# LANGUAGE MultiParamTypeClasses #-}
4+{-# LANGUAGE FunctionalDependencies #-}
5+{-# LANGUAGE TypeFamilies #-}
6+{-# LANGUAGE FlexibleInstances #-}
7+{-# LANGUAGE UndecidableInstances #-}
8+#ifdef USE_REFLEX_OPTIMIZER
9+{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
10+#endif
11+module Reflex.NotReady.Class
12+ ( NotReady(..)
13+ ) where
14+
15+import Control.Monad.Trans
16+import Control.Monad.Reader (ReaderT)
17+
18+import Reflex.Class
19+import Reflex.Host.Class
20+import Reflex.PostBuild.Base (PostBuildT)
21+import Reflex.EventWriter (EventWriterT)
22+import Reflex.DynamicWriter (DynamicWriterT)
23+import Reflex.Query.Base (QueryT)
24+import Reflex.Requester.Base (RequesterT)
25+import Reflex.PerformEvent.Base (PerformEventT(..))
26+import Reflex.TriggerEvent.Base (TriggerEventT)
27+
28+class Monad m => NotReady t m | m -> t where
29+ notReadyUntil :: Event t a -> m ()
30+ default notReadyUntil :: (MonadTrans f, m ~ f m', NotReady t m') => Event t a -> m ()
31+ notReadyUntil = lift . notReadyUntil
32+
33+ notReady :: m ()
34+ default notReady :: (MonadTrans f, m ~ f m', NotReady t m') => m ()
35+ notReady = lift notReady
36+
37+instance NotReady t m => NotReady t (ReaderT r m) where
38+ notReadyUntil = lift . notReadyUntil
39+ notReady = lift notReady
40+
41+instance NotReady t m => NotReady t (PostBuildT t m) where
42+ notReadyUntil = lift . notReadyUntil
43+ notReady = lift notReady
44+
45+instance NotReady t m => NotReady t (EventWriterT t w m) where
46+ notReadyUntil = lift . notReadyUntil
47+ notReady = lift notReady
48+
49+instance NotReady t m => NotReady t (DynamicWriterT t w m) where
50+ notReadyUntil = lift . notReadyUntil
51+ notReady = lift notReady
52+
53+instance NotReady t m => NotReady t (QueryT t q m) where
54+ notReadyUntil = lift . notReadyUntil
55+ notReady = lift notReady
56+
57+instance (ReflexHost t, NotReady t (HostFrame t)) => NotReady t (PerformEventT t m) where
58+ notReadyUntil = PerformEventT . notReadyUntil
59+ notReady = PerformEventT notReady
60+
61+instance NotReady t m => NotReady t (RequesterT t request response m) where
62+ notReadyUntil = lift . notReadyUntil
63+ notReady = lift notReady
64+
65+instance NotReady t m => NotReady t (TriggerEventT t m) where
66+ notReadyUntil = lift . notReadyUntil
67+ notReady = lift notReady