File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 18
18
" package.json"
19
19
],
20
20
"dependencies" : {
21
- "purescript-arrays" : " *" ,
22
- "purescript-monoid" : " *"
21
+ "purescript-arrays" : " ~0.2.0" ,
22
+ "purescript-monoid" : " *" ,
23
+ "purescript-control" : " ~0.2.0"
23
24
}
24
25
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module Data.Tuple where
2
2
3
3
import Data.Array
4
4
import Data.Monoid
5
+ import Control.Lazy
5
6
6
7
data Tuple a b = Tuple a b
7
8
@@ -27,11 +28,20 @@ instance applicativeTuple :: (Monoid a) => Applicative (Tuple a) where
27
28
pure = Tuple mempty
28
29
29
30
instance bindTuple :: (Semigroup a ) => Bind (Tuple a ) where
30
- (>>=) (Tuple a1 b) f = case f b of
31
+ (>>=) (Tuple a1 b) f = case f b of
31
32
Tuple a2 c -> Tuple (a1 <> a2) c
32
33
33
34
instance monadTuple :: (Monoid a ) => Monad (Tuple a )
34
35
36
+ instance lazyTuple :: (Lazy a , Lazy b ) => Lazy (Tuple a b ) where
37
+ defer f = Tuple (defer $ \_ -> fst (f unit)) (defer $ \_ -> snd (f unit))
38
+
39
+ instance lazyLazy1Tuple :: (Lazy1 l1 , Lazy1 l2 ) => Lazy (Tuple (l1 a ) (l2 b )) where
40
+ defer f = Tuple (defer1 $ \_ -> fst (f unit)) (defer1 $ \_ -> snd (f unit))
41
+
42
+ instance lazyLazy2Tuple :: (Lazy2 l1 , Lazy2 l2 ) => Lazy (Tuple (l1 a b ) (l2 c d )) where
43
+ defer f = Tuple (defer2 $ \_ -> fst (f unit)) (defer2 $ \_ -> snd (f unit))
44
+
35
45
fst :: forall a b . Tuple a b -> a
36
46
fst (Tuple a _) = a
37
47
You can’t perform that action at this time.
0 commit comments