packages feed

reactive-banana-wx 0.2.0.3 → 0.3.0.0

raw patch · 3 files changed

+20/−16 lines, 3 filesdep ~reactive-bananaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: reactive-banana

API changes (from Hackage documentation)

- Reactive.Banana.WX: event0 :: w -> Event w (IO ()) -> Prepare (Event ())
+ Reactive.Banana.WX: event0 :: w -> Event w (IO ()) -> NetworkDescription (Event ())
- Reactive.Banana.WX: event1 :: Typeable a => w -> Event w (a -> IO ()) -> Prepare (Event a)
+ Reactive.Banana.WX: event1 :: Typeable a => w -> Event w (a -> IO ()) -> NetworkDescription (Event a)
- Reactive.Banana.WX: sink :: w -> [Prop' w] -> Prepare ()
+ Reactive.Banana.WX: sink :: w -> [Prop' w] -> NetworkDescription ()

Files

reactive-banana-wx.cabal view
@@ -1,5 +1,5 @@ Name:                reactive-banana-wx-Version:             0.2.0.3+Version:             0.3.0.0 Synopsis:            Examples for the reactive-banana library, using wxHaskell. Description:     This library provides some examples for the @reactive-banana@ library,@@ -23,7 +23,7 @@ Library     hs-source-dirs:  src     build-depends:   base >= 4.2 && < 4.4,-                     reactive-banana >= 0.2.0.3 && < 0.3,+                     reactive-banana >= 0.3.0.0 && < 0.4,                      wx==0.12.*, wxcore==0.12.*     extensions:      ExistentialQuantification     exposed-modules: Reactive.Banana.WX@@ -32,7 +32,7 @@     hs-source-dirs:  src     main-is:         Counter.hs     build-depends:   base >= 4.2 && < 4.4,-                     reactive-banana >= 0.2.0.3 && < 0.3,+                     reactive-banana >= 0.3.0.0 && < 0.4,                      wx==0.12.*, wxcore==0.12.*     extensions:      ExistentialQuantification 
src/Counter.hs view
@@ -5,9 +5,10 @@ ------------------------------------------------------------------------------} module Main where +import Control.Monad+import Graphics.UI.WX hiding (Event) import Reactive.Banana import Reactive.Banana.WX-import Graphics.UI.WX hiding (Event)  {-----------------------------------------------------------------------------     Main@@ -21,7 +22,7 @@     set f [layout := margin 10 $             column 5 [widget bup, widget bdown, widget output]]     -    prepareEvents $ do+    network <- compile $ do         eup   <- event0 bup   command         edown <- event0 bdown command         @@ -30,3 +31,5 @@             counter = accumE 0 $ ((+1) <$ eup) `union` (subtract 1 <$ edown)              sink output [text :== ("0", show <$> counter)]+    +    run network
src/Reactive/Banana/WX.hs view
@@ -9,6 +9,7 @@  import Reactive.Banana import qualified Graphics.UI.WX as WX+import Graphics.UI.WX (on, Prop(..))  {-----------------------------------------------------------------------------     Wx@@ -17,26 +18,26 @@ ------------------------------------------------------------------------------}  -- | Event with exactly one parameter.-event1 :: Typeable a => w -> WX.Event w (a -> IO ()) -> Prepare (Event a)-event1 widget e = fromAddHandler addHandler-    where-    addHandler k = WX.set widget [WX.on e WX.:~ \h x -> h x >> k x]+event1 :: Typeable a => w -> WX.Event w (a -> IO ()) -> NetworkDescription (Event a)+event1 widget e = do+    (addHandler, runHandlers) <- liftIO $ newAddHandler+    liftIO $ WX.set widget [on e :~ \h x -> h x >> runHandlers x]+    fromAddHandler addHandler  -- | Event without parameters.-event0 :: w -> WX.Event w (IO ()) -> Prepare (Event ())-event0 widget e = fromAddHandler addHandler-   where-   addHandler k = WX.set widget [WX.on e WX.:~ \h -> h >> k ()]+event0 :: w -> WX.Event w (IO ()) -> NetworkDescription (Event ())+event0 widget e = event1 widget $ WX.mapEvent const (\_ e -> e ()) e + data Prop' w = forall a. (WX.Attr w a) :== (a, Event a)  -- | "Animate" a property with a stream of events-sink :: w -> [Prop' w] -> Prepare ()+sink :: w -> [Prop' w] -> NetworkDescription () sink widget props = mapM_ sink1 props     where     sink1 (attr :== (x,ex)) = do-        liftIO $ WX.set widget [attr  WX.:= x]-        reactimate $ (\x -> WX.set widget [attr WX.:= x]) <$> ex+        liftIO $ WX.set widget [attr := x]+        reactimate $ (\x -> WX.set widget [attr := x]) <$> ex