File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 16
16
17
17
instance bindTuple :: (Semigroup a) => Bind (Tuple a)
18
18
19
+ instance comonadTuple :: Comonad (Tuple a)
20
+
19
21
instance eqTuple :: (Eq a, Eq b) => Eq (Tuple a b)
20
22
23
+ instance extendTuple :: Extend (Tuple a)
24
+
21
25
instance functorTuple :: Functor (Tuple a)
22
26
27
+ instance lazyLazy1Tuple :: (Lazy1 l1, Lazy1 l2) => Lazy (Tuple (l1 a) (l2 b))
28
+
29
+ instance lazyLazy2Tuple :: (Lazy2 l1, Lazy2 l2) => Lazy (Tuple (l1 a b) (l2 c d))
30
+
31
+ instance lazyTuple :: (Lazy a, Lazy b) => Lazy (Tuple a b)
32
+
23
33
instance monadTuple :: (Monoid a) => Monad (Tuple a)
24
34
35
+ instance monoidTuple :: (Monoid a, Monoid b) => Monoid (Tuple a b)
36
+
25
37
instance ordTuple :: (Ord a, Ord b) => Ord (Tuple a b)
26
38
39
+ instance semigroupTuple :: (Semigroup a, Semigroup b) => Semigroup (Tuple a b)
40
+
41
+ instance semigroupoidTuple :: Semigroupoid Tuple
42
+
27
43
instance showTuple :: (Show a, Show b) => Show (Tuple a b)
28
44
29
45
Original file line number Diff line number Diff line change 1
1
module Data.Tuple where
2
2
3
+ import Control.Comonad
4
+ import Control.Extend
5
+ import Control.Lazy
6
+
3
7
import Data.Array
4
8
import Data.Monoid
5
- import Control.Lazy
6
9
7
10
data Tuple a b = Tuple a b
8
11
@@ -18,6 +21,15 @@ instance ordTuple :: (Ord a, Ord b) => Ord (Tuple a b) where
18
21
EQ -> compare b1 b2
19
22
other -> other
20
23
24
+ instance semigroupoidTuple :: Semigroupoid Tuple where
25
+ (<<<) (Tuple _ c) (Tuple a _) = Tuple a c
26
+
27
+ instance semigroupTuple :: (Semigroup a , Semigroup b ) => Semigroup (Tuple a b ) where
28
+ (<>) (Tuple a1 b1) (Tuple a2 b2) = Tuple (a1 <> a2) (b1 <> b2)
29
+
30
+ instance monoidTuple :: (Monoid a , Monoid b ) => Monoid (Tuple a b ) where
31
+ mempty = Tuple mempty mempty
32
+
21
33
instance functorTuple :: Functor (Tuple a ) where
22
34
(<$>) f (Tuple x y) = Tuple x (f y)
23
35
@@ -33,6 +45,12 @@ instance bindTuple :: (Semigroup a) => Bind (Tuple a) where
33
45
34
46
instance monadTuple :: (Monoid a ) => Monad (Tuple a )
35
47
48
+ instance extendTuple :: Extend (Tuple a ) where
49
+ (<<=) f t@(Tuple a b) = Tuple a (f t)
50
+
51
+ instance comonadTuple :: Comonad (Tuple a ) where
52
+ extract = snd
53
+
36
54
instance lazyTuple :: (Lazy a , Lazy b ) => Lazy (Tuple a b ) where
37
55
defer f = Tuple (defer $ \_ -> fst (f unit)) (defer $ \_ -> snd (f unit))
38
56
You can’t perform that action at this time.
0 commit comments