on ae@dev-script help sign in
41 lines 1.5 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 ScopedTypeVariables #-}
8{-# LANGUAGE TypeFamilies #-}
9{-# LANGUAGE TypeOperators #-}
10{-# LANGUAGE UndecidableInstances #-}
11#ifdef USE_REFLEX_OPTIMIZER
12{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
13#endif
14module Reflex.PostBuild.Class
15 ( PostBuild (..)
16 ) where
18import Reflex.Class
20import Control.Monad.Reader
21import Control.Monad.State
22import qualified Control.Monad.State.Strict as Strict
24-- | 'PostBuild' represents an action that is notified via an 'Event' when it
25-- has finished executing. Note that the specific definition of "finished" is
26-- determined by the instance of 'PostBuild', but the intent is to allow
27-- 'Behavior's and 'Dynamic's to be safely sampled, regardless of where they
28-- were created, when the post-build 'Event' fires. The post-build 'Event' will
29-- fire exactly once for an given action.
30class (Reflex t, Monad m) => PostBuild t m | m -> t where
31 -- | Retrieve the post-build 'Event' for this action.
32 getPostBuild :: m (Event t ())
34instance PostBuild t m => PostBuild t (ReaderT r m) where
35 getPostBuild = lift getPostBuild
37instance PostBuild t m => PostBuild t (StateT s m) where
38 getPostBuild = lift getPostBuild
40instance PostBuild t m => PostBuild t (Strict.StateT s m) where
41 getPostBuild = lift getPostBuild