mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-18 16:51:51 +03:00
[ base ] Implement Foldable
and Traversable
for Identity
This commit is contained in:
parent
60ddcd0e07
commit
2bd88b7d31
@ -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`.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user