1
1
-- | This module defines the `Tagged` profunctor
2
2
module Data.Lens.Internal.Tagged where
3
3
4
+ import Prelude
5
+
4
6
import Data.Either (Either (..))
5
- import Data.Function (const )
7
+ import Data.Eq (class Eq1 )
8
+ import Data.Foldable (class Foldable )
6
9
import Data.Newtype (class Newtype )
10
+ import Data.Ord (class Ord1 )
7
11
import Data.Profunctor (class Profunctor )
8
12
import Data.Profunctor.Choice (class Choice )
9
13
import Data.Profunctor.Closed (class Closed )
10
14
import Data.Profunctor.Costrong (class Costrong )
15
+ import Data.Traversable (class Traversable )
11
16
import Data.Tuple (Tuple (..))
12
17
13
18
newtype Tagged a b = Tagged b
14
19
15
20
derive instance newtypeTagged :: Newtype (Tagged a b ) _
16
21
22
+ derive instance eqTagged :: Eq b => Eq (Tagged a b )
23
+ instance eq1Tagged :: Eq1 (Tagged a ) where eq1 = eq
24
+
25
+ derive instance ordTagged :: Ord b => Ord (Tagged a b )
26
+ instance ord1Tagged :: Ord1 (Tagged a ) where compare1 = compare
27
+
28
+ derive instance functorTagged :: Functor (Tagged a )
29
+
17
30
instance taggedProfunctor :: Profunctor Tagged where
18
31
dimap _ g (Tagged x) = Tagged (g x)
19
32
@@ -27,3 +40,12 @@ instance taggedCostrong :: Costrong Tagged where
27
40
28
41
instance taggedClosed :: Closed Tagged where
29
42
closed (Tagged b) = Tagged (const b)
43
+
44
+ instance foldableTagged :: Foldable (Tagged a ) where
45
+ foldMap f (Tagged a) = f a
46
+ foldr f b (Tagged a) = f a b
47
+ foldl f b (Tagged a) = f b a
48
+
49
+ instance traversableTagged :: Traversable (Tagged a ) where
50
+ sequence (Tagged a) = map Tagged a
51
+ traverse f (Tagged a) = map Tagged (f a)
0 commit comments