@@ -104,7 +104,6 @@ module Reflex.Class
104104 , numberOccurrencesFrom_
105105 , (<@>)
106106 , (<@)
107− , headE
108107 , tailE
109108 , headTailE
110109 , takeWhileE
@@ -459,6 +458,14 @@ class MonadSample t m => MonadHold t m where
459458 buildDynamic :: PullM t a -> Event t a -> m (Dynamic t a)
460459 default buildDynamic :: (m ~ f m', MonadTrans f, MonadHold t m') => PullM t a -> Event t a -> m (Dynamic t a)
461460 buildDynamic getV0 = lift . buildDynamic getV0
461+ -- | Create a new 'Event' that only occurs only once, on the first occurence of
462+ -- the supplied 'Event'.
463+ headE :: Event t a -> m (Event t a)
464+ default headE :: (Reflex t, MonadFix m) => Event t a -> m (Event t a)
465+ headE e = do
466+ rec be <- hold e $ fmapCheap (const never) e'
467+ let e' = switch be
468+ return e'
462469
463470-- | An 'EventSelector' allows you to efficiently 'select' an 'Event' based on a
464471-- key. This is much more efficient than filtering for each key with
@@ -488,6 +495,7 @@ instance MonadHold t m => MonadHold t (ReaderT r m) where
488495 holdDyn a0 = lift . holdDyn a0
489496 holdIncremental a0 = lift . holdIncremental a0
490497 buildDynamic a0 = lift . buildDynamic a0
498+ headE = lift . headE
491499
492500instance (MonadSample t m, Monoid r) => MonadSample t (WriterT r m) where
493501 sample = lift . sample
@@ -497,6 +505,7 @@ instance (MonadHold t m, Monoid r) => MonadHold t (WriterT r m) where
497505 holdDyn a0 = lift . holdDyn a0
498506 holdIncremental a0 = lift . holdIncremental a0
499507 buildDynamic a0 = lift . buildDynamic a0
508+ headE = lift . headE
500509
501510instance MonadSample t m => MonadSample t (StateT s m) where
502511 sample = lift . sample
@@ -506,6 +515,7 @@ instance MonadHold t m => MonadHold t (StateT s m) where
506515 holdDyn a0 = lift . holdDyn a0
507516 holdIncremental a0 = lift . holdIncremental a0
508517 buildDynamic a0 = lift . buildDynamic a0
518+ headE = lift . headE
509519
510520instance MonadSample t m => MonadSample t (ExceptT e m) where
511521 sample = lift . sample
@@ -514,6 +524,8 @@ instance MonadHold t m => MonadHold t (ExceptT e m) where
514524 hold a0 = lift . hold a0
515525 holdDyn a0 = lift . holdDyn a0
516526 holdIncremental a0 = lift . holdIncremental a0
527+ buildDynamic a0 = lift . buildDynamic a0
528+ headE = lift . headE
517529
518530instance (MonadSample t m, Monoid w) => MonadSample t (RWST r w s m) where
519531 sample = lift . sample
@@ -522,6 +534,8 @@ instance (MonadHold t m, Monoid w) => MonadHold t (RWST r w s m) where
522534 hold a0 = lift . hold a0
523535 holdDyn a0 = lift . holdDyn a0
524536 holdIncremental a0 = lift . holdIncremental a0
537+ buildDynamic a0 = lift . buildDynamic a0
538+ headE = lift . headE
525539
526540instance MonadSample t m => MonadSample t (ContT r m) where
527541 sample = lift . sample
@@ -530,6 +544,8 @@ instance MonadHold t m => MonadHold t (ContT r m) where
530544 hold a0 = lift . hold a0
531545 holdDyn a0 = lift . holdDyn a0
532546 holdIncremental a0 = lift . holdIncremental a0
547+ buildDynamic a0 = lift . buildDynamic a0
548+ headE = lift . headE
533549
534550--------------------------------------------------------------------------------
535551-- Convenience functions
@@ -652,14 +668,6 @@ attachWith f = attachWithMaybe $ \a b -> Just $ f a b
652668attachWithMaybe :: Reflex t => (a -> b -> Maybe c) -> Behavior t a -> Event t b -> Event t c
653669attachWithMaybe f b e = flip push e $ \o -> (`f` o) <$> sample b
654670
655−-- | Create a new 'Event' that only occurs only once, on the first occurence of
656−-- the supplied 'Event'.
657−headE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
658−headE e = do
659− rec be <- hold e $ fmapCheap (const never) e'
660− let e' = switch be
661− return e'
662−
663671-- | Create a new 'Event' that occurs on all but the first occurence of the
664672-- supplied 'Event'.
665673tailE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)