Skip to content

Refactor functors and related packages #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2021
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 @@ -8,6 +8,7 @@ Breaking changes:
- Added support for PureScript 0.14 and dropped support for all previous versions (#20)

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

Bugfixes:

Expand Down
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
],
"dependencies": {
"purescript-control": "master",
"purescript-foldable-traversable": "master",
"purescript-invariant": "master",
"purescript-newtype": "master",
"purescript-prelude": "master"
Expand Down
36 changes: 0 additions & 36 deletions src/Data/Identity.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ import Control.Comonad (class Comonad)
import Control.Extend (class Extend)
import Control.Lazy (class Lazy)
import Data.Eq (class Eq1)
import Data.Foldable (class Foldable)
import Data.FoldableWithIndex (class FoldableWithIndex)
import Data.Functor.Invariant (class Invariant, imapF)
import Data.FunctorWithIndex (class FunctorWithIndex)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)
import Data.Semigroup.Foldable (class Foldable1)
import Data.Semigroup.Traversable (class Traversable1)
import Data.Traversable (class Traversable)
import Data.TraversableWithIndex (class TraversableWithIndex)

newtype Identity a = Identity a

Expand Down Expand Up @@ -55,9 +48,6 @@ derive instance ord1Identity :: Ord1 Identity

derive instance functorIdentity :: Functor Identity

instance functorWithIndexIdentity :: FunctorWithIndex Unit Identity where
mapWithIndex f (Identity a) = Identity (f unit a)

instance invariantIdentity :: Invariant Identity where
imap = imapF

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

instance comonadIdentity :: Comonad Identity where
extract (Identity x) = x

instance foldableIdentity :: Foldable Identity where
foldr f z (Identity x) = f x z
foldl f z (Identity x) = f z x
foldMap f (Identity x) = f x

instance foldable1Identity :: Foldable1 Identity where
foldMap1 f (Identity x) = f x
foldl1 _ (Identity x) = x
foldr1 _ (Identity x) = x

instance foldableWithIndexIdentity :: FoldableWithIndex Unit Identity where
foldrWithIndex f z (Identity x) = f unit x z
foldlWithIndex f z (Identity x) = f unit z x
foldMapWithIndex f (Identity x) = f unit x

instance traversableIdentity :: Traversable Identity where
traverse f (Identity x) = Identity <$> f x
sequence (Identity x) = Identity <$> x

instance traversable1Identity :: Traversable1 Identity where
traverse1 f (Identity x) = Identity <$> f x
sequence1 (Identity x) = Identity <$> x

instance traversableWithIndexIdentity :: TraversableWithIndex Unit Identity where
traverseWithIndex f (Identity x) = Identity <$> f unit x