@@ -7,17 +7,15 @@ import Data.Lens.Index (ix)
7
7
import Data.Lens.Setter (iover )
8
8
import Data.Lens.Lens (ilens , IndexedLens , cloneIndexedLens )
9
9
import Data.Lens.Fold ((^?))
10
- import Data.Lens.Prism .Partial ((^?!))
10
+ import Data.Lens.Fold .Partial ((^?!), (^@ ?!))
11
11
import Data.Lens.Zoom (Traversal , Traversal' , Lens , Lens' , zoom )
12
12
import Data.Tuple (Tuple (..))
13
13
import Data.Maybe (Maybe (..))
14
14
import Data.Either (Either (..))
15
- import Partial.Unsafe (unsafePartial )
16
-
17
15
import Control.Monad.Eff (Eff )
18
16
import Control.Monad.Eff.Console (CONSOLE , logShow )
19
17
import Control.Monad.State (evalState , get )
20
-
18
+ import Partial.Unsafe ( unsafePartial )
21
19
22
20
-- Traversing an array nested within a record
23
21
foo :: forall a b r . Lens { foo :: a | r } { foo :: b | r } a b
@@ -34,7 +32,6 @@ doc = { foo: Just { bar: [ "Hello", " ", "World" ]} }
34
32
bars :: forall a b . Traversal (Foo a ) (Foo b ) a b
35
33
bars = foo <<< _Just <<< bar <<< traversed
36
34
37
-
38
35
-- Get the index of a deeply nested record
39
36
type BarRec = { foo :: Array (Either { bar :: Array Int } String ) }
40
37
data Bar = Bar BarRec
@@ -51,8 +48,6 @@ _0Justbar = _Bar <<< foo <<< ix 0
51
48
_1bars :: Traversal' Bar Int
52
49
_1bars = _0Justbar <<< _Left <<< bar <<< ix 1
53
50
54
-
55
-
56
51
-- Tests state using zoom
57
52
stateTest :: Tuple Int String
58
53
stateTest = evalState go (Tuple 4 [" Foo" , " Bar" ]) where
@@ -70,5 +65,6 @@ main = do
70
65
logShow $ view bars doc
71
66
logShow $ doc2 ^? _1bars
72
67
logShow $ unsafePartial $ doc2 ^?! _1bars
68
+ logShow $ unsafePartial $ Tuple 0 1 ^@?! i_2
73
69
logShow stateTest
74
70
logShow cloneTest
0 commit comments