Skip to content

Commit 6b7c4a8

Browse files
authored
Refactor functors and related packages (#26)
This is part of a set of commits that rearrange the dependencies between multiple packages. The immediate motivation is to allow certain newtypes to be reused between `profunctor` and `bifunctors`, but this particular approach goes a little beyond that in two ways: first, it attempts to move data types (`either`, `tuple`) toward the bottom of the dependency stack; and second, it tries to ensure no package comes between `functors` and the packages most closely related to it, in order to open the possibility of merging those packages together (which may be desirable if at some point in the future additional newtypes are added which reveal new and exciting constraints on the module dependency graph).
1 parent 0ab3ddb commit 6b7c4a8

File tree

3 files changed

+1
-37
lines changed

3 files changed

+1
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Breaking changes:
88
- Added support for PureScript 0.14 and dropped support for all previous versions (#20)
99

1010
New features:
11+
- This package no longer depends on the `purescript-foldable-traversable` package. Relevant instances have been moved to that package. (#26)
1112

1213
Bugfixes:
1314

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
],
2222
"dependencies": {
2323
"purescript-control": "master",
24-
"purescript-foldable-traversable": "master",
2524
"purescript-invariant": "master",
2625
"purescript-newtype": "master",
2726
"purescript-prelude": "master"

src/Data/Identity.purs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@ import Control.Comonad (class Comonad)
77
import Control.Extend (class Extend)
88
import Control.Lazy (class Lazy)
99
import Data.Eq (class Eq1)
10-
import Data.Foldable (class Foldable)
11-
import Data.FoldableWithIndex (class FoldableWithIndex)
1210
import Data.Functor.Invariant (class Invariant, imapF)
13-
import Data.FunctorWithIndex (class FunctorWithIndex)
1411
import Data.Newtype (class Newtype)
1512
import Data.Ord (class Ord1)
16-
import Data.Semigroup.Foldable (class Foldable1)
17-
import Data.Semigroup.Traversable (class Traversable1)
18-
import Data.Traversable (class Traversable)
19-
import Data.TraversableWithIndex (class TraversableWithIndex)
2013

2114
newtype Identity a = Identity a
2215

@@ -55,9 +48,6 @@ derive instance ord1Identity :: Ord1 Identity
5548

5649
derive instance functorIdentity :: Functor Identity
5750

58-
instance functorWithIndexIdentity :: FunctorWithIndex Unit Identity where
59-
mapWithIndex f (Identity a) = Identity (f unit a)
60-
6151
instance invariantIdentity :: Invariant Identity where
6252
imap = imapF
6353

@@ -80,29 +70,3 @@ instance extendIdentity :: Extend Identity where
8070

8171
instance comonadIdentity :: Comonad Identity where
8272
extract (Identity x) = x
83-
84-
instance foldableIdentity :: Foldable Identity where
85-
foldr f z (Identity x) = f x z
86-
foldl f z (Identity x) = f z x
87-
foldMap f (Identity x) = f x
88-
89-
instance foldable1Identity :: Foldable1 Identity where
90-
foldMap1 f (Identity x) = f x
91-
foldl1 _ (Identity x) = x
92-
foldr1 _ (Identity x) = x
93-
94-
instance foldableWithIndexIdentity :: FoldableWithIndex Unit Identity where
95-
foldrWithIndex f z (Identity x) = f unit x z
96-
foldlWithIndex f z (Identity x) = f unit z x
97-
foldMapWithIndex f (Identity x) = f unit x
98-
99-
instance traversableIdentity :: Traversable Identity where
100-
traverse f (Identity x) = Identity <$> f x
101-
sequence (Identity x) = Identity <$> x
102-
103-
instance traversable1Identity :: Traversable1 Identity where
104-
traverse1 f (Identity x) = Identity <$> f x
105-
sequence1 (Identity x) = Identity <$> x
106-
107-
instance traversableWithIndexIdentity :: TraversableWithIndex Unit Identity where
108-
traverseWithIndex f (Identity x) = Identity <$> f unit x

0 commit comments

Comments
 (0)