Skip to content

Commit

Permalink
yampa: Make FRP.Yampa.Event.maybeToEvent public. Refs #267.
Browse files Browse the repository at this point in the history
The function FRP.Yampa.Event.maybeToEvent is labelled as internal, yet
it is being exported by the module. The function is useful and is being
used in the wild, so removing it now would break existing applications.

This commit makes the function "officially" public. It changes the
comment stating that it is internal, and it moves it within the module
to a location that makes more sense in terms of explaining the API.
  • Loading branch information
ivanperez-keera committed Oct 7, 2023
1 parent 23575ea commit b18a942
Showing 1 changed file with 11 additions and 13 deletions.
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 b18a942

Please sign in to comment.