Skip to content

Commit

Permalink
Rename unlessE -> difference
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Spitzner committed Oct 18, 2016
1 parent 61c2268 commit 0fbe5c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
18 changes: 9 additions & 9 deletions Quickref.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ Since MonadHold depends on MonadSample, any [S] function also runs in [H] contex
[ ] attachPromptlyDynWithMaybe :: (a -> b -> Maybe c) -> Dynamic a -> Event b -> Event c

-- Combine multiple Events
[ ] <> :: Monoid a => Event a -> Event a -> Event a
[ ] unlessE :: Event a -> Event b -> Event a
[ ] align :: Event a -> Event b -> Event (These a b)
[ ] alignWith :: (These a b -> c) -> Event a -> Event b -> Event c
[ ] mergeWith :: (a -> a -> a) -> [Event a] -> Event a
[ ] leftmost :: [Event a] -> Event a
[ ] mergeList :: [Event a] -> Event (NonEmpty a)
[ ] merge :: GCompare k => DMap (WrapArg Event k) -> Event (DMap k)
[ ] mergeMap :: Ord k => Map k (Event a) -> Event (Map k a)
[ ] <> :: Semigroup a => Event a -> Event a -> Event a
[ ] difference :: Event a -> Event b -> Event a
[ ] align :: Event a -> Event b -> Event (These a b)
[ ] alignWith :: (These a b -> c) -> Event a -> Event b -> Event c
[ ] mergeWith :: (a -> a -> a) -> [Event a] -> Event a
[ ] leftmost :: [Event a] -> Event a
[ ] mergeList :: [Event a] -> Event (NonEmpty a)
[ ] merge :: GCompare k => DMap (WrapArg Event k) -> Event (DMap k)
[ ] mergeMap :: Ord k => Map k (Event a) -> Event (Map k a)

-- Efficient one-to-many fanout
[ ] fanMap :: Ord k => Event (Map k a) -> EventSelector (Const2 k a)
Expand Down
8 changes: 5 additions & 3 deletions src/Reflex/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Reflex.Class
, mergeMap
, mergeList
, mergeWith
, unlessE
, difference
-- ** Breaking up 'Event's
, splitE
, fanEither
Expand Down Expand Up @@ -720,8 +720,10 @@ distributeListOverDynWith f = fmap (f . map (\(Const2 _ :=> Identity v) -> v) .

-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
-- unless the second supplied 'Event' occurs simultaneously.
unlessE :: Reflex t => Event t a -> Event t b -> Event t a
unlessE = alignWithMaybe $ \case { This a -> Just a ; _ -> Nothing }
difference :: Reflex t => Event t a -> Event t b -> Event t a
difference = alignWithMaybe $ \case
This a -> Just a
_ -> Nothing

-- (intentially not exported, for now)
alignWithMaybe
Expand Down
4 changes: 2 additions & 2 deletions test/Reflex/Test/Micro.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ testCases =
f <- fanMap . fmap toMap <$> events1
return $ toList <$> mergeList [ select f (Const2 'b'), select f (Const2 'b'), select f (Const2 'e'), select f (Const2 'e') ]

, testE "unlessE" $ do
, testE "difference" $ do
e1 <- events1
e2 <- events2
return $ e1 `unlessE ` e2
return $ e1 `difference ` e2

] where

Expand Down

0 comments on commit 0fbe5c2

Please sign in to comment.