File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -9,20 +9,25 @@ import Data.Profunctor.Choice
9
9
import Data.Tuple
10
10
import Data.Either
11
11
12
+ import Data.Lens.Internal.Wander
13
+
12
14
-- | Profunctor used for `IndexedOptic`s.
13
15
newtype Indexed p i s t = Indexed (p (Tuple i s ) t )
14
16
15
17
-- | Unwrap a value of type `Indexed`.
16
18
fromIndexed :: forall p i s t . Indexed p i s t -> p (Tuple i s ) t
17
19
fromIndexed (Indexed p) = p
18
20
19
- instance indexedProfunctor :: (Profunctor p ) => Profunctor (Indexed p i ) where
21
+ instance profunctorIndexed :: (Profunctor p ) => Profunctor (Indexed p i ) where
20
22
dimap f g = Indexed <<< dimap (second f) g <<< fromIndexed
21
23
22
- instance indexedStrong :: (Strong p ) => Strong (Indexed p i ) where
24
+ instance strongIndexed :: (Strong p ) => Strong (Indexed p i ) where
23
25
first = Indexed <<< dimap (\(Tuple i (Tuple a c)) -> (Tuple (Tuple i a) c)) id <<< first <<< fromIndexed
24
26
second = Indexed <<< dimap (\(Tuple i (Tuple c a)) -> (Tuple c (Tuple i a))) id <<< second <<< fromIndexed
25
27
26
- instance indexedChoice :: (Choice p ) => Choice (Indexed p i ) where
28
+ instance choiceIndexed :: (Choice p ) => Choice (Indexed p i ) where
27
29
left (Indexed p) = Indexed (dimap (\(Tuple i ac) -> either (Left <<< Tuple i) Right ac) id $ left p)
28
30
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
You can’t perform that action at this time.
0 commit comments