New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement iforM and iforM_ (#262) #311
Conversation
LGTM Also I vaguely remember that GHC required fully saturated application to inline. So |
Right, I copypasted the definition of |
Sorry. I take that back. :) You forgot |
Good catch! |
Amended PR LGTM. @lehins @Bodigrim could any of you take a look it just in case. I already almost missed Primitive reexport No it seems GHC is good with current definition. Toy benchmark sees no difference: import qualified Data.Vector as V
import Criterion.Main
fun1 :: (Int -> IO ()) -> IO ()
{-# NOINLINE fun1 #-}
fun1 = V.forM_ (V.generate 4000 id)
fun2 :: (Int -> IO ()) -> IO ()
{-# NOINLINE fun2 #-}
fun2 = \f -> V.forM_ (V.generate 4000 id) f
main :: IO ()
main = defaultMain
[ bench "1" $ whnfIO (fun1 (\i -> return ()))
, bench "2" $ whnfIO (fun2 (\i -> return ()))
] -O0
-O
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Sorry for succumbing to unholy nitpicking.
Looks great. All comments are addressed. @fumieval Thank you! |
Thank you guys too for swift feedbacks! |
Added iforM and iforM_, indexed variants of
forM
andforM_