Portability | Rank2Types |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Infered |
- class Field1 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field2 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field3 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field4 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field5 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field6 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field7 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field8 a b c d | a -> c, b -> d, a d -> b, b c -> a where
- class Field9 a b c d | a -> c, b -> d, a d -> b, b c -> a where
Tuples
class Field1 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provides access to 1st field of a tuple.
Access the 1st field of a tuple (and possibly change its type).
>>>
import Control.Lens
>>>
(1,2)^._1
1
>>>
_1 .~ "hello" $ (1,2)
("hello",2)
This can also be used on larger tuples as well
>>>
_1 +~ 41 $ (1,2,3,4,5)
(42,2,3,4,5)
_1 ::Lens
(a,b) (a',b) a a' _1 ::Lens
(a,b,c) (a',b,c) a a' _1 ::Lens
(a,b,c,d) (a',b,c,d) a a' ... _1 ::Lens
(a,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a'
Field1 (a, b) (a', b) a a' | |
Field1 (a, b, c) (a', b, c) a a' | |
Field1 (a, b, c, d) (a', b, c, d) a a' | |
Field1 (a, b, c, d, e) (a', b, c, d, e) a a' | |
Field1 (a, b, c, d, e, f) (a', b, c, d, e, f) a a' | |
Field1 (a, b, c, d, e, f, g) (a', b, c, d, e, f, g) a a' | |
Field1 (a, b, c, d, e, f, g, h) (a', b, c, d, e, f, g, h) a a' | |
Field1 (a, b, c, d, e, f, g, h, i) (a', b, c, d, e, f, g, h, i) a a' |
class Field2 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provides access to the 2nd field of a tuple
Access the 2nd field of a tuple
>>>
import Control.Lens
>>>
_2 .~ "hello" $ (1,(),3,4)
(1,"hello",3,4)
anyOf
_2
:: (c ->Bool
) -> (a, c) ->Bool
traverse
.
_2
:: (Applicative
f,Traversable
t) => (a -> f b) -> t (c, a) -> f (t (c, b))foldMapOf
(traverse
.
_2
) :: (Traversable
t,Monoid
m) => (c -> m) -> t (b, c) -> m
Field2 (a, b) (a, b') b b' | |
Field2 (a, b, c) (a, b', c) b b' | |
Field2 (a, b, c, d) (a, b', c, d) b b' | |
Field2 (a, b, c, d, e) (a, b', c, d, e) b b' | |
Field2 (a, b, c, d, e, f) (a, b', c, d, e, f) b b' | |
Field2 (a, b, c, d, e, f, g) (a, b', c, d, e, f, g) b b' | |
Field2 (a, b, c, d, e, f, g, h) (a, b', c, d, e, f, g, h) b b' | |
Field2 (a, b, c, d, e, f, g, h, i) (a, b', c, d, e, f, g, h, i) b b' |
class Field3 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provides access to the 3rd field of a tuple
Field3 (a, b, c) (a, b, c') c c' | |
Field3 (a, b, c, d) (a, b, c', d) c c' | |
Field3 (a, b, c, d, e) (a, b, c', d, e) c c' | |
Field3 (a, b, c, d, e, f) (a, b, c', d, e, f) c c' | |
Field3 (a, b, c, d, e, f, g) (a, b, c', d, e, f, g) c c' | |
Field3 (a, b, c, d, e, f, g, h) (a, b, c', d, e, f, g, h) c c' | |
Field3 (a, b, c, d, e, f, g, h, i) (a, b, c', d, e, f, g, h, i) c c' |
class Field4 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provide access to the 4th field of a tuple
Field4 (a, b, c, d) (a, b, c, d') d d' | |
Field4 (a, b, c, d, e) (a, b, c, d', e) d d' | |
Field4 (a, b, c, d, e, f) (a, b, c, d', e, f) d d' | |
Field4 (a, b, c, d, e, f, g) (a, b, c, d', e, f, g) d d' | |
Field4 (a, b, c, d, e, f, g, h) (a, b, c, d', e, f, g, h) d d' | |
Field4 (a, b, c, d, e, f, g, h, i) (a, b, c, d', e, f, g, h, i) d d' |
class Field5 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provides access to the 5th field of a tuple
class Field6 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provides access to the 6th element of a tuple
class Field7 a b c d | a -> c, b -> d, a d -> b, b c -> a whereSource
Provide access to the 7th field of a tuple