Add IEach interface
This commit is contained in:
parent
f2e172678a
commit
451d7b2233
7 changed files with 71 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue