Skip to content

Commit 7d8cd11

Browse files
tslawlerpaf31
authored andcommitted
Rename instances for Indexed; add Wander instance (#30)
* Rename instances; add Wander instance Use the {className}{TypeName} convention * fix typos
1 parent c9af7b6 commit 7d8cd11

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Data/Lens/Internal/Indexed.purs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,25 @@ import Data.Profunctor.Choice
99
import Data.Tuple
1010
import Data.Either
1111

12+
import Data.Lens.Internal.Wander
13+
1214
-- | Profunctor used for `IndexedOptic`s.
1315
newtype Indexed p i s t = Indexed (p (Tuple i s) t)
1416

1517
-- | Unwrap a value of type `Indexed`.
1618
fromIndexed :: forall p i s t. Indexed p i s t -> p (Tuple i s) t
1719
fromIndexed (Indexed p) = p
1820

19-
instance indexedProfunctor :: (Profunctor p) => Profunctor (Indexed p i) where
21+
instance profunctorIndexed :: (Profunctor p) => Profunctor (Indexed p i) where
2022
dimap f g = Indexed <<< dimap (second f) g <<< fromIndexed
2123

22-
instance indexedStrong :: (Strong p) => Strong (Indexed p i) where
24+
instance strongIndexed :: (Strong p) => Strong (Indexed p i) where
2325
first = Indexed <<< dimap (\(Tuple i (Tuple a c)) -> (Tuple (Tuple i a) c)) id <<< first <<< fromIndexed
2426
second = Indexed <<< dimap (\(Tuple i (Tuple c a)) -> (Tuple c (Tuple i a))) id <<< second <<< fromIndexed
2527

26-
instance indexedChoice :: (Choice p) => Choice (Indexed p i) where
28+
instance choiceIndexed :: (Choice p) => Choice (Indexed p i) where
2729
left (Indexed p) = Indexed (dimap (\(Tuple i ac) -> either (Left <<< Tuple i) Right ac) id $ left p)
2830
right (Indexed p) = Indexed (dimap (\(Tuple i ac) -> either Left (Right <<< Tuple i) ac) id $ right p)
31+
32+
instance wanderIndexed :: (Wander p) => Wander (Indexed p i) where
33+
wander trav = Indexed <<< wander (\ia2fb (Tuple i s) -> trav (ia2fb <<< Tuple i) s) <<< fromIndexed

0 commit comments

Comments
 (0)