reactive-banana-wx 0.6.0.0 → 0.6.0.1
raw patch · 2 files changed
+115/−15 lines, 2 filesdep ~basedep ~processdep ~reactive-banana
Dependency ranges changed: base, process, reactive-banana, wx, wxcore
Files
- reactive-banana-wx.cabal +75/−15
- src/Tidings.hs +40/−0
reactive-banana-wx.cabal view
@@ -1,5 +1,5 @@ Name: reactive-banana-wx-Version: 0.6.0.0+Version: 0.6.0.1 Synopsis: Examples for the reactive-banana library, using wxHaskell. Description: This library provides some GUI examples for the @reactive-banana@ library,@@ -43,8 +43,8 @@ build-depends: base >= 4.2 && < 5, cabal-macosx >= 0.1 && < 0.3, reactive-banana >= 0.6.0.0 && < 0.7,- wxcore (>= 0.13.2.3 && < 0.90) || (>= 0.90.0.1 && < 0.91),- wx (>= 0.13.2.3 && < 0.90) || (>= 0.90.0.1 && < 0.91)+ wxcore (>= 0.13.2.1 && < 0.90) || (>= 0.90.0.1 && < 0.91),+ wx (>= 0.13.2.1 && < 0.90) || (>= 0.90.0.1 && < 0.91) extensions: ExistentialQuantification exposed-modules: Reactive.Banana.WX @@ -54,16 +54,33 @@ subdir: reactive-banana-wx Executable Animation- if !flag(buildExamples)- buildable: False- else+ if flag(buildExamples)+ build-depends:+ process >= 1.0 && < 1.2,+ random == 1.0.*,+ executable-path == 0.0.*,+ filepath >= 1.1 && <= 1.4,+ reactive-banana,+ wx,+ wxcore,+ base cpp-options: -DbuildExamples+ + else+ buildable: False hs-source-dirs: src other-modules: Paths_reactive_banana_wx, Paths main-is: Animation.hs Executable Arithmetic- if !flag(buildExamples)+ if flag(buildExamples)+ build-depends:+ process >= 1.0 && < 1.2,+ reactive-banana,+ wx,+ wxcore,+ base+ else buildable: False hs-source-dirs: src main-is: Arithmetic.hs@@ -73,7 +90,11 @@ build-depends: random == 1.0.*, executable-path == 0.0.*,- filepath >= 1.1 && <= 1.4+ filepath >= 1.1 && <= 1.4,+ reactive-banana,+ wx,+ wxcore,+ base cpp-options: -DbuildExamples else buildable: False@@ -82,14 +103,25 @@ main-is: Asteroids.hs Executable Counter- if !flag(buildExamples)+ if flag(buildExamples)+ build-depends:+ reactive-banana,+ wx,+ wxcore,+ base+ else buildable: False hs-source-dirs: src main-is: Counter.hs Executable CurrencyConverter if flag(buildExamples)- build-depends: process >= 1.0.1 && < 1.2+ build-depends:+ process >= 1.0.1 && < 1.2,+ reactive-banana,+ wx,+ wxcore,+ base else buildable: False hs-source-dirs: src@@ -97,15 +129,26 @@ Executable CRUD if flag(buildExamples)- build-depends: containers >= 0.3 && < 0.6+ build-depends:+ containers >= 0.3 && < 0.6,+ reactive-banana,+ wx,+ wxcore,+ base else buildable: False hs-source-dirs: src main-is: CRUD.hs+ other-modules: Tidings Executable NetMonitor if flag(buildExamples)- build-depends: process >= 1.0 && < 1.2+ build-depends:+ process >= 1.0 && < 1.2,+ reactive-banana,+ wx,+ wxcore,+ base else buildable: False hs-source-dirs: src@@ -113,20 +156,37 @@ Executable TicTacToe if flag(buildExamples)- build-depends: array >= 0.3 && < 0.5+ build-depends:+ array >= 0.3 && < 0.5,+ reactive-banana,+ wx,+ wxcore,+ base else buildable: False hs-source-dirs: src main-is: TicTacToe.hs Executable TwoCounters- if !flag(buildExamples)+ if flag(buildExamples)+ build-depends:+ reactive-banana,+ wx,+ wxcore,+ base+ else buildable: False hs-source-dirs: src main-is: TwoCounters.hs Executable Wave- if !flag(buildExamples)+ if flag(buildExamples)+ build-depends:+ reactive-banana,+ wx,+ wxcore,+ base+ else buildable: False hs-source-dirs: src main-is: Wave.hs
+ src/Tidings.hs view
@@ -0,0 +1,40 @@+{-----------------------------------------------------------------------------+ reactive-banana+------------------------------------------------------------------------------}+module Tidings (+ -- * Synopsis+ -- The 'Tidings' data type for composing user events.+ --+ -- See <http://apfelmus.nfshost.com/blog/2012/03/29-frp-three-principles-bidirectional-gui.html>+ -- for more information.+ + -- * Documentation+ Tidings, tidings, facts, rumors,+ ) where++import Reactive.Banana.Combinators++-- | Data type representing a behavior 'facts'+-- and suggestions to change it 'rumors'.+data Tidings t a = T { facts :: Behavior t a, rumors :: Event t a }++-- | Smart constructor. Combine facts and rumors into 'Tidings'.+tidings :: Behavior t a -> Event t a -> Tidings t a+tidings b e = T b (calm e)++instance Functor (Tidings t) where+ fmap f (T b e) = T (fmap f b) (fmap f e)++-- | The applicative instance combines 'rumors'+-- and uses 'facts' when some of the 'rumors' are not available.+instance Applicative (Tidings t) where+ pure x = T (pure x) never+ f <*> x = uncurry ($) <$> pair f x++pair :: Tidings t a -> Tidings t b -> Tidings t (a,b)+pair (T bx ex) (T by ey) = T b e+ where+ b = (,) <$> bx <*> by+ x = flip (,) <$> by <@> ex+ y = (,) <$> bx <@> ey+ e = unionWith (\(x,_) (_,y) -> (x,y)) x y