on develop help sign in
Merge branch 'now-event' of github.com:parenthetical/reflex into now-event
0889e0dAdriaan Leijnse
ChangeLog.md+7
@@ -1,5 +1,12 @@
1# Revision history for reflex
1# Revision history for reflex
2
2
3+## 0.7.1.0
4+
5+* ([#413](https://github.com/reflex-frp/reflex/pull/413), [#417](https://github.com/reflex-frp/reflex/pull/417)) Add `Reflex.Host.Headless` module which provides `runHeadlessApp` as an easy way to run a Reflex network in a "headless" environment.
6+* ([#420](https://github.com/reflex-frp/reflex/pull/420)) Add a [`Data.Zip.Unzip`](https://hackage.haskell.org/package/semialign-1.1/docs/Data-Zip.html#t:Unzip) instance for `Event`.
7+* ([#419](https://github.com/reflex-frp/reflex/pull/419)) Add `distributeIntMapOverDynPure` and `joinDynThroughIntMap` as convenience functions for working with `Dynamic` `IntMap`s.
8+
9+
3## 0.7.0.0
10## 0.7.0.0
4
11
5* Add lifting instances for most classes to `Reflex.Profiled.Profiled`. ([#398](https://github.com/reflex-frp/reflex/pull/398))
12* Add lifting instances for most classes to `Reflex.Profiled.Profiled`. ([#398](https://github.com/reflex-frp/reflex/pull/398))
reflex.cabal+2−2
@@ -1,5 +1,5 @@
1Name: reflex
1Name: reflex
2−Version: 0.7.0.0
2+Version: 0.7.1.0
3Synopsis: Higher-order Functional Reactive Programming
3Synopsis: Higher-order Functional Reactive Programming
4Description: Reflex is a high-performance, deterministic, higher-order Functional Reactive Programming system
4Description: Reflex is a high-performance, deterministic, higher-order Functional Reactive Programming system
5License: BSD3
5License: BSD3
@@ -244,7 +244,7 @@ test-suite hlint
244 , directory
244 , directory
245 , filepath
245 , filepath
246 , filemanip
246 , filemanip
247− , hlint < 2.1 || >= 2.2.2
247+ , hlint (< 2.1 || >= 2.2.2) && < 3
248 if impl(ghcjs)
248 if impl(ghcjs)
249 buildable: False
249 buildable: False
250
250
release.nix+2−2
@@ -1,12 +1,12 @@
1{ reflex-platform-fun ? import ./dep/reflex-platform
1{ reflex-platform-fun ? import ./dep/reflex-platform
2+, supportedSystems ? ["x86_64-linux" "x86_64-darwin"]
2}:
3}:
3
4
4let
5let
5 native-reflex-platform = reflex-platform-fun {};
6 native-reflex-platform = reflex-platform-fun {};
6 inherit (native-reflex-platform.nixpkgs) lib;
7 inherit (native-reflex-platform.nixpkgs) lib;
7− systems = ["x86_64-linux" "x86_64-darwin"];
8
8
9− perPlatform = lib.genAttrs systems (system: let
9+ perPlatform = lib.genAttrs supportedSystems (system: let
10 reflex-platform = reflex-platform-fun { inherit system; };
10 reflex-platform = reflex-platform-fun { inherit system; };
11 compilers = [
11 compilers = [
12 "ghc"
12 "ghc"
src/Reflex/Class.hs+7−1
@@ -180,7 +180,7 @@ import Prelude hiding (zip, zipWith)
180import Data.These.Combinators (justThese)
180import Data.These.Combinators (justThese)
181#endif
181#endif
182#if MIN_VERSION_semialign(1,1,0)
182#if MIN_VERSION_semialign(1,1,0)
183−import Data.Zip (Zip (..))
183+import Data.Zip (Zip (..), Unzip (..))
184#endif
184#endif
185#endif
185#endif
186
186
@@ -1099,6 +1099,12 @@ instance Reflex t => Zip (Event t) where
1099 zip x y = mapMaybe justThese $ align x y
1099 zip x y = mapMaybe justThese $ align x y
1100#endif
1100#endif
1101
1101
1102+#ifdef MIN_VERSION_semialign
1103+#if MIN_VERSION_semialign(1,1,0)
1104+instance Reflex t => Unzip (Event t) where
1105+ unzip = splitE
1106+#endif
1107+#endif
1102
1108
1103-- | Create a new 'Event' that only occurs if the supplied 'Event' occurs and
1109-- | Create a new 'Event' that only occurs if the supplied 'Event' occurs and
1104-- the 'Behavior' is true at the time of occurrence.
1110-- the 'Behavior' is true at the time of occurrence.
src/Reflex/Dynamic.hs+14
@@ -53,10 +53,12 @@ module Reflex.Dynamic
53 , foldDynMaybe
53 , foldDynMaybe
54 , foldDynMaybeM
54 , foldDynMaybeM
55 , joinDynThroughMap
55 , joinDynThroughMap
56+ , joinDynThroughIntMap
56 , traceDyn
57 , traceDyn
57 , traceDynWith
58 , traceDynWith
58 , splitDynPure
59 , splitDynPure
59 , distributeMapOverDynPure
60 , distributeMapOverDynPure
61+ , distributeIntMapOverDynPure
60 , distributeDMapOverDynPure
62 , distributeDMapOverDynPure
61 , distributeListOverDynPure
63 , distributeListOverDynPure
62 , Demux
64 , Demux
@@ -88,6 +90,8 @@ import Data.Dependent.Map (DMap)
88import qualified Data.Dependent.Map as DMap
90import qualified Data.Dependent.Map as DMap
89import Data.Dependent.Sum (DSum (..))
91import Data.Dependent.Sum (DSum (..))
90import Data.GADT.Compare (GCompare (..), GEq (..), GOrdering (..))
92import Data.GADT.Compare (GCompare (..), GEq (..), GOrdering (..))
93+import Data.IntMap (IntMap)
94+import qualified Data.IntMap as IntMap
91import Data.Map (Map)
95import Data.Map (Map)
92import Data.Maybe
96import Data.Maybe
93import Data.Monoid ((<>))
97import Data.Monoid ((<>))
@@ -202,6 +206,11 @@ splitDynPure d = (fmap fst d, fmap snd d)
202distributeMapOverDynPure :: (Reflex t, Ord k) => Map k (Dynamic t v) -> Dynamic t (Map k v)
206distributeMapOverDynPure :: (Reflex t, Ord k) => Map k (Dynamic t v) -> Dynamic t (Map k v)
203distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithFunctorToDMap
207distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithFunctorToDMap
204
208
209+-- | Convert an 'IntMap' with 'Dynamic' elements into a 'Dynamic' of an 'IntMap' with
210+-- non-'Dynamic' elements.
211+distributeIntMapOverDynPure :: (Reflex t) => IntMap (Dynamic t v) -> Dynamic t (IntMap v)
212+distributeIntMapOverDynPure = fmap dmapToIntMap . distributeDMapOverDynPure . intMapWithFunctorToDMap
213+
205-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
214-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
206-- non-'Dynamic' elements, preserving the order of the elements.
215-- non-'Dynamic' elements, preserving the order of the elements.
207{-# DEPRECATED distributeListOverDynPure "Use 'distributeListOverDyn' instead" #-}
216{-# DEPRECATED distributeListOverDynPure "Use 'distributeListOverDyn' instead" #-}
@@ -214,6 +223,11 @@ distributeListOverDynPure = distributeListOverDyn
214joinDynThroughMap :: forall t k a. (Reflex t, Ord k) => Dynamic t (Map k (Dynamic t a)) -> Dynamic t (Map k a)
223joinDynThroughMap :: forall t k a. (Reflex t, Ord k) => Dynamic t (Map k (Dynamic t a)) -> Dynamic t (Map k a)
215joinDynThroughMap = (distributeMapOverDynPure =<<)
224joinDynThroughMap = (distributeMapOverDynPure =<<)
216
225
226+-- | Combine a 'Dynamic' of an 'IntMap' of 'Dynamic's into a 'Dynamic'
227+-- with the current values of the 'Dynamic's in a map.
228+joinDynThroughIntMap :: forall t a. (Reflex t) => Dynamic t (IntMap (Dynamic t a)) -> Dynamic t (IntMap a)
229+joinDynThroughIntMap = (distributeIntMapOverDynPure =<<)
230+
217-- | Print the value of the 'Dynamic' when it is first read and on each
231-- | Print the value of the 'Dynamic' when it is first read and on each
218-- subsequent change that is observed (as 'traceEvent'), prefixed with the
232-- subsequent change that is observed (as 'traceEvent'), prefixed with the
219-- provided string. This should /only/ be used for debugging.
233-- provided string. This should /only/ be used for debugging.
src/Reflex/Host/Headless.hs+3−5
@@ -43,7 +43,7 @@ type MonadHeadlessApp t m =
43-- | Run a headless FRP network. Inside the action, you will most probably use
43-- | Run a headless FRP network. Inside the action, you will most probably use
44-- the capabilities provided by the 'TriggerEvent' and 'PerformEvent' type
44-- the capabilities provided by the 'TriggerEvent' and 'PerformEvent' type
45-- classes to interface the FRP network with the outside world. Useful for
45-- classes to interface the FRP network with the outside world. Useful for
46−-- testing.
46+-- testing. Each headless network runs on its own spider timeline.
47runHeadlessApp
47runHeadlessApp
48 :: (forall t m. MonadHeadlessApp t m => m (Event t ()))
48 :: (forall t m. MonadHeadlessApp t m => m (Event t ()))
49 -- ^ The action to be run in the headless FRP network. The FRP network is
49 -- ^ The action to be run in the headless FRP network. The FRP network is
@@ -51,10 +51,8 @@ runHeadlessApp
51 -> IO ()
51 -> IO ()
52runHeadlessApp guest =
52runHeadlessApp guest =
53 -- We are using the 'Spider' implementation of reflex. Running the host
53 -- We are using the 'Spider' implementation of reflex. Running the host
54− -- allows us to take actions on the FRP timeline. The scoped type signature
54+ -- allows us to take actions on the FRP timeline.
55− -- specifies that our host runs on the Global timeline.
55+ withSpiderTimeline $ runSpiderHostForTimeline $ do
56− -- For more information, see 'Reflex.Spider.Internal.runSpiderHost'.
57− (runSpiderHost :: SpiderHost Global a -> IO a) $ do
58 -- Create the "post-build" event and associated trigger. This event fires
56 -- Create the "post-build" event and associated trigger. This event fires
59 -- once, when the application starts.
57 -- once, when the application starts.
60 (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef
58 (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef