Skip to content

Commit

Permalink
Merge branch 'develop-maybeToEvent' into develop. Close #267.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Oct 7, 2023
2 parents 23575ea + 9c029b9 commit 50dd649
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
3 changes: 3 additions & 0 deletions yampa-test/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023-10-07 Ivan Perez <ivan.perez@keera.co.uk>
* Move test for consistency with module tested (#267).

2023-08-07 Ivan Perez <ivan.perez@keera.co.uk>
* Version bump (0.14.4) (#274).
* Add version bounds to dependencies (#273).
Expand Down
18 changes: 9 additions & 9 deletions yampa-test/tests/Test/FRP/Yampa/Event.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ tests = testGroup "Regression tests for FRP.Yampa.Event"
, testApplicative
, testMonad
, testAlternative
, testProperty "maybeToEvent" testMaybeToEvent
, testEvent
, testProperty "fromEvent" testFromEvent
, testProperty "isEvent" testIsEvent
Expand All @@ -58,6 +57,7 @@ tests = testGroup "Regression tests for FRP.Yampa.Event"
, testProperty "filterE" testFilterE
, testProperty "mapFilterE" testMapFilterE
, testProperty "gate" testGate
, testProperty "maybeToEvent" testMaybeToEvent
]

-- * The Event type
Expand Down Expand Up @@ -227,14 +227,6 @@ testAlternative = testGroup "alternative"
testAlternativeEmptyIdRight =
forAll randomEvent $ \e ->
(e <|> noEvent ) == e

-- * Internal utilities for event construction

-- | maybeToEvent
testMaybeToEvent :: Property
testMaybeToEvent =
forAll randomMaybe $ \m ->
event Nothing Just (maybeToEvent m) == m
-- * Utility functions similar to those available for Maybe

-- | event
Expand Down Expand Up @@ -438,6 +430,14 @@ testGate =
forAll randomBool $ \b ->
gate e b == filterE (const b) e

-- * Utilities for easy event construction

-- | maybeToEvent
testMaybeToEvent :: Property
testMaybeToEvent =
forAll randomMaybe $ \m ->
event Nothing Just (maybeToEvent m) == m

-- * Arbitrary value generation

instance Arbitrary a => Arbitrary (Event a) where
Expand Down
3 changes: 2 additions & 1 deletion yampa/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2023-10-05 Ivan Perez <ivan.perez@keera.co.uk>
2023-10-07 Ivan Perez <ivan.perez@keera.co.uk>
* Define Yampa.FRP.Task.return in terms of pure (#276).
* Add link to new publication (#277).
* Make FRP.Yampa.Event.maybeToEvent public (#267).

2023-08-07 Ivan Perez <ivan.perez@keera.co.uk>
* Version bump (0.14.4) (#274).
Expand Down
24 changes: 11 additions & 13 deletions yampa/src/FRP/Yampa/Event.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ module FRP.Yampa.Event
, noEventFst
, noEventSnd

-- * Internal utilities for event construction
, maybeToEvent

-- * Utility functions similar to those available for Maybe
, event
, fromEvent
Expand All @@ -64,6 +61,10 @@ module FRP.Yampa.Event
, filterE
, mapFilterE
, gate

-- * Utilities for easy event construction
, maybeToEvent

)
where

Expand Down Expand Up @@ -167,16 +168,6 @@ instance NFData a => NFData (Event a) where
rnf NoEvent = ()
rnf (Event a) = rnf a `seq` ()

-- * Internal utilities for event construction

-- These utilities are to be considered strictly internal to Yampa for the time
-- being.

-- | Convert a maybe value into a event ('Event' is isomorphic to 'Maybe').
maybeToEvent :: Maybe a -> Event a
maybeToEvent Nothing = NoEvent
maybeToEvent (Just a) = Event a

-- * Utility functions similar to those available for Maybe

-- | An event-based version of the maybe function.
Expand Down Expand Up @@ -304,3 +295,10 @@ mapFilterE f e = e >>= (maybeToEvent . f)
gate :: Event a -> Bool -> Event a
_ `gate` False = NoEvent
e `gate` True = e

-- * Utilities for easy event construction

-- | Convert a maybe value into a event ('Event' is isomorphic to 'Maybe').
maybeToEvent :: Maybe a -> Event a
maybeToEvent Nothing = NoEvent
maybeToEvent (Just a) = Event a

0 comments on commit 50dd649

Please sign in to comment.