on develop help sign in
Fix error with 'fanThese'.

justThis and justThat produce Nothing in the 'These' case, so neither event produced by fanThese would fire when the value of the event is a 'These', exactly the opposite of what I intended. Also made the style consistent with the rest of the code.

commit20dd2fe354e1cd6544910dbaaf68e8c0c7de569d authorHector A. Escobedo <ninjahector.escobedo@gmail.com> dateWed 10 Aug 2016, 14:59 (10 years ago) parent49a5160
1 file changed+12−5
src/Reflex/Class.hs+12−5
src/Reflex/Class.hs+12−5
@@ -605,15 +605,22 @@ mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
605605
606606-- | Split the event into separate events for 'Left' and 'Right' values.
607607fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b)
608−fanEither e = let justLeft = either Just (const Nothing)
609− justRight = either (const Nothing) Just
610− in
611− (fmapMaybe justLeft e, fmapMaybe justRight e)
608+fanEither e =
609+ let justLeft = either Just (const Nothing)
610+ justRight = either (const Nothing) Just
611+ in (fmapMaybe justLeft e, fmapMaybe justRight e)
612612
613613-- | Split the event into separate events for 'This' and 'That' values,
614614-- allowing them to fire simultaneously when the input value is 'These'.
615615fanThese :: Reflex t => Event t (These a b) -> (Event t a, Event t b)
616−fanThese e = (fmapMaybe justThis e, fmapMaybe justThat e)
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
623+ in (fmapMaybe this e, fmapMaybe that e)
617624
618625-- | Split the event into an 'EventSelector' that allows efficient selection of
619626-- the individual 'Event's.