Skip to content

Commit 96069c9

Browse files
Roxxikpaf31
authored andcommitted
removed IndexedShop (#52)
* removed IndexedShop * fixed imports * added test * test uses clone now
1 parent 772540c commit 96069c9

File tree

4 files changed

+13
-25
lines changed

4 files changed

+13
-25
lines changed

src/Data/Lens/Internal/IndexedShop.purs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Data/Lens/Lens.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Data.Lens.Lens
1414
import Prelude
1515

1616
import Data.Lens.Internal.Shop (Shop(..))
17-
import Data.Lens.Internal.IndexedShop (IndexedShop(..))
1817
import Data.Lens.Internal.Indexed (Indexed(..))
1918
import Data.Lens.Types
2019
( Lens, Lens', ALens, ALens'
@@ -50,7 +49,7 @@ ilens get set = ilens' \s -> Tuple (get s) \b -> set s b
5049

5150
withIndexedLens :: forall i s t a b r.
5251
(AnIndexedLens i s t a b) -> ((s -> (Tuple i a)) -> (s -> b -> t) -> r) -> r
53-
withIndexedLens l f = case l (Indexed (IndexedShop id \_ b -> b)) of IndexedShop x y -> f x y
52+
withIndexedLens l f = case l (Indexed (Shop id \_ b -> b)) of Shop x y -> f x y
5453

5554
cloneIndexedLens :: forall i s t a b. AnIndexedLens i s t a b -> IndexedLens i s t a b
5655
cloneIndexedLens l = withIndexedLens l \x y p -> ilens x y p

src/Data/Lens/Types.purs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module Data.Lens.Types
44
, module Data.Lens.Internal.Exchange
55
, module Data.Lens.Internal.Market
66
, module Data.Lens.Internal.Shop
7-
, module Data.Lens.Internal.IndexedShop
87
, module Data.Lens.Internal.Tagged
98
, module Data.Lens.Internal.Forget
109
, module Data.Lens.Internal.Wander
@@ -18,12 +17,12 @@ import Data.Lens.Internal.Indexed (Indexed(..))
1817
import Data.Lens.Internal.Market (Market(..))
1918
import Data.Lens.Internal.Re (Re(..))
2019
import Data.Lens.Internal.Shop (Shop(..))
21-
import Data.Lens.Internal.IndexedShop (IndexedShop(..))
2220
import Data.Lens.Internal.Tagged (Tagged(..))
2321
import Data.Lens.Internal.Wander (class Wander, wander)
2422
import Data.Profunctor (class Profunctor)
2523
import Data.Profunctor.Choice (class Choice)
2624
import Data.Profunctor.Strong (class Strong)
25+
import Data.Tuple
2726

2827
-- | A general-purpose Data.Lens.
2928
type Optic p s t a b = p a b -> p s t
@@ -47,7 +46,7 @@ type ALens' s a = ALens s s a a
4746
type IndexedLens i s t a b = forall p. Strong p => IndexedOptic p i s t a b
4847
type IndexedLens' i s a = IndexedLens i s s a a
4948

50-
type AnIndexedLens i s t a b = IndexedOptic (IndexedShop i a b) i s t a b
49+
type AnIndexedLens i s t a b = IndexedOptic (Shop (Tuple i a) b) i s t a b
5150
type AnIndexedLens' i s a = AnIndexedLens i s s a a
5251

5352
-- | A prism.

test/Main.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Prelude
44

55
import Data.Lens (view, traversed, _1, _2, _Just, _Left, lens)
66
import Data.Lens.Index (ix)
7+
import Data.Lens.Setter (iover)
8+
import Data.Lens.Lens (ilens, IndexedLens, cloneIndexedLens)
79
import Data.Lens.Fold ((^?))
810
import Data.Lens.Zoom (Traversal, Traversal', Lens, Lens', zoom)
911
import Data.Tuple (Tuple(..))
@@ -53,8 +55,16 @@ stateTest :: Tuple Int String
5355
stateTest = evalState go (Tuple 4 ["Foo", "Bar"]) where
5456
go = Tuple <$> zoom _1 get <*> zoom (_2 <<< traversed) get
5557

58+
--test cloning of indexed lenses
59+
cloneTest :: Tuple Int Int
60+
cloneTest = iover (cloneIndexedLens i_2) (+) (Tuple 1 2)
61+
62+
i_2 :: forall i a b. IndexedLens i (Tuple i a) (Tuple i b) a b
63+
i_2 = ilens id \(Tuple i _) b -> Tuple i b
64+
5665
main :: forall e. Eff (console :: CONSOLE | e) Unit
5766
main = do
5867
logShow $ view bars doc
5968
logShow $ doc2 ^? _1bars
6069
logShow stateTest
70+
logShow cloneTest

0 commit comments

Comments
 (0)