Skip to content
Browse files

Event: add justD

  • Loading branch information...
1 parent 1810d97 commit 174d66f941d2b0582f6d91752a98af64cc705998 @liyang liyang committed with Takano Akio Oct 8, 2012
Showing with 8 additions and 1 deletion.
  1. +7 −0 FRP/Euphoria/Event.hs
  2. +1 −1 euphoria.cabal
View
7 FRP/Euphoria/Event.hs
@@ -64,6 +64,7 @@ module FRP.Euphoria.Event
, stepperD
, stepperDefD
, stepperMaybeD
+, justD
, accumD
-- ** Conversion into events
, eachStepD
@@ -512,6 +513,12 @@ stepperDefD = stepperD def
stepperMaybeD :: Event a -> SignalGen (Discrete (Maybe a))
stepperMaybeD ev = stepperDefD (Just <$> ev)
+-- | Given an initial value, filter out the Nothings.
+justD :: a -> Discrete (Maybe a) -> SignalGen (Discrete a)
+justD initial mD = do
+ mE <- preservesD mD
+ stepperD initial (justE mE)
+
-- | Like @accumS@, but creates a 'Discrete'.
accumD :: a -> Event (a -> a) -> SignalGen (Discrete a)
accumD initial (Event evt) = Discrete <$> transfer (False, initial) upd evt
View
2 euphoria.cabal
@@ -60,7 +60,7 @@ description:
license: PublicDomain
license-file: LICENSE
-author: Takano Akio, Andrew Richards
+author: Takano Akio, Andrew Richards, Liyang HU
maintainer: aljee@hyper.cx <Takano Akio>
-- copyright:
category: FRP

0 comments on commit 174d66f

Please sign in to comment.
Something went wrong with that request. Please try again.