Last active
June 25, 2020 16:32
-
-
Save cohei/a47ed793f5143c165e8e to your computer and use it in GitHub Desktop.
Ruby's tap in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Functor | |
tap :: Functor f => a -> (a -> f b) -> f a | |
x `tap` action = x <$ action x | |
-- Only standard output | |
-- >>> print 1 | |
-- 1 | |
-- Standard output and return value | |
-- >>> 1 `tap` print | |
-- 1 | |
-- 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment