on develop help sign in
31 lines 1.0 kB history raw
1{-|
2Module: Reflex.BehaviorWriter.Class
3Description: This module defines the 'BehaviorWriter' class
4-}
5{-# LANGUAGE CPP #-}
6{-# LANGUAGE ConstraintKinds #-}
7{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE FunctionalDependencies #-}
9{-# LANGUAGE UndecidableInstances #-}
10#ifdef USE_REFLEX_OPTIMIZER
11{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
12#endif
13module Reflex.BehaviorWriter.Class
14 ( MonadBehaviorWriter
15 , BehaviorWriter(..)
16 ) where
18import Control.Monad.Reader (ReaderT, lift)
19import Reflex.Class (Behavior)
21{-# DEPRECATED MonadBehaviorWriter "Use 'BehaviorWriter' instead" #-}
22-- | Type synonym for 'BehaviorWriter'
23type MonadBehaviorWriter = BehaviorWriter
25-- | 'BehaviorWriter' efficiently collects 'Behavior' values using 'tellBehavior'
26-- and combines them monoidally to provide a 'Behavior' result.
27class (Monad m, Monoid w) => BehaviorWriter t w m | m -> t w where
28 tellBehavior :: Behavior t w -> m ()
30instance BehaviorWriter t w m => BehaviorWriter t w (ReaderT r m) where
31 tellBehavior = lift . tellBehavior