on develop help sign in
Merge branch 'develop' into jd-fancy-throttle
commit53698dff1f79f228af38d8f36f767d46e7779810 authorLuigy Leon <luichi.19@gmail.com> dateWed 16 Jan 2019, 18:39 (8 years ago) parent2e2e19dfc68de9
14 files changed+158−29
.travis.yml−16 Quickref.md+17 hydra.json+29 jobsets.nix+70 reflex-platform.nix+8 release.nix+9 src/Reflex/BehaviorWriter/Base.hs−2 src/Reflex/Class.hs+2−2 src/Reflex/EventWriter/Base.hs+1−1 src/Reflex/Query/Base.hs+5 src/Reflex/Spider/Internal.hs+5−1 test/QueryT.hs+6−1 test/Reflex/Plan/Pure.hs+4−4 test/Reflex/TestPlan.hs+2−2
.travis.ymldeleted−16
@@ -1,16 +0,0 @@
1−# Cache Buster: 0
2−language: nix
3−cache:
4− directories:
5− - /nix
6−matrix:
7− include:
8− - env: COMPILER=ghc7103
9− - env: COMPILER=ghc821
10− - env: COMPILER=ghc802
11− - env: COMPILER=ghcjs
12−script:
13− - set -e
14− - nix-build -E "with (import <nixpkgs> {}); pkgs.haskell.packages.$COMPILER.callPackage ./default.nix { }"
15− - nix-collect-garbage -d # This is important to do right before 'script' ends so the cache gets GCed
16−
Quickref.md+17
@@ -292,3 +292,20 @@ Th typeclasses and their associated annotations include:
292292[P,T] delay :: NominalDiffTime -> Event t a -> m (Event t a)
293293```
294294
295+## Networks
296+
297+```haskell
298+-- Functions from Reflex.Network used to deal with Dynamics/Events carrying (m a)
299+
300+-- Given a Dynamic of network-creating actions, create a network that is recreated whenever the Dynamic updates.
301+-- The returned Event of network results occurs when the Dynamic does. Note: Often, the type a is an Event,
302+-- in which case the return value is an Event-of-Events that would typically be flattened (via switchHold).
303+[P,A] networkView :: Dynamic (m a) -> m (Event a)
304+
305+-- Given an initial network and an Event of network-creating actions, create a network that is recreated whenever the
306+-- Event fires. The returned Dynamic of network results occurs when the Event does. Note: Often, the type a is an
307+-- Event, in which case the return value is a Dynamic-of-Events that would typically be flattened.
308+[H,A] networkHold :: m a -> Event (m a) -> m (Dynamic a)
309+
310+-- Render a placeholder network to be shown while another network is not yet done building
311+[P,A] untilReady :: m a -> m b -> m (a, Event b)
hydra.jsonnew file+29
@@ -0,0 +1,29 @@
1+{
2+ "enabled": 1,
3+ "hidden": true,
4+ "description": "Jobsets",
5+ "nixexprinput": "src",
6+ "nixexprpath": "jobsets.nix",
7+ "checkinterval": 300,
8+ "schedulingshares": 100,
9+ "enableemail": false,
10+ "emailoverride": "",
11+ "keepnr": 10,
12+ "inputs": {
13+ "src": {
14+ "type": "git",
15+ "value": "https://github.com/reflex-frp/reflex.git develop",
16+ "emailresponsible": false
17+ },
18+ "nixpkgs": {
19+ "type": "git",
20+ "value": "https://github.com/NixOS/nixpkgs-channels nixos-unstable",
21+ "emailresponsible": false
22+ },
23+ "prs": {
24+ "type": "githubpulls",
25+ "value": "reflex-frp reflex",
26+ "emailresponsible": false
27+ }
28+ }
29+}
jobsets.nixnew file+70
@@ -0,0 +1,70 @@
1+{ prs }:
2+
3+let
4+ pkgs = (import ./reflex-platform.nix {}).nixpkgs;
5+ mkFetchGithub = value: {
6+ inherit value;
7+ type = "git";
8+ emailresponsible = false;
9+ };
10+in
11+with pkgs.lib;
12+let
13+ defaults = jobs: {
14+ inherit (jobs) description;
15+ enabled = 1;
16+ hidden = false;
17+ keepnr = 10;
18+ schedulingshares = 100;
19+ checkinterval = 120;
20+ enableemail = false;
21+ emailoverride = "";
22+ nixexprinput = "reflex";
23+ nixexprpath = "release.nix";
24+ inputs = jobs.inputs // {
25+ nixpkgs = {
26+ type = "git";
27+ value = "https://github.com/NixOS/nixpkgs-channels nixos-unstable";
28+ emailresponsible = false;
29+ };
30+ config = {
31+ type = "nix";
32+ value = "{ android_sdk.accept_license = true; }";
33+ emailresponsible = false;
34+ };
35+ };
36+ };
37+ branchJobset = branch: defaults {
38+ description = "reflex-${branch}";
39+ inputs = {
40+ reflex = {
41+ value = "https://github.com/reflex-frp/reflex ${branch}";
42+ type = "git";
43+ emailresponsible = false;
44+ };
45+ };
46+ };
47+ makePr = num: info: {
48+ name = "reflex-pr-${num}";
49+ value = defaults {
50+ description = "#${num}: ${info.title}";
51+ inputs = {
52+ reflex = {
53+ #NOTE: This should really use "pull/${num}/merge"; however, GitHub's
54+ #status checks only operate on PR heads. This creates a race
55+ #condition, which can currently only be solved by requiring PRs to be
56+ #up to date before they're merged. See
57+ #https://github.com/isaacs/github/issues/1002
58+ value = "https://github.com/reflex-frp/reflex pull/${num}/head";
59+ type = "git";
60+ emailresponsible = false;
61+ };
62+ };
63+ };
64+ };
65+ processedPrs = mapAttrs' makePr (builtins.fromJSON (builtins.readFile prs));
66+ jobsetsAttrs = processedPrs //
67+ genAttrs ["develop"] branchJobset;
68+in {
69+ jobsets = pkgs.writeText "spec.json" (builtins.toJSON jobsetsAttrs);
70+}
reflex-platform.nixnew file+8
@@ -0,0 +1,8 @@
1+let
2+ reflex-platform-src = (import <nixpkgs> {}).fetchFromGitHub {
3+ owner = "reflex-frp";
4+ repo = "reflex-platform";
5+ rev = "384cd850f3adf1d404bced2424b5f6efb0f415f2";
6+ sha256 = "1ws77prqx8khmp8j6br1ij4k2v4dlgv170r9fmg0p1jivfbn8y9d";
7+ };
8+in import reflex-platform-src
release.nixnew file+9
@@ -0,0 +1,9 @@
1+{ rp ? import ./reflex-platform.nix {}
2+}:
3+let
4+ inherit (rp.nixpkgs) lib;
5+ compilers = ["ghc8_4" "ghc8_0" "ghcjs8_4" "ghcjs8_0"];
6+in lib.genAttrs compilers (ghc: {
7+ reflex-useTemplateHaskell = rp.${ghc}.callPackage ./. { useTemplateHaskell = true; };
8+ reflex = rp.${ghc}.callPackage ./. { useTemplateHaskell = false; };
9+})
src/Reflex/BehaviorWriter/Base.hs−2
@@ -6,11 +6,9 @@ Description: Implementation of MonadBehaviorWriter
66{-# LANGUAGE FlexibleInstances #-}
77{-# LANGUAGE GADTs #-}
88{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9−{-# LANGUAGE LambdaCase #-}
109{-# LANGUAGE MultiParamTypeClasses #-}
1110{-# LANGUAGE RankNTypes #-}
1211{-# LANGUAGE ScopedTypeVariables #-}
13−{-# LANGUAGE TupleSections #-}
1412{-# LANGUAGE TypeFamilies #-}
1513{-# LANGUAGE UndecidableInstances #-}
1614{-# LANGUAGE StandaloneDeriving #-}
src/Reflex/Class.hs+2−2
@@ -926,8 +926,8 @@ instance Reflex t => Align (Event t) where
926926gate :: Reflex t => Behavior t Bool -> Event t a -> Event t a
927927gate = attachWithMaybe $ \allow a -> if allow then Just a else Nothing
928928
929−-- | Create a new behavior given a starting behavior and switch to a the behvior
930−-- carried by the event when it fires.
929+-- | Create a new behavior given a starting behavior and switch to the behavior
930+-- carried by the event when it fires.
931931switcher :: (Reflex t, MonadHold t m)
932932 => Behavior t a -> Event t (Behavior t a) -> m (Behavior t a)
933933switcher b eb = pull . (sample <=< sample) <$> hold b eb
src/Reflex/EventWriter/Base.hs+1−1
@@ -58,7 +58,7 @@ import Unsafe.Coerce
5858
5959{-# DEPRECATED TellId "Do not construct this directly; use tellId instead" #-}
6060newtype TellId w x
61− = TellId Int -- ^ WARNING: Do not construct this directly; use 'TellId' instead
61+ = TellId Int -- ^ WARNING: Do not construct this directly; use 'tellId' instead
6262 deriving (Show, Eq, Ord, Enum)
6363
6464tellId :: Int -> TellId w w
src/Reflex/Query/Base.hs+5
@@ -22,6 +22,7 @@ module Reflex.Query.Base
2222import Control.Applicative (liftA2)
2323import Control.Monad.Exception
2424import Control.Monad.Fix
25+import Control.Monad.Primitive
2526import Control.Monad.Reader
2627import Control.Monad.Ref
2728import Control.Monad.State.Strict
@@ -244,6 +245,10 @@ instance (Reflex t, MonadFix m, Group q, Additive q, Query q, MonadHold t m, Adj
244245instance MonadTrans (QueryT t q) where
245246 lift = QueryT . lift . lift . lift
246247
248+instance PrimMonad m => PrimMonad (QueryT t q m) where
249+ type PrimState (QueryT t q m) = PrimState m
250+ primitive = lift . primitive
251+
247252instance PostBuild t m => PostBuild t (QueryT t q m) where
248253 getPostBuild = lift getPostBuild
249254
src/Reflex/Spider/Internal.hs+5−1
@@ -2307,9 +2307,13 @@ newJoinDyn d =
23072307 in Reflex.Spider.Internal.unsafeBuildDynamic readV0 v'
23082308
23092309instance HasSpiderTimeline x => Functor (Reflex.Class.Dynamic (SpiderTimeline x)) where
2310− fmap f = SpiderDynamic . newMapDyn f . unSpiderDynamic
2310+ fmap = mapDynamicSpider
23112311 x <$ d = R.unsafeBuildDynamic (return x) $ x <$ R.updated d
23122312
2313+mapDynamicSpider :: HasSpiderTimeline x => (a -> b) -> Reflex.Class.Dynamic (SpiderTimeline x) a -> Reflex.Class.Dynamic (SpiderTimeline x) b
2314+mapDynamicSpider f = SpiderDynamic . newMapDyn f . unSpiderDynamic
2315+{-# INLINE [1] mapDynamicSpider #-}
2316+
23132317instance HasSpiderTimeline x => Applicative (Reflex.Class.Dynamic (SpiderTimeline x)) where
23142318 pure = SpiderDynamic . dynamicConst
23152319#if MIN_VERSION_base(4,10,0)
test/QueryT.hs+6−1
@@ -1,15 +1,16 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DeriveFunctor #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE GeneralizedNewtypeDeriving #-}
45{-# LANGUAGE LambdaCase #-}
56{-# LANGUAGE RankNTypes #-}
7+{-# LANGUAGE StandaloneDeriving #-}
68{-# LANGUAGE TypeFamilies #-}
79{-# LANGUAGE UndecidableInstances #-}
810
911import Control.Lens
1012import Control.Monad.Fix
1113import Data.Align
12−import Data.AppendMap () -- for the Align instance
1314import qualified Data.AppendMap as AMap
1415import Data.Functor.Misc
1516import Data.Map (Map)
@@ -36,6 +37,10 @@ instance (Ord k, Query a, Eq (QueryResult a), Align (MonoidalMap k)) => Query (S
3637newtype Selector k a = Selector { unSelector :: MonoidalMap k a }
3738 deriving (Show, Read, Eq, Ord, Functor)
3839
40+#if !(MIN_VERSION_monoidal_containers(0,4,1))
41+deriving instance Ord k => Align (MonoidalMap k)
42+#endif
43+
3944instance (Ord k, Eq a, Monoid a, Align (MonoidalMap k)) => Semigroup (Selector k a) where
4045 (Selector a) <> (Selector b) = Selector $ fmapMaybe id $ f a b
4146 where
test/Reflex/Plan/Pure.hs+4−4
@@ -55,15 +55,15 @@ instance TestPlan (Pure Int) PurePlan where
5555runPure :: PurePlan a -> (a, IntSet)
5656runPure (PurePlan p) = runStateT p mempty $ 0
5757
58−relavantTimes :: IntSet -> IntSet
59−relavantTimes occs = IntSet.fromList [0..l + 1]
58+relevantTimes :: IntSet -> IntSet
59+relevantTimes occs = IntSet.fromList [0..l + 1]
6060 where l = fromMaybe 0 (fst <$> IntSet.maxView occs)
6161
6262testBehavior :: (Behavior (Pure Int) a, IntSet) -> IntMap a
63−testBehavior (b, occs) = IntMap.fromSet (sample b) (relavantTimes occs)
63+testBehavior (b, occs) = IntMap.fromSet (sample b) (relevantTimes occs)
6464
6565testEvent :: (Event (Pure Int) a, IntSet) -> IntMap (Maybe a)
66−testEvent (Event readEvent, occs) = IntMap.fromSet readEvent (relavantTimes occs)
66+testEvent (Event readEvent, occs) = IntMap.fromSet readEvent (relevantTimes occs)
6767
6868
6969
test/Reflex/TestPlan.hs+2−2
@@ -26,8 +26,8 @@ import Reflex.Class
2626import Prelude
2727
2828class (Reflex t, MonadHold t m, MonadFix m) => TestPlan t m where
29− -- | Speicify a plan of an input Event firing
30− -- Occurances must be in the future (i.e. Time > 0)
29+ -- | Specify a plan of an input Event firing
30+ -- Occurrences must be in the future (i.e. Time > 0)
3131 -- Initial specification is
3232
3333 plan :: [(Word, a)] -> m (Event t a)