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 1818 " package.json"
1919 ],
2020 "dependencies" : {
21- "purescript-arrays" : " *" ,
22- "purescript-monoid" : " *"
21+ "purescript-arrays" : " ~0.2.0" ,
22+ "purescript-monoid" : " *" ,
23+ "purescript-control" : " ~0.2.0"
2324 }
2425}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module Data.Tuple where
22
33import Data.Array
44import Data.Monoid
5+ import Control.Lazy
56
67data Tuple a b = Tuple a b
78
@@ -27,11 +28,20 @@ instance applicativeTuple :: (Monoid a) => Applicative (Tuple a) where
2728 pure = Tuple mempty
2829
2930instance 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
3132 Tuple a2 c -> Tuple (a1 <> a2) c
3233
3334instance monadTuple :: (Monoid a ) => Monad (Tuple a )
3435
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+
3545fst :: forall a b . Tuple a b -> a
3646fst (Tuple a _) = a
3747
You can’t perform that action at this time.
0 commit comments