@@ -5,12 +5,14 @@ import Prelude
5
5
6
6
import Data.Either (Either (..))
7
7
import Data.Eq (class Eq1 )
8
+ import Data.Foldable (class Foldable )
8
9
import Data.Newtype (class Newtype )
9
10
import Data.Ord (class Ord1 )
10
11
import Data.Profunctor (class Profunctor )
11
12
import Data.Profunctor.Choice (class Choice )
12
13
import Data.Profunctor.Closed (class Closed )
13
14
import Data.Profunctor.Costrong (class Costrong )
15
+ import Data.Traversable (class Traversable )
14
16
import Data.Tuple (Tuple (..))
15
17
16
18
newtype Tagged a b = Tagged b
@@ -23,6 +25,8 @@ instance eq1Tagged :: Eq1 (Tagged a) where eq1 = eq
23
25
derive instance ordTagged :: Ord b => Ord (Tagged a b )
24
26
instance ord1Tagged :: Ord1 (Tagged a ) where compare1 = compare
25
27
28
+ derive instance functorTagged :: Functor (Tagged a )
29
+
26
30
instance taggedProfunctor :: Profunctor Tagged where
27
31
dimap _ g (Tagged x) = Tagged (g x)
28
32
@@ -36,3 +40,12 @@ instance taggedCostrong :: Costrong Tagged where
36
40
37
41
instance taggedClosed :: Closed Tagged where
38
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