@@ -14,6 +14,7 @@
1414{-# LANGUAGE TypeFamilies #-}
1515{-# LANGUAGE TypeOperators #-}
1616{-# LANGUAGE UndecidableInstances #-}
17+{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
1718
1819-- | This module contains the Reflex interface, as well as a variety of
1920-- convenience functions for working with 'Event's, 'Behavior's, and other
@@ -141,8 +142,6 @@ import Debug.Trace (trace)
141142class ( MonadHold t (PushM t)
142143 , MonadSample t (PullM t)
143144 , MonadFix (PushM t)
144− , Functor (Event t)
145− , Functor (Behavior t)
146145 , Functor (Dynamic t)
147146 , Applicative (Dynamic t) -- Necessary for GHC <= 7.8
148147 , Monad (Dynamic t)
@@ -507,9 +506,11 @@ instance Reflex t => Bind (Event t) where
507506 join = coincidence
508507
509508instance Reflex t => Functor (Event t) where
509+ {-# INLINE fmap #-}
510510 fmap f = fmapMaybe $ Just . f
511511
512512instance Reflex t => FunctorMaybe (Event t) where
513+ {-# INLINE fmapMaybe #-}
513514 fmapMaybe f = push $ return . f
514515
515516-- | Never: @'zero' = 'never'@.
@@ -645,6 +646,7 @@ instance (Semigroup a, Reflex t) => Monoid (Event t a) where
645646-- | Create a new 'Event' that occurs if at least one of the 'Event's in the
646647-- list occurs. If multiple occur at the same time they are folded from the left
647648-- with the given function.
649+{-# INLINE mergeWith #-}
648650mergeWith :: Reflex t => (a -> a -> a) -> [Event t a] -> Event t a
649651mergeWith f es = fmap (Prelude.foldl1 f . map (\(Const2 _ :=> Identity v) -> v) . DMap.toList)
650652 . merge
@@ -655,6 +657,7 @@ mergeWith f es = fmap (Prelude.foldl1 f . map (\(Const2 _ :=> Identity v) -> v)
655657-- | Create a new 'Event' that occurs if at least one of the 'Event's in the
656658-- list occurs. If multiple occur at the same time the value is the value of the
657659-- leftmost event.
660+{-# INLINE leftmost #-}
658661leftmost :: Reflex t => [Event t a] -> Event t a
659662leftmost = mergeWith const
660663