... |
... |
@@ -133,39 +133,39 @@ class (forall a. Functor (p a)) => Bifunctor p where |
133
|
133
|
second = bimap id
|
134
|
134
|
|
135
|
135
|
|
136
|
|
--- | Class laws for tuples hold only up to laziness. Both
|
137
|
|
--- 'first' 'id' and 'second' 'id' are lazier than 'id' (and 'fmap' 'id'):
|
|
136
|
+-- | Tuple instances have the same laziness as for 'Functor'. Both
|
|
137
|
+-- 'first' 'id' and 'second' 'id' have the same laziness as 'id' (and 'fmap' 'id'):
|
138
|
138
|
--
|
139
|
|
--- >>> first id (undefined :: (Int, Word)) `seq` ()
|
140
|
|
--- ()
|
141
|
|
--- >>> second id (undefined :: (Int, Word)) `seq` ()
|
142
|
|
--- ()
|
|
139
|
+-- >>> first id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()
|
|
140
|
+-- *** Exception: error!
|
|
141
|
+-- >>> second id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()
|
|
142
|
+-- *** Exception: error!
|
143
|
143
|
-- >>> id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()
|
144
|
144
|
-- *** Exception: error!
|
145
|
145
|
--
|
146
|
146
|
-- @since 4.8.0.0
|
147
|
147
|
instance Bifunctor (,) where
|
148
|
|
- bimap f g ~(a, b) = (f a, g b)
|
|
148
|
+ bimap f g (a, b) = (f a, g b)
|
149
|
149
|
|
150
|
150
|
-- | @since 4.8.0.0
|
151
|
151
|
instance Bifunctor ((,,) x1) where
|
152
|
|
- bimap f g ~(x1, a, b) = (x1, f a, g b)
|
|
152
|
+ bimap f g (x1, a, b) = (x1, f a, g b)
|
153
|
153
|
|
154
|
154
|
-- | @since 4.8.0.0
|
155
|
155
|
instance Bifunctor ((,,,) x1 x2) where
|
156
|
|
- bimap f g ~(x1, x2, a, b) = (x1, x2, f a, g b)
|
|
156
|
+ bimap f g (x1, x2, a, b) = (x1, x2, f a, g b)
|
157
|
157
|
|
158
|
158
|
-- | @since 4.8.0.0
|
159
|
159
|
instance Bifunctor ((,,,,) x1 x2 x3) where
|
160
|
|
- bimap f g ~(x1, x2, x3, a, b) = (x1, x2, x3, f a, g b)
|
|
160
|
+ bimap f g (x1, x2, x3, a, b) = (x1, x2, x3, f a, g b)
|
161
|
161
|
|
162
|
162
|
-- | @since 4.8.0.0
|
163
|
163
|
instance Bifunctor ((,,,,,) x1 x2 x3 x4) where
|
164
|
|
- bimap f g ~(x1, x2, x3, x4, a, b) = (x1, x2, x3, x4, f a, g b)
|
|
164
|
+ bimap f g (x1, x2, x3, x4, a, b) = (x1, x2, x3, x4, f a, g b)
|
165
|
165
|
|
166
|
166
|
-- | @since 4.8.0.0
|
167
|
167
|
instance Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) where
|
168
|
|
- bimap f g ~(x1, x2, x3, x4, x5, a, b) = (x1, x2, x3, x4, x5, f a, g b)
|
|
168
|
+ bimap f g (x1, x2, x3, x4, x5, a, b) = (x1, x2, x3, x4, x5, f a, g b)
|
169
|
169
|
|
170
|
170
|
|
171
|
171
|
-- | @since 4.8.0.0
|