Add IEach interface

This commit is contained in:
Kiana Sheibani 2023-10-19 14:57:35 -04:00
parent f2e172678a
commit 451d7b2233
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
7 changed files with 71 additions and 19 deletions

View file

@ -7,6 +7,7 @@ import Control.Lens.Iso
import Control.Lens.Lens
import Control.Lens.Optional
import Control.Lens.Traversal
import Control.Lens.Indexed
%default total
@ -24,6 +25,28 @@ interface Each s t a b | s where
||| containers that do not have a `Traversable` implementation.
each : Traversal s t a b
||| An interface for accessing every element of a container, providing an index.
|||
||| This can be thought of as a generalized version of `itraversed` for
||| containers that do not have a `Traversable` implementation.
public export
interface Each s t a b => IEach i s t a b | s where
||| Access every element of a container at the same time, providing an index.
|||
||| This can be thought of as a generalized version of `itraversed` for
||| containers that do not have a `Traversable` implementation.
ieach : IndexedTraversal i s t a b
public export
[Traversed] Traversable f => Each (f a) (f b) a b where
each = traversed
public export
[Ordinal] Num i => Each s t a b => IEach i s t a b where
ieach = iordinal each
public export
Each (Identity a) (Identity b) a b where