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