on 8217c81 help sign in
42 lines 1.6 kB history raw
1-- | This module defines 'PostBuild', which indicates that an action will be
2-- notified when it, and any action it's a part of, has finished executing.
3{-# LANGUAGE CPP #-}
4{-# LANGUAGE DataKinds #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE FunctionalDependencies #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE TypeFamilies #-}
10{-# LANGUAGE TypeOperators #-}
11{-# LANGUAGE UndecidableInstances #-}
12#ifdef USE_REFLEX_OPTIMIZER
13{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
14#endif
15module Reflex.PostBuild.Class
16 ( PostBuild (..)
17 ) where
19import Reflex.Class
21import Control.Monad.Reader
22import Control.Monad.State
23import qualified Control.Monad.State.Strict as Strict
25-- | 'PostBuild' represents an action that is notified via an 'Event' when it
26-- has finished executing. Note that the specific definition of "finished" is
27-- determined by the instance of 'PostBuild', but the intent is to allow
28-- 'Behavior's and 'Dynamic's to be safely sampled, regardless of where they
29-- were created, when the post-build 'Event' fires. The post-build 'Event' will
30-- fire exactly once for an given action.
31class (Reflex t, Monad m) => PostBuild t m | m -> t where
32 -- | Retrieve the post-build 'Event' for this action.
33 getPostBuild :: m (Event t ())
35instance PostBuild t m => PostBuild t (ReaderT r m) where
36 getPostBuild = lift getPostBuild
38instance PostBuild t m => PostBuild t (StateT s m) where
39 getPostBuild = lift getPostBuild
41instance PostBuild t m => PostBuild t (Strict.StateT s m) where
42 getPostBuild = lift getPostBuild