Skip to content

Commit

Permalink
[ base ] Implement Foldable and Traversable for Identity
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Aug 19, 2024
1 parent 60ddcd0 commit 8d81468
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_NEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ This CHANGELOG describes the merged but unreleased changes. Please see [CHANGELO

* Export `System.Signal.signalCode` and `System.Signal.toSignal`.

* Added implementations of `Foldable` and `Traversable` for `Control.Monad.Identity`

#### Contrib

* `Data.List.Lazy` was moved from `contrib` to `base`.
Expand Down
13 changes: 13 additions & 0 deletions libs/base/Control/Monad/Identity.idr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public export
Monad Identity where
(Id x) >>= k = k x

public export
Foldable Identity where
foldr f init (Id x) = f x init
foldl f init (Id x) = f init x
null _ = False
foldlM f init (Id x) = f init x
toList (Id x) = [x]
foldMap f (Id x) = f x

public export
Traversable Identity where
traverse f (Id x) = Id <$> f x

public export
Show a => Show (Identity a) where
showPrec d (Id x) = showCon d "Id" $ showArg x
Expand Down

0 comments on commit 8d81468

Please sign in to comment.