haskell / haskell/containers

Add rules for Data.Set.alterF

Open
#695 0 comments 1 reaction 0 assignees View on GitHub
performance Set
Dominant language
Haskell
Stars
355
Forks
194
Avg merge
3d 4h
Merged PRs (30d)
4

Description

We want

```haskell
alterF (const m) k s
-- or even
alterF (`seq` m) k s
===>
seq s $
bool (delete k s) (insert_preserving k s) <$> m
```

to avoid worrying about whether the key was in the map when it doesn't matter.

We might also want to generalize the `Const` rule to accommodate other `Const`-like functors:

```haskell
data Var = X | Y
-- When
-- fmap (`seq` X) (f False) = fmap (`seq` Y) (f False)
-- and
-- fmap (`seq` X) (f True) = fmap (`seq` Y) (f True)
alterF f k s ===> (`seq` empty) <$> f (member k s)
```

I haven't worked out the exact strictness for this bit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.