Skip to content

Commit 18595a1

Browse files
authored
Merge pull request #367 from reflex-frp/ignore-traverse_
Change "traverse" to "traverse_" (includes #363)
2 parents de9d2b0 + c94a6b9 commit 18595a1

File tree

11 files changed

+97
-139
lines changed

11 files changed

+97
-139
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Revision history for reflex
22

3+
## Unreleased
4+
5+
* Data.WeakBag.traverse and Data.FastWeakBag.traverse have been
6+
renamed to Data.WeakBag.traverse_ and Data.FastWeakBag.traverse_
7+
respectively.
8+
39
## 0.6.2.4
410

511
* Update to monoidal-containers 0.6

default.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
, transformers-compat, unbounded-delays, prim-uniq
88
, data-default, filepath, directory, filemanip, ghcjs-base
99
, monoidal-containers, witherable, profunctors
10-
, semialign ? null, splitThese ? (semialign != null)
10+
, splitThese ? (semialign != null), semialign ? null, these-lens ? null
1111
, useTemplateHaskell ? true
1212
}:
1313
mkDerivation {
1414
pname = "reflex";
1515
version = "0.6.2.4";
16-
src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [ ".git" "dist" ])) ./.;
16+
src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
17+
"default.nix"
18+
"release.nix"
19+
".git"
20+
"dist"
21+
])) ./.;
1722
libraryHaskellDepends = [
1823
base bifunctors containers dependent-map dependent-sum
1924
exception-transformers lens
@@ -30,6 +35,7 @@ mkDerivation {
3035
haskell-src-exts haskell-src-meta
3136
]) ++ (if splitThese then [
3237
semialign
38+
these-lens
3339
] else []);
3440
testHaskellDepends = if ghc.isGhcjs or false then [] else [
3541
hlint filepath directory filemanip

dep/reflex-platform/default.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# DO NOT HAND-EDIT THIS FILE
2+
import ((import <nixpkgs> {}).fetchFromGitHub (
3+
let json = builtins.fromJSON (builtins.readFile ./github.json);
4+
in { inherit (json) owner repo rev sha256;
5+
private = json.private or false;
6+
}
7+
))

dep/reflex-platform/github.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"owner": "reflex-frp",
3+
"repo": "reflex-platform",
4+
"branch": "jailbreakTheselens",
5+
"rev": "4284ed527c96c373538dc7e31776d9a50ca6aa91",
6+
"sha256": "1m1nkxq7ng9wnqbd77xn8d81f2iz8g61y5m0r3gp0gi0q59jm8ay"
7+
}

hydra.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

jobsets.nix

Lines changed: 0 additions & 70 deletions
This file was deleted.

reflex-platform.nix

Lines changed: 0 additions & 8 deletions
This file was deleted.

release.nix

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1-
{ rp ? import ./reflex-platform.nix {}
1+
{ reflex-platform-fun ? import ./dep/reflex-platform
22
}:
3+
34
let
4-
inherit (rp.nixpkgs) lib;
5-
compilers = ["ghc8_4" "ghc8_0" "ghcjs8_4" "ghcjs8_0"];
6-
in lib.attrValues (lib.genAttrs compilers (ghc: {
7-
reflex-useTemplateHaskell = rp.${ghc}.callPackage ./. { useTemplateHaskell = true; splitThese = false; };
8-
reflex = rp.${ghc}.callPackage ./. { useTemplateHaskell = false; splitThese = false; };
9-
}))
5+
native-reflex-platform = reflex-platform-fun {};
6+
inherit (native-reflex-platform.nixpkgs) lib;
7+
systems = ["x86_64-linux" "x86_64-darwin"];
8+
9+
perPlatform = lib.genAttrs systems (system: let
10+
reflex-platform = reflex-platform-fun { inherit system; };
11+
compilers = [
12+
"ghc"
13+
"ghcjs"
14+
] ++ lib.optionals (reflex-platform.androidSupport) [
15+
"ghcAndroidAarch64"
16+
"ghcAndroidAarch32"
17+
] ++ lib.optionals (reflex-platform.iosSupport) [
18+
"ghcIosAarch64"
19+
];
20+
hsPkgs = lib.genAttrs compilers (ghc: let
21+
ghc' = reflex-platform.${ghc}.override {
22+
overrides = self: super: {
23+
reflex-dontUseTemplateHaskell = self.callPackage ./. { useTemplateHaskell = false; };
24+
reflex = self.callPackage ./. { useTemplateHaskell = true; };
25+
};
26+
};
27+
in {
28+
inherit (ghc') reflex reflex-dontUseTemplateHaskell;
29+
});
30+
in hsPkgs // {
31+
cache = reflex-platform.pinBuildInputs "reflex-${system}"
32+
(lib.concatLists (map builtins.attrValues (builtins.attrValues hsPkgs)));
33+
});
34+
35+
metaCache = native-reflex-platform.pinBuildInputs "reflex-everywhere"
36+
(map (a: a.cache) (builtins.attrValues perPlatform));
37+
38+
in perPlatform // { inherit metaCache; }

src/Data/FastWeakBag.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Data.FastWeakBag
1818
, isEmpty
1919
, insert
2020
, traverse
21+
, traverse_
2122
, remove
2223
-- * Internal functions
2324
-- These will not always be available.
@@ -116,14 +117,14 @@ foreign import javascript unsafe "(function(){ for(var i = 0; i < $1.tickets.len
116117
isEmpty bag = {-# SCC "isEmpty" #-} IntMap.null <$> readIORef (_weakBag_children bag)
117118
#endif
118119

119-
{-# INLINE traverse #-}
120+
{-# INLINE traverse_ #-}
120121
-- | Visit every node in the given list. If new nodes are appended during the
121122
-- traversal, they will not be visited. Every live node that was in the list
122123
-- when the traversal began will be visited exactly once; however, no guarantee
123124
-- is made about the order of the traversal.
124-
traverse :: forall a m. MonadIO m => FastWeakBag a -> (a -> m ()) -> m ()
125+
traverse_ :: forall a m. MonadIO m => FastWeakBag a -> (a -> m ()) -> m ()
125126
#ifdef GHCJS_FAST_WEAK
126-
traverse wb f = do
127+
traverse_ wb f = do
127128
let go cursor = when (not $ js_isNull cursor) $ do
128129
val <- liftIO $ js_getTicketValue cursor
129130
f $ unsafeFromRawJSVal val
@@ -134,13 +135,17 @@ foreign import javascript unsafe "$r = $1.val;" js_getTicketValue :: JSVal -> IO
134135
--TODO: Fix the race condition where if a cursor is deleted (presumably using 'remove', below) while we're holding it, it can't find its way back to the correct bag
135136
foreign import javascript unsafe "(function(){ for(var i = $1.pos - 1; i >= 0; i--) { if($1.bag.tickets[i] !== null) { return $1.bag.tickets[i]; } }; return null; })()" js_getNext :: FastWeakBagTicket a -> IO JSVal --TODO: Clean up as we go along so this isn't O(n) every time -- Result can be null or a FastWeakBagTicket a
136137
#else
137-
traverse (FastWeakBag _ children) f = {-# SCC "traverse" #-} do
138+
traverse_ (FastWeakBag _ children) f = {-# SCC "traverse_" #-} do
138139
cs <- liftIO $ readIORef children
139140
forM_ cs $ \c -> do
140141
ma <- liftIO $ deRefWeak c
141142
mapM_ f ma
142143
#endif
143144

145+
{-# DEPRECATED traverse "Use 'traverse_' instead" #-}
146+
traverse :: forall a m. MonadIO m => FastWeakBag a -> (a -> m ()) -> m ()
147+
traverse = traverse_
148+
144149
-- | Remove an item from the 'FastWeakBag'; does nothing if invoked multiple times
145150
-- on the same 'FastWeakBagTicket'.
146151
{-# INLINE remove #-}

src/Data/WeakBag.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Data.WeakBag
1515
, singleton
1616
, insert
1717
, traverse
18+
, traverse_
1819
, remove
1920
-- * Internal functions
2021
-- These will not always be available.
@@ -99,18 +100,22 @@ singleton a wbRef finalizer = {-# SCC "singleton" #-} do
99100
ticket <- insert a bag wbRef finalizer
100101
return (bag, ticket)
101102

102-
{-# INLINE traverse #-}
103+
{-# INLINE traverse_ #-}
103104
-- | Visit every node in the given list. If new nodes are appended during the
104105
-- traversal, they will not be visited. Every live node that was in the list
105106
-- when the traversal began will be visited exactly once; however, no guarantee
106107
-- is made about the order of the traversal.
107-
traverse :: MonadIO m => WeakBag a -> (a -> m ()) -> m ()
108-
traverse (WeakBag _ children) f = {-# SCC "traverse" #-} do
108+
traverse_ :: MonadIO m => WeakBag a -> (a -> m ()) -> m ()
109+
traverse_ (WeakBag _ children) f = {-# SCC "traverse" #-} do
109110
cs <- liftIO $ readIORef children
110111
forM_ cs $ \c -> do
111112
ma <- liftIO $ deRefWeak c
112113
mapM_ f ma
113114

115+
{-# DEPRECATED traverse "Use 'traverse_' instead" #-}
116+
traverse :: MonadIO m => WeakBag a -> (a -> m ()) -> m ()
117+
traverse = traverse_
118+
114119
-- | Remove an item from the 'WeakBag'; does nothing if invoked multiple times
115120
-- on the same 'WeakBagTicket'.
116121
{-# INLINE remove #-}

0 commit comments

Comments
 (0)