This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module Example.Control.Lens.Each where
2+
3+ import Control.Lens
4+
5+ import Data.String
6+ import Data.Tuple
7+
8+ import Debug.Trace
9+
10+ foo :: [Number ]
11+ foo = [1,2,3] # each +~ 2
12+
13+ bar :: Tuple Number Number
14+ bar = ("Hi " ~ "everybody !") # each %~ length
15+
16+ main = do
17+ print foo
18+ print bar
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ var paths =
2323
2424var options =
2525 { test : { main : 'Test.Control.Lens'
26- , verboseErrors : true
2726 }
2827 } ;
2928
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ module Control.Lens
1818 , tail
1919 , uncons
2020 , unsnoc
21+ -- Each
22+ , each
2123 -- Equality
2224 , simple
2325 , simply
@@ -163,6 +165,7 @@ module Control.Lens
163165
164166 import qualified Control.Lens.At as At
165167 import qualified Control.Lens.Cons as Cons
168+ import qualified Control.Lens.Each as Each
166169 import qualified Control.Lens.Equality as Equality
167170 import qualified Control.Lens.Fold as Fold
168171 import qualified Control.Lens.Getter as Getter
@@ -199,6 +202,9 @@ module Control.Lens
199202 uncons = Cons. uncons
200203 unsnoc = Cons. unsnoc
201204
205+ -- Each
206+ each = Each. each
207+
202208 -- Equality
203209 simple = Equality. simple
204210 simply = Equality. simply
Original file line number Diff line number Diff line change 1+ module Control.Lens.Each where
2+
3+ import Control.Lens.Type (Traversal ())
4+
5+ import Data.Traversable (traverse )
6+ import Data.Tuple (Tuple (..))
7+
8+ class Each s t a b where
9+ each :: Traversal s t a b
10+
11+ instance eachTuple :: Each (Tuple a a ) (Tuple b b ) a b where
12+ each f (Tuple a b ) = Tuple <$> f a <*> f b
13+
14+ instance eachArray :: Each [a] [b] a b where
15+ each = traverse
Original file line number Diff line number Diff line change 9494 unsnoc :: forall a s. (Snoc s s a a) => s a -> Maybe (Tuple (s a) a)
9595
9696
97+ ## Module Control.Lens.Each
98+
99+ ### Type Classes
100+
101+ class Each s t a b where
102+ each :: Traversal s t a b
103+
104+
105+ ### Type Class Instances
106+
107+ instance eachArray :: Each [a] [b] a b
108+
109+ instance eachTuple :: Each (Tuple a a) (Tuple b b) a b
110+
111+
97112## Module Control.Lens.Equality
98113
99114### Values
You can’t perform that action at this time.
0 commit comments