Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Bugfixes:
Other improvements:
- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#14)
- Added a CHANGELOG.md file and pull request template (#15, #16)
- This package now depends on the `purescript-tuples` and `purescript-type-equality` packages, and contains an instance previously in `purescript-tuples` (#17)

## [v4.0.0](https://github.com/purescript/purescript-distributive/releases/tag/v4.0.0) - 2018-05-23

Expand Down
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"dependencies": {
"purescript-identity": "master",
"purescript-newtype": "master",
"purescript-prelude": "master"
"purescript-prelude": "master",
"purescript-tuples": "master",
"purescript-type-equality": "master"
}
}
6 changes: 6 additions & 0 deletions src/Data/Distributive.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Prelude

import Data.Identity (Identity(..))
import Data.Newtype (unwrap)
import Data.Tuple (Tuple(..), snd)
import Type.Equality (class TypeEquals, from)

-- | Categorical dual of `Traversable`:
-- |
Expand Down Expand Up @@ -31,6 +33,10 @@ instance distributiveFunction :: Distributive ((->) e) where
distribute a e = map (_ $ e) a
collect f = distribute <<< map f

instance distributiveTuple :: TypeEquals a Unit => Distributive (Tuple a) where
collect = collectDefault
distribute = Tuple (from unit) <<< map snd

-- | A default implementation of `distribute`, based on `collect`.
distributeDefault
:: forall a f g
Expand Down