Skip to content

Commit

Permalink
Merge branch 'develop' into redundant-monad-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar committed Apr 17, 2023
2 parents d3ebca3 + 82c2b5e commit 91734d8
Show file tree
Hide file tree
Showing 17 changed files with 721 additions and 641 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/haskell.yml
Expand Up @@ -6,18 +6,18 @@ jobs:
build:
strategy:
matrix:
ghc: ['8.4.4', '8.6.5', '8.8.4', '8.10.2', '9.0.1', '9.2.2']
ghc: ['8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.1', '9.2.5', '9.4.3']
os: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}

name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: Cache
uses: actions/cache@v1
uses: actions/cache@v3
env:
cache-name: cache-cabal
with:
Expand All @@ -30,9 +30,7 @@ jobs:
${{ runner.os }}
- name: Install dependencies
run: |
cabal update
cabal build --only-dependencies --enable-tests --enable-benchmarks
run: cabal build --only-dependencies --enable-tests --enable-benchmarks
- name: Build
run: cabal build --enable-tests --enable-benchmarks all
- name: Run tests
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -32,7 +32,6 @@ tags
hsenv.log
\#*#
.#*
/shell.nix
/ghci-tmp
*.dump-*
*.verbose-core2core
11 changes: 11 additions & 0 deletions ChangeLog.md
@@ -1,5 +1,16 @@
# Revision history for reflex

## 0.9.0.0

* Breaking Change: Filter updates to `listWithKey` child widgets so that changes to the input Map don't cause spurious updates to unaffected children. This imposes an `Eq` constraint on the child values.
* Expose all Requester internals in Reflex.Requester.Base.Internal
* [Add EventWriter instance for RequesterT #469](https://github.com/reflex-frp/reflex/pull/469)

## 0.8.2.2

* Require witherable >= 0.4 and, hence, a newer monoidal-containers
* Support newer constraints-extras (0.4)

## 0.8.2.1

* Fix build for GHC 9.2
Expand Down
4 changes: 2 additions & 2 deletions dep/reflex-platform/github.json
Expand Up @@ -3,6 +3,6 @@
"repo": "reflex-platform",
"branch": "develop",
"private": false,
"rev": "ac66356c8839d1dc16cc60887c2db5988a60e6c4",
"sha256": "0zk8pf72lid6cqq4mlr1mcwh6zd5lz9i83kw519aci6mfba1afvq"
"rev": "6c8830e059a6d2859cb1b65acefed3c2f1d216d3",
"sha256": "06kv45yq8qan0p22wzj5c9mx11ns1wddyqjr1xasjjkf6gaf0080"
}
5 changes: 4 additions & 1 deletion dep/reflex-platform/thunk.nix
Expand Up @@ -2,7 +2,10 @@
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
Expand Down
2 changes: 2 additions & 0 deletions nixpkgs/default.nix
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions nixpkgs/github.json
@@ -0,0 +1,8 @@
{
"owner": "NixOS",
"repo": "nixpkgs",
"branch": "nixpkgs-unstable",
"private": false,
"rev": "e37ef84b478fa8da0ced96522adfd956fde9047a",
"sha256": "03qak39mn2142gp6zglrzrkdbig6h4r3da1psmvf3q2dwcw3zsfv"
}
12 changes: 12 additions & 0 deletions nixpkgs/thunk.nix
@@ -0,0 +1,12 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
15 changes: 15 additions & 0 deletions overlay.nix
@@ -0,0 +1,15 @@
{ haskellLib, self, super }:
{
# jailbreak here because callHackageDirect doesn't give us a way to get the latest revision of a package
# 0.1.0.0-r3 would work just fine
commutative-semigroups = haskellLib.doJailbreak (self.callHackageDirect {
pkg = "commutative-semigroups";
ver = "0.1.0.0";
sha256 = "0xmv20n3iqjc64xi3c91bwqrg8x79sgipmflmk21zz4rj9jdkv8i";
} {});
patch = self.callHackageDirect {
pkg = "patch";
ver = "0.0.8.1";
sha256 = "0q5rxnyilhbnfph48fnxbclggsbbhs0pkn0kfiadm0hmfr440cgk";
} {};
}
23 changes: 12 additions & 11 deletions reflex.cabal
@@ -1,5 +1,5 @@
Name: reflex
Version: 0.8.2.1
Version: 0.9.0.0
Synopsis: Higher-order Functional Reactive Programming
Description:
Interactive programs without callbacks or side-effects.
Expand Down Expand Up @@ -28,8 +28,8 @@ extra-source-files:
ChangeLog.md

tested-with:
GHC ==8.4.4 || ==8.6.5 || ==8.8.1 || ==8.10.2 || ==9.0.1 || ==9.2.2,
GHCJS ==8.6
GHC ==8.4.4 || ==8.6.5 || ==8.8.1 || ==8.10.7 || ==9.0.1 || ==9.2.5 || ==9.4.3,
GHCJS ==8.6 || ==8.10

flag use-reflex-optimizer
description: Use the GHC plugin Reflex.Optimizer on some of the modules in the package. This is still experimental.
Expand Down Expand Up @@ -71,17 +71,17 @@ library
hs-source-dirs: src
build-depends:
MemoTrie == 0.6.*,
base >= 4.11 && < 4.17,
base >= 4.11 && < 4.18,
bifunctors >= 5.2 && < 5.6,
comonad >= 5.0.4 && < 5.1,
commutative-semigroups >= 0.1 && <0.2,
constraints >= 0.10 && <0.14,
constraints-extras >= 0.3 && < 0.4,
constraints-extras >= 0.3 && < 0.5,
containers >= 0.6 && < 0.7,
data-default >= 0.5 && < 0.8,
dependent-map >= 0.3 && < 0.5,
exception-transformers == 0.4.*,
lens >= 4.7 && < 5.2,
lens >= 4.7 && < 5.3,
mmorph >= 1.0 && < 1.2,
monad-control >= 1.0.1 && < 1.1,
mtl >= 2.1 && < 2.3,
Expand All @@ -95,7 +95,7 @@ library
semigroupoids >= 4.0 && < 6,
stm >= 2.4 && < 2.6,
syb >= 0.5 && < 0.8,
time >= 1.4 && < 1.12,
time >= 1.4 && < 1.13,
transformers >= 0.5.6.0 && < 0.6,
unbounded-delays >= 0.1.0.0 && < 0.2,
witherable >= 0.4 && < 0.5
Expand Down Expand Up @@ -144,6 +144,7 @@ library
Reflex.Query.Base,
Reflex.Query.Class,
Reflex.Requester.Base,
Reflex.Requester.Base.Internal,
Reflex.Requester.Class,
Reflex.Spider,
Reflex.Spider.Internal,
Expand Down Expand Up @@ -187,7 +188,7 @@ library
dependent-sum >= 0.6 && < 0.8,
haskell-src-exts >= 1.16 && < 1.24,
haskell-src-meta >= 0.6 && < 0.9,
template-haskell >= 2.9 && < 2.19
template-haskell >= 2.9 && < 2.20
exposed-modules:
Reflex.Dynamic.TH
other-extensions: TemplateHaskell
Expand Down Expand Up @@ -259,10 +260,10 @@ test-suite hlint
, directory
, filepath
, filemanip
if impl(ghc >= 8.8)
build-depends: hlint >= 3 && < 4
if impl(ghc < 9.2)
build-depends: hlint (< 2.1 || >= 2.2.2) && < 3.5
else
build-depends: hlint (< 2.1 || >= 2.2.2) && < 4
build-depends: hlint >= 3.5 && < 3.6
if impl(ghcjs)
buildable: False

Expand Down
29 changes: 5 additions & 24 deletions release.nix
Expand Up @@ -3,11 +3,11 @@
}:

let
native-reflex-platform = reflex-platform-fun {};
native-reflex-platform = reflex-platform-fun { __useNewerCompiler = true; };
inherit (native-reflex-platform.nixpkgs) lib;

perPlatform = lib.genAttrs supportedSystems (system: let
reflex-platform = reflex-platform-fun { inherit system; };
reflex-platform = reflex-platform-fun { inherit system; __useNewerCompiler = true; };
compilers = [
"ghc"
"ghcjs"
Expand All @@ -25,32 +25,13 @@ let
variationPkgs = lib.genAttrs variations (variation: let
reflex-platform = reflex-platform-fun {
inherit system;
__useNewerCompiler = true;
__useTemplateHaskell = variation == "reflex"; # TODO hack
haskellOverlays = [
(self: super: {
commutative-semigroups = self.callHackageDirect {
pkg = "commutative-semigroups";
ver = "0.1.0.0";
sha256 = "0xmv20n3iqjc64xi3c91bwqrg8x79sgipmflmk21zz4rj9jdkv8i";
} {};
patch = self.callHackageDirect {
pkg = "patch";
ver = "0.0.7.0";
sha256 = "0yr2hk3fpwjxi1z0n384k3aq9b3z00c02bbwqybcj3n20l4k17l6";
} {};
})
(self: super: import ./overlay.nix { inherit self super; haskellLib = native-reflex-platform.nixpkgs.haskell.lib; })
# Use this package's source for reflex
(self: super: {
_dep = super._dep // {
reflex = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
"release.nix"
".git"
"dist"
"cabal.haskell-ci"
"cabal.project"
".travis.yml"
])) ./.;
};
_dep = super._dep // { reflex = import ./src.nix; };
})
];
};
Expand Down
34 changes: 34 additions & 0 deletions shell.nix
@@ -0,0 +1,34 @@
# Enter a shell for this project, with some choice of compiler. By default, we
# select the version of ghc provided by reflex-platform, but you can choose a
# later version from nixpkgs as well by doing:
# $ nix-shell --argstr compiler "ghc943"
{ compiler ? "reflex-platform" # or "ghc943", "ghc924"
}:
let
rp = import ./dep/reflex-platform { __useNewerCompiler = true; };
pkgs = rp.nixpkgs;
haskellLib = pkgs.haskell.lib;
system = builtins.currentSystem;
nixpkgsGhc = ((import ./nixpkgs {}).haskell.packages.${compiler}).override {
overrides = self: super: import ./overlay.nix { inherit self super haskellLib; } // {
hlint = self.callHackageDirect {
pkg = "hlint";
ver = "3.5";
sha256 = "1np43k54918v54saqqgnd82ccd6225njwxpg2031asi70jam80x9";
} {};
};
};
reflexEnv = if compiler == "reflex-platform"
then (import ./release.nix {}).${system}.ghc.reflex.env
else (nixpkgsGhc.callCabal2nix "reflex" (import ./src.nix) {}).env;
in
pkgs.mkShell {
name = "shell";
buildInputs = [
pkgs.cabal-install
pkgs.ghcid
];
inputsFrom = [
reflexEnv
];
}
8 changes: 8 additions & 0 deletions src.nix
@@ -0,0 +1,8 @@
builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
"release.nix"
".git"
"dist"
"cabal.haskell-ci"
"cabal.project"
".travis.yml"
])) ./.
16 changes: 8 additions & 8 deletions src/Reflex/Collection.hs
Expand Up @@ -74,7 +74,7 @@ listHoldWithKey m0 m' f = do
--where the Events carry diffs, not the whole value
listWithKey
:: forall t k v m a
. (Ord k, Adjustable t m, PostBuild t m, MonadFix m, MonadHold t m)
. (Ord k, Adjustable t m, PostBuild t m, MonadFix m, MonadHold t m, Eq v)
=> Dynamic t (Map k v)
-> (k -> Dynamic t v -> m a)
-> m (Dynamic t (Map k a))
Expand Down Expand Up @@ -106,7 +106,7 @@ listWithKey vals mkChild = do
, tag (current vals) postBuild
]
listHoldWithKey Map.empty changeVals $ \k v ->
mkChild k =<< holdDyn v (select childValChangedSelector $ Const2 k)
mkChild k =<< holdUniqDyn =<< holdDyn v (select childValChangedSelector $ Const2 k)

-- | Display the given map of items (in key order) using the builder
-- function provided, and update it with the given event. 'Nothing'
Expand Down Expand Up @@ -147,15 +147,15 @@ listWithKeyShallowDiff initialVals valsChanged mkChild = do
-- this scenario, but 'listViewWithKey' flattens this to
-- @/Event t (Map k a)/@ via 'switch'.
listViewWithKey
:: (Ord k, Adjustable t m, PostBuild t m, MonadHold t m, MonadFix m)
:: (Ord k, Adjustable t m, PostBuild t m, MonadHold t m, MonadFix m, Eq v)
=> Dynamic t (Map k v)
-> (k -> Dynamic t v -> m (Event t a))
-> m (Event t (Map k a))
listViewWithKey vals mkChild =
switch . fmap mergeMap <$> listViewWithKey' vals mkChild

listViewWithKey'
:: (Ord k, Adjustable t m, PostBuild t m, MonadHold t m, MonadFix m)
:: (Ord k, Adjustable t m, PostBuild t m, MonadHold t m, MonadFix m, Eq v)
=> Dynamic t (Map k v)
-> (k -> Dynamic t v -> m a)
-> m (Behavior t (Map k a))
Expand All @@ -165,7 +165,7 @@ listViewWithKey' vals mkChild = current <$> listWithKey vals mkChild
-- selected at any time.
selectViewListWithKey
:: forall t m k v a
. (Adjustable t m, Ord k, PostBuild t m, MonadHold t m, MonadFix m)
. (Adjustable t m, Ord k, PostBuild t m, MonadHold t m, MonadFix m, Eq v)
=> Dynamic t k
-- ^ Current selection key
-> Dynamic t (Map k v)
Expand All @@ -189,7 +189,7 @@ selectViewListWithKey selection vals mkChild = do
-- item widget's output 'Event'.
selectViewListWithKey_
:: forall t m k v a
. (Adjustable t m, Ord k, PostBuild t m, MonadHold t m, MonadFix m)
. (Adjustable t m, Ord k, PostBuild t m, MonadHold t m, MonadFix m, Eq v)
=> Dynamic t k
-- ^ Current selection key
-> Dynamic t (Map k v)
Expand All @@ -207,15 +207,15 @@ selectViewListWithKey_ selection vals mkChild =
-- key/value map. Unlike the 'withKey' variants, the child widgets
-- are insensitive to which key they're associated with.
list
:: (Ord k, Adjustable t m, MonadHold t m, PostBuild t m, MonadFix m)
:: (Ord k, Adjustable t m, MonadHold t m, PostBuild t m, MonadFix m, Eq v)
=> Dynamic t (Map k v)
-> (Dynamic t v -> m a)
-> m (Dynamic t (Map k a))
list dm mkChild = listWithKey dm (\_ dv -> mkChild dv)

-- | Create a dynamically-changing set of widgets from a Dynamic list.
simpleList
:: (Adjustable t m, MonadHold t m, PostBuild t m, MonadFix m)
:: (Adjustable t m, MonadHold t m, PostBuild t m, MonadFix m, Eq v)
=> Dynamic t [v]
-> (Dynamic t v -> m a)
-> m (Dynamic t [a])
Expand Down

0 comments on commit 91734d8

Please sign in to comment.