Skip to content

Commit ceedc5e

Browse files
authored
Merge pull request #43 from tslawler/patch-1
Add `mapping`, `dimapping` Isos
2 parents 945dd02 + 3f27cef commit ceedc5e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Data/Lens/Iso.purs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- | This module defines functions for working with isomorphisms.
22
module Data.Lens.Iso
3-
( iso, withIso, cloneIso, re, au, auf, under, curried, uncurried, flipped
3+
( iso, withIso, cloneIso, re, au, auf, under, curried, uncurried, flipped, mapping, dimapping
44
, module Data.Lens.Types
55
) where
66

@@ -45,3 +45,10 @@ uncurried = iso uncurry curry
4545

4646
flipped :: forall a b c d e f. Iso (a -> b -> c) (d -> e -> f) (b -> a -> c) (e -> d -> f)
4747
flipped = iso flip flip
48+
49+
mapping :: forall s t a b f g. (Functor f, Functor g) => AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
50+
mapping l = withIso l \sa bt -> iso (map sa) (map bt)
51+
52+
dimapping :: forall s ss t tt a aa b bb p q
53+
. (Profunctor p, Profunctor q) => AnIso s t a b -> AnIso ss tt aa bb -> Iso (p a ss) (q b tt) (p s aa) (q t bb)
54+
dimapping f g = withIso f \sa bt -> withIso g \ssaa bbtt -> iso (dimap sa ssaa) (dimap bt bbtt)

0 commit comments

Comments
 (0)