summaryrefslogtreecommitdiff
path: root/src/Data/Tuple/Optic.hs
blob: 7a790b77e34e53a38b748f1e719a004add58838f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeOperators         #-}
{-# LANGUAGE TypeFamilies          #-}
module Data.Tuple.Optic (
    curried
  , swapped
  , associated
  , t21
  , t22
  , t31
  , t32
  , t33
  , t41
  , t42
  , t43
  , t44
  , t51
  , t52
  , t53
  , t54
  , t55
) where

import Data.Profunctor.Optic.Import
import Data.Profunctor.Optic.Iso
import Data.Profunctor.Optic.Lens
import Data.Profunctor.Optic.Type

---------------------------------------------------------------------
-- Optics 
---------------------------------------------------------------------

t21 :: Lens (a,b) (a',b) a a'
t21 = lensVl $ \f ~(a,b) -> (\a' -> (a',b)) <$> f a
{-# INLINE t21 #-}

t22 :: Lens (a,b) (a,b') b b'
t22 = lensVl $ \f ~(a,b) -> (\b' -> (a,b')) <$> f b
{-# INLINE t22 #-}

t31 :: Lens (a,b,c) (a',b,c) a a'
t31 = lensVl $ \f ~(a,b,c) -> (\a' -> (a',b,c)) <$> f a
{-# INLINE t31 #-}

t32 :: Lens (a,b,c) (a,b',c) b b'
t32 = lensVl $ \f ~(a,b,c) -> (\b' -> (a,b',c)) <$> f b
{-# INLINE t32 #-}

t33 :: Lens (a,b,c) (a,b,c') c c'
t33 = lensVl $ \f ~(a,b,c) -> (\c' -> (a,b,c')) <$> f c
{-# INLINE t33 #-}

t41 :: Lens (a,b,c,d) (a',b,c,d) a a'
t41 = lensVl $ \f ~(a,b,c,d) -> (\a' -> (a',b,c,d)) <$> f a
{-# INLINE t41 #-}

t42 :: Lens (a,b,c,d) (a,b',c,d) b b'
t42 = lensVl $ \f ~(a,b,c,d) -> (\b' -> (a,b',c,d)) <$> f b
{-# INLINE t42 #-}

t43 :: Lens (a,b,c,d) (a,b,c',d) c c'
t43 = lensVl $ \f ~(a,b,c,d) -> (\c' -> (a,b,c',d)) <$> f c
{-# INLINE t43 #-}

t44 :: Lens (a,b,c,d) (a,b,c,d') d d'
t44 = lensVl $ \f ~(a,b,c,d) -> (\d' -> (a,b,c,d')) <$> f d
{-# INLINE t44 #-}

t51 :: Lens (a,b,c,d,e) (a',b,c,d,e) a a'
t51 = lensVl $ \f ~(a,b,c,d,e) -> (\a' -> (a',b,c,d,e)) <$> f a
{-# INLINE t51 #-}

t52 :: Lens (a,b,c,d,e) (a,b',c,d,e) b b'
t52 = lensVl $ \f ~(a,b,c,d,e) -> (\b' -> (a,b',c,d,e)) <$> f b
{-# INLINE t52 #-}

t53 :: Lens (a,b,c,d,e) (a,b,c',d,e) c c'
t53 = lensVl $ \f ~(a,b,c,d,e) -> (\c' -> (a,b,c',d,e)) <$> f c
{-# INLINE t53 #-}

t54 :: Lens (a,b,c,d,e) (a,b,c,d',e) d d'
t54 = lensVl $ \f ~(a,b,c,d,e) -> (\d' -> (a,b,c,d',e)) <$> f d
{-# INLINE t54 #-}

t55 :: Lens (a,b,c,d,e) (a,b,c,d,e') e e'
t55 = lensVl $ \f ~(a,b,c,d,e) -> (\e' -> (a,b,c,d,e')) <$> f e
{-# INLINE t55 #-}

---------------------------------------------------------------------
-- Optics 
---------------------------------------------------------------------