on develop help sign in
Merge pull request #61 from HectorAE/develop
a06d50dRyan Trinkle
src/Reflex/Class.hs+12−5
@@ -605,15 +605,22 @@ mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
605
605
606-- | Split the event into separate events for 'Left' and 'Right' values.
606-- | Split the event into separate events for 'Left' and 'Right' values.
607fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b)
607fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b)
608+fanEither e =
608−fanEither e = let justLeft = either Just (const Nothing)
609+ let justLeft = either Just (const Nothing)
609− justRight = either (const Nothing) Just
610+ justRight = either (const Nothing) Just
610− in
611− (fmapMaybe justLeft e, fmapMaybe justRight e)
611+ in (fmapMaybe justLeft e, fmapMaybe justRight e)
612
612
613-- | Split the event into separate events for 'This' and 'That' values,
613-- | Split the event into separate events for 'This' and 'That' values,
614-- allowing them to fire simultaneously when the input value is 'These'.
614-- allowing them to fire simultaneously when the input value is 'These'.
615fanThese :: Reflex t => Event t (These a b) -> (Event t a, Event t b)
615fanThese :: Reflex t => Event t (These a b) -> (Event t a, Event t b)
616+fanThese e =
617+ let this (This x) = Just x
618+ this (These x _) = Just x
619+ this _ = Nothing
620+ that (That y) = Just y
621+ that (These _ y) = Just y
622+ that _ = Nothing
616−fanThese e = (fmapMaybe justThis e, fmapMaybe justThat e)
623+ in (fmapMaybe this e, fmapMaybe that e)
617
624
618-- | Split the event into an 'EventSelector' that allows efficient selection of
625-- | Split the event into an 'EventSelector' that allows efficient selection of
619-- the individual 'Event's.
626-- the individual 'Event's.