Skip to content

Commit 144de62

Browse files
committed
Merge branch 'release/0.6.2.1' of github.com:ryantrinkle/reflex
* 'release/0.6.2.1' of github.com:ryantrinkle/reflex: (30 commits) Loosen monoidal-containers version bounds Update CONTRIBUTING.md Update CONTRIBUTING.md Use unsafePerformIO better (#325) Generalize fan following DMap (#318) Distribute more generally Generalize merge Drop *Tag classes Fix deprecation warnings related to updated Data.Some Bump dependent-sum to latest version fan: Rewrite haddock Replace hackage link with badge Use Some for more existential types (which should be efficient now that it is a newtype) Bump upper bounds Typo DRY conditional compilation Bump 'these' upper bound Typo Update changelog for holdDyn fix Make holdDyn lazy in its Event again ...
2 parents 898efd6 + 45056ff commit 144de62

File tree

22 files changed

+622
-273
lines changed

22 files changed

+622
-273
lines changed

CONTRIBUTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Contribution Guide
2+
3+
Contributions and issue reports are encouraged and appreciated!
4+
5+
- [Opening Issues](#opening-issues)
6+
- [Submitting Changes](#submitting-changes)
7+
- [Guidelines for Commit Messages](#guidelines-for-commit-messages)
8+
- [Guidelines for Pull Requests](#guidelines-for-pull-requests)
9+
- [Code Quality](#code-quality)
10+
- [Documentation](#documentation)
11+
12+
## Opening Issues
13+
14+
Before opening an issue, please check whether your issue has already been reported. Assuming it has not:
15+
16+
* Describe the issue you're encountering or the suggestion you're making
17+
* Include any relevant steps to reproduce or code samples you can. It's always easier for us to debug if we have something that demonstrates the error.
18+
* Let us know what version of reflex you were using. If you're using a github checkout, provide the git hash.
19+
* Describe how you're building reflex (i.e., via reflex-platform, cabal install, stack, obelisk, etc.). If you're using reflex-platform or obelisk, provide the git hash of your checkout.
20+
21+
## Submitting Changes
22+
23+
### Guidelines for Commit Messages
24+
25+
#### Summary Line
26+
The summary line of your commit message should summarize the changes being made. Commit messages should be written in the imperative mood and should describe what happens when the commit is applied.
27+
28+
One way to think about it is that your commit message should be able to complete the sentence:
29+
"When applied, this commit will..."
30+
31+
#### Body
32+
For breaking changes, new features, refactors, or other major changes, the body of the commit message should describe the motivation behind the change in greater detail and may include references to the issue tracker. The body shouldn't repeat code/comments from the diff.
33+
34+
### Guidelines for Pull Requests
35+
36+
Wherever possible, pull requests should add a single feature or fix a single bug. Pull requests should not bundle several unrelated changes.
37+
38+
### Code Quality
39+
40+
#### Warnings
41+
42+
Your pull request should add no new warnings to the project. It should also generally not disable any warnings.
43+
44+
#### Build and Test
45+
46+
Make sure the project builds and that the tests pass! This will generally also be checked by CI before merge, but trying it yourself first means you'll catch problems earlier and your contribution can be merged that much sooner!
47+
48+
### Documentation
49+
50+
#### In the code
51+
We're always striving to improve documentation. Please include [haddock](https://haskell-haddock.readthedocs.io/en/latest/index.html) documentation for any added code, and update the documentation for any code you modify.
52+
53+
#### In the [Changelog](ChangeLog.md)
54+
Add an entry to the changelog when your PR:
55+
* Adds a feature
56+
* Deprecates something
57+
* Includes a breaking change
58+
* Makes any other change that will impact users
59+
60+
#### In the [Readme](README.md)
61+
The readme is the first place a lot of people look for information about the repository. Update any parts of the readme that are affected by your PR.
62+

ChangeLog.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
# Revision history for reflex
22

3-
## 0.6.0.0 -- 2019-03-20
3+
## Unreleased
44

5-
* Deprecate FunctorMaybe in favor of Data.Witherable.Filterable. We still export fmapMaybe, ffilter, etc., but they all rely on Filterable now.
6-
* Rename MonadDynamicWriter to DynamicWriter and add a deprecation for the old name.
7-
* Remove many deprecated functions.
8-
* Add a Num instance for Dynamic.
9-
* Add matchRequestsWithResponses to make it easier to use Requester with protocols that don't do this matching for you.
10-
* Add withRequesterT to map functions over the request and response of a RequesterT.
11-
* Suppress nil patches in QueryT as an optimization. The Query type must now have an Eq instance.
12-
* Add throttleBatchWithLag to Reflex.Time. See that module for details.
5+
* Generalize `fan` to `fanG` to take a `DMap` with non-`Identity`
6+
values.
7+
8+
* Generalize merging functions:
9+
`merge` to `mergeG`,
10+
`mergeIncremental` to `mergeIncrementalG`,
11+
`distributeDMapOverDynPure` to `distributeDMapOverDynPureG`,
12+
`mergeIncrementalWithMove` to `mergeIncrementalWithMoveG`.
13+
14+
15+
## 0.6.2.0
16+
17+
* Fix `holdDyn` so that it is lazy in its event argument
18+
These produce `DMap`s whose values needn't be `Identity`.
19+
* Stop using the now-deprecated `*Tag` classes (e.g., `ShowTag`).
20+
* Fix `holdDyn` so that it is lazy in its event argument.
1321

1422
## 0.6.1.0
1523

16-
* Re-export all of Data.Map.Monoidal
17-
* Fix QueryT and RequesterT tests
24+
* Re-export all of `Data.Map.Monoidal`
25+
* Fix `QueryT` and `RequesterT` tests
26+
27+
## 0.6.0.0 -- 2019-03-20
28+
29+
* Deprecate `FunctorMaybe` in favor of `Data.Witherable.Filterable`. We still export `fmapMaybe`, `ffilter`, etc., but they all rely on `Filterable` now.
30+
* Rename `MonadDynamicWriter` to `DynamicWriter` and add a deprecation for the old name.
31+
* Remove many deprecated functions.
32+
* Add a `Num` instance for `Dynamic`.
33+
* Add `matchRequestsWithResponses` to make it easier to use `Requester` with protocols that don't do this matching for you.
34+
* Add `withRequesterT` to map functions over the request and response of a `RequesterT`.
35+
* Suppress nil patches in `QueryT` as an optimization. The `Query` type must now have an `Eq` instance.
36+
* Add `throttleBatchWithLag` to `Reflex.Time`. See that module for details.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## [Reflex](https://reflex-frp.org/)
2+
3+
[![Hackage](https://img.shields.io/hackage/v/reflex.svg)](http://hackage.haskell.org/package/reflex)
4+
25
### Practical Functional Reactive Programming
36

47
Reflex is a fully-deterministic, higher-order Functional Reactive Programming (FRP) interface and an engine that efficiently implements that interface.
@@ -14,8 +17,6 @@ A summary of Reflex functions is available in the [quick reference](Quickref.md)
1417

1518
[/r/reflexfrp](https://www.reddit.com/r/reflexfrp)
1619

17-
[hackage](https://hackage.haskell.org/package/reflex)
18-
1920
[irc.freenode.net #reflex-frp](http://webchat.freenode.net?channels=%23reflex-frp&uio=d4)
2021

2122
### Hacking

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}:
1212
mkDerivation {
1313
pname = "reflex";
14-
version = "0.6.1";
14+
version = "0.6.2.1";
1515
src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [ ".git" "dist" ])) ./.;
1616
libraryHaskellDepends = [
1717
base bifunctors containers dependent-map dependent-sum

reflex.cabal

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: reflex
2-
Version: 0.6.1
2+
Version: 0.6.2.1
33
Synopsis: Higher-order Functional Reactive Programming
44
Description: Reflex is a high-performance, deterministic, higher-order Functional Reactive Programming system
55
License: BSD3
@@ -44,13 +44,15 @@ library
4444
base >= 4.9 && < 4.13,
4545
bifunctors >= 5.2 && < 5.6,
4646
comonad,
47+
constraints-extras >= 0.2,
4748
containers >= 0.5 && < 0.7,
4849
data-default >= 0.5 && < 0.8,
49-
dependent-map >= 0.2.4 && < 0.3,
50+
dependent-map >= 0.3 && < 0.4,
5051
exception-transformers == 0.4.*,
52+
profunctors,
5153
lens >= 4.7 && < 5,
5254
monad-control >= 1.0.1 && < 1.1,
53-
monoidal-containers == 0.4.*,
55+
monoidal-containers >= 0.4 && < 0.6,
5456
mtl >= 2.1 && < 2.3,
5557
prim-uniq >= 0.1.0.1 && < 0.2,
5658
primitive >= 0.5 && < 0.7,
@@ -61,7 +63,7 @@ library
6163
semigroups >= 0.16 && < 0.19,
6264
stm >= 2.4 && < 2.6,
6365
syb >= 0.5 && < 0.8,
64-
these >= 0.4 && < 0.7.7,
66+
these >= 0.4 && < 0.9,
6567
time >= 1.4 && < 1.9,
6668
transformers >= 0.2,
6769
transformers-compat >= 0.3,
@@ -133,16 +135,16 @@ library
133135
if flag(use-template-haskell)
134136
cpp-options: -DUSE_TEMPLATE_HASKELL
135137
build-depends:
136-
dependent-sum >= 0.3 && < 0.5,
137-
haskell-src-exts >= 1.16 && < 1.21,
138+
dependent-sum >= 0.6 && < 0.7,
139+
haskell-src-exts >= 1.16 && < 1.22,
138140
haskell-src-meta >= 0.6 && < 0.9,
139141
template-haskell >= 2.9 && < 2.15
140142
exposed-modules:
141143
Reflex.Dynamic.TH
142144
other-extensions: TemplateHaskell
143145
else
144146
build-depends:
145-
dependent-sum == 0.4.*
147+
dependent-sum == 0.6.*
146148

147149
if flag(fast-weak) && impl(ghcjs)
148150
cpp-options: -DGHCJS_FAST_WEAK

src/Data/AppendMap.hs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
{-# LANGUAGE ScopedTypeVariables #-}
88
{-# LANGUAGE TypeFamilies #-}
99
{-# OPTIONS_GHC -fno-warn-orphans #-}
10-
-- | 'Data.Map' with a better 'Monoid' instance
11-
--
12-
-- 'Data.Map' has @mappend = union@, which is left-biased. AppendMap has
13-
-- @mappend = unionWith mappend@ instead.
10+
-- |
11+
-- Module:
12+
-- Data.AppendMap
13+
-- Description:
14+
-- Instances and convenience functions for 'Data.Map.Monoidal'. We use
15+
-- monoidal-containers to take advantage of its better monoid instance.
16+
-- 'Data.Map' has @mappend = union@, which is left-biased. 'MonoidalMap'
17+
-- has @mappend = unionWith mappend@ instead.
1418
module Data.AppendMap
1519
( module Data.AppendMap
1620
, module Data.Map.Monoidal
@@ -30,12 +34,15 @@ import qualified Data.Witherable as W
3034
import Data.Map.Monoidal
3135

3236
{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
37+
-- | AppendMap is a synonym for 'Data.Map.Monoidal.MonoidalMap'
3338
type AppendMap = MonoidalMap
3439

3540
{-# DEPRECATED _unAppendMap "Use 'getMonoidalMap' instead" #-}
41+
-- | A synonym for 'getMonoidalMap'
3642
_unAppendMap :: MonoidalMap k v -> Map k v
3743
_unAppendMap = getMonoidalMap
3844

45+
-- | Pattern synonym for 'MonoidalMap'
3946
pattern AppendMap :: Map k v -> MonoidalMap k v
4047
pattern AppendMap m = MonoidalMap m
4148

@@ -50,6 +57,7 @@ nonEmptyDelete k vs =
5057
then Nothing
5158
else Just deleted
5259

60+
-- | Like 'mapMaybe' but indicates whether the resulting container is empty
5361
mapMaybeNoNull :: (a -> Maybe b)
5462
-> MonoidalMap token a
5563
-> Maybe (MonoidalMap token b)
@@ -60,9 +68,11 @@ mapMaybeNoNull f as =
6068
else Just bs
6169

6270
-- TODO: Move instances to `Reflex.Patch`
71+
-- | Displays a 'MonoidalMap' as a tree. See 'Data.Map.Lazy.showTree' for details.
6372
showTree :: forall k a. (Show k, Show a) => MonoidalMap k a -> String
6473
showTree = coerce (Map.showTree :: Map k a -> String)
6574

75+
-- | Displays a 'MonoidalMap' as a tree, using the supplied function to convert nodes to string.
6676
showTreeWith :: forall k a. (k -> a -> String) -> Bool -> Bool -> MonoidalMap k a -> String
6777
showTreeWith = coerce (Map.showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String)
6878

src/Data/FastMutableIntMap.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{-# LANGUAGE TypeFamilies #-}
2+
-- |
3+
-- Module:
4+
-- Data.FastMutableIntMap
5+
-- Description:
6+
-- A mutable version of 'IntMap'
27
module Data.FastMutableIntMap
38
( FastMutableIntMap
49
, new
@@ -32,33 +37,43 @@ import Data.IORef
3237
import Reflex.Patch.Class
3338
import Reflex.Patch.IntMap
3439

40+
-- | A 'FastMutableIntMap' holds a map of values of type @a@ and allows low-overhead modifications via IO.
41+
-- Operations on 'FastMutableIntMap' run in IO.
3542
newtype FastMutableIntMap a = FastMutableIntMap (IORef (IntMap a))
3643

44+
-- | Create a new 'FastMutableIntMap' out of an 'IntMap'
3745
new :: IntMap a -> IO (FastMutableIntMap a)
3846
new m = FastMutableIntMap <$> newIORef m
3947

48+
-- | Create a new empty 'FastMutableIntMap'
4049
newEmpty :: IO (FastMutableIntMap a)
4150
newEmpty = FastMutableIntMap <$> newIORef IntMap.empty
4251

52+
-- | Insert an element into a 'FastMutableIntMap' at the given key
4353
insert :: FastMutableIntMap a -> Int -> a -> IO ()
4454
insert (FastMutableIntMap r) k v = modifyIORef' r $ IntMap.insert k v
4555

56+
-- | Attempt to lookup an element by key in a 'FastMutableIntMap'
4657
lookup :: FastMutableIntMap a -> Int -> IO (Maybe a)
4758
lookup (FastMutableIntMap r) k = IntMap.lookup k <$> readIORef r
4859

60+
-- | Runs the provided action over the intersection of a 'FastMutableIntMap' and an 'IntMap'
4961
forIntersectionWithImmutable_ :: MonadIO m => FastMutableIntMap a -> IntMap b -> (a -> b -> m ()) -> m ()
5062
forIntersectionWithImmutable_ (FastMutableIntMap r) b f = do
5163
a <- liftIO $ readIORef r
5264
traverse_ (uncurry f) $ IntMap.intersectionWith (,) a b
5365

66+
-- | Runs the provided action over the values of a 'FastMutableIntMap'
5467
for_ :: MonadIO m => FastMutableIntMap a -> (a -> m ()) -> m ()
5568
for_ (FastMutableIntMap r) f = do
5669
a <- liftIO $ readIORef r
5770
traverse_ f a
5871

72+
-- | Checks whether a 'FastMutableIntMap' is empty
5973
isEmpty :: FastMutableIntMap a -> IO Bool
6074
isEmpty (FastMutableIntMap r) = IntMap.null <$> readIORef r
6175

76+
-- | Retrieves the size of a 'FastMutableIntMap'
6277
size :: FastMutableIntMap a -> IO Int
6378
size (FastMutableIntMap r) = IntMap.size <$> readIORef r
6479

@@ -69,6 +84,8 @@ getFrozenAndClear (FastMutableIntMap r) = do
6984
writeIORef r IntMap.empty
7085
return result
7186

87+
-- | Updates the value of a 'FastMutableIntMap' with the given patch (see 'Reflex.Patch.IntMap'),
88+
-- and returns an 'IntMap' with the modified keys and values.
7289
applyPatch :: FastMutableIntMap a -> PatchIntMap a -> IO (IntMap a)
7390
applyPatch (FastMutableIntMap r) p@(PatchIntMap m) = do
7491
v <- readIORef r

src/Data/FastWeakBag.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ newtype FastWeakBag a = FastWeakBag JSVal
5050
#else
5151
data FastWeakBag a = FastWeakBag
5252
{ _weakBag_nextId :: {-# UNPACK #-} !(IORef Int) --TODO: what if this wraps around?
53-
, _weakBag_children :: {-# UNPACK #-} !(IORef (IntMap (Weak a)))
53+
, _weakBag_children :: {-# UNPACK #-} !(IORef (IntMap (Weak a))) -- ^ Map of items contained by the 'FastWeakBag'
5454
}
5555
#endif
5656

src/Data/Functor/Misc.hs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ import Data.IntMap (IntMap)
5252
import qualified Data.IntMap as IntMap
5353
import Data.Map (Map)
5454
import qualified Data.Map as Map
55-
import Data.Some (Some)
56-
import qualified Data.Some as Some
55+
import Data.Some (Some(Some))
5756
import Data.These
5857
import Data.Typeable hiding (Refl)
5958

@@ -79,9 +78,6 @@ deriving instance Read k => Read (Const2 k v v)
7978
instance Show k => GShow (Const2 k v) where
8079
gshowsPrec n x@(Const2 _) = showsPrec n x
8180

82-
instance (Show k, Show (f v)) => ShowTag (Const2 k v) f where
83-
showTaggedPrec (Const2 _) = showsPrec
84-
8581
instance Eq k => GEq (Const2 k v) where
8682
geq (Const2 a) (Const2 b) =
8783
if a == b
@@ -124,7 +120,7 @@ intMapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=
124120
-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
125121
-- the keys, using a function to remove the wrapping 'Functor'
126122
weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'
127-
weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (Some.This k, f v)) . DMap.toAscList
123+
weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (Some k, f v)) . DMap.toAscList
128124

129125
--------------------------------------------------------------------------------
130126
-- WrapArg
@@ -214,11 +210,6 @@ instance GShow (EitherTag l r) where
214210
LeftTag -> showString "LeftTag"
215211
RightTag -> showString "RightTag"
216212

217-
instance (Show l, Show r) => ShowTag (EitherTag l r) Identity where
218-
showTaggedPrec t n (Identity a) = case t of
219-
LeftTag -> showsPrec n a
220-
RightTag -> showsPrec n a
221-
222213
-- | Convert 'Either' to a 'DSum'. Inverse of 'dsumToEither'.
223214
eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity
224215
eitherToDSum = \case

0 commit comments

Comments
 (0)