Skip to content
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

Missing pipes fusion #23

Open
kvanbere opened this issue Mar 8, 2014 · 2 comments
Open

Missing pipes fusion #23

kvanbere opened this issue Mar 8, 2014 · 2 comments

Comments

@kvanbere
Copy link

kvanbere commented Mar 8, 2014

Lots of functions in pipes-network do not implement fusion.

Looking at the source files, it would be really clumsy (with lots of code duplication or strange naming and force inlines..) to try and implement them now, BUT I was talking with @Gabriel439 and maybe we can get a for' variant of for, which tells pipes automatic general fusion is safe, thus doing all the work for us.

@Gabriella439
Copy link
Contributor

To clarify what @kvanberendonck means, the for rewrite rules are guaranteed to be true if the body of the loop does not request/await, so we could provide a Pipes.Internal version of for, which type restricts the second argument, like this:

for' :: Monad m
    => Proxy x' x b' b m a'
    -> (b -> Proxy X u c' c m b')
    -> Proxy x' x c' c m a'
for' p f = p //> (closed \>\ f)

{-# RULES "for' p f" forall p f . p >-> for' cat f = for' p f #-}

I just need to make sure that fusion still fires if we use this approach because @kvanberendonck has identified some cases where pipes that are implemented in terms of fusible pipe are not triggering shortcut fusion.

@k0001
Copy link
Owner

k0001 commented Mar 8, 2014

Thank for mentioning this. I admit I haven't paid incredible attention to the recent discussions about pipes fusion, but I'd be happy to make the internals of pipes-network a bit uglier if that's what we need in order to guarantee pipes fusion. However, I'd rather wait for @Gabriel439's for' and see if that makes the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants