
Simon Marlow
I needed maybeRight just the other day, as a matter of fact.
timeout n m | n < 0 = fmap Just m | n == 0 = return Nothing | otherwise = do r <- race (threadDelay n) m case r of Left _ -> return Nothing Right a -> return (Just a)
would have been
timeout n m | n < 0 = fmap Just m | n == 0 = return Nothing | otherwise = fmap maybeRight $ race (threadDelay n) m
(I'd rather not use `either`, it's one of those functions whose type I always have to look up)
Use (|||) from Control.Arrow instead. The thing on the left is applied to Lefts, the thing on the right to Rights.
In general, I feel we have a fondness for a few too many near-trivial one-liners that make libraries bigger and harder to navigate, without really adding much expressivity.
I have a lot of sympathy for this view. Hence, only
+0.3
and at most -1 from me, naturally. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk