Gabriella439 / Haskell-Pipes-Safe-Library

Safety for the pipes ecosystem
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

Use Proxy instead of too polymorphic Effect' synonym #4

Closed k0001 closed 11 years ago

k0001 commented 11 years ago

GHC fails with the following error, otherwise:

Pipes/Safe.hs:201:12:
    Couldn't match type `Proxy x' x y' y m r'
                  with `forall x'1 x1 y'1 y1. Proxy x'1 x1 y'1 y1 m r'
    Expected type: Effect' m r -> Proxy x' x y' y m r
      Actual type: Proxy x' x y' y m r -> Proxy x' x y' y m r
    In the expression: _promptly
    In an equation for `promptly': promptly = _promptly
Gabriella439 commented 11 years ago

Actually, all you have to do is change Effect' to Effect. You probably got the error because I just swapped the polymorphic and concrete type synonyms and haven't gotten a chance to fix the downstream libraries just yet.

k0001 commented 11 years ago

I thought you would prefer the most polymorphic alternative, since Effect' is quite polymorphic by itself. But then, I completely missed your rename, and thus the fact that you never meant it to be so polymorphic. I've added a new commit fixing this.

Gabriella439 commented 11 years ago

The trick is that any time you have a pipe as the argument of a function, you should use a concrete type (i.e. no apostrophe) and when it is the result it can use the polymorphic type (i.e. apostrophe). So in this case the most general type is:

promptly :: Effect m r -> Effect' m r

To see another example of this trick, check out the zip function from Pipes.Prelude, which has type:

zip :: (Monad m)
    => (() -> Producer a m r)
    => (() -> Producer b m r)
    => (() -> Producer' (a, b) m r)

Also, I think your pull request is not current with HEAD because github won't let me merge this automatically. You can either issue a new pull request off the new HEAD or pull in the latest changes from HEAD so that I can merge this in, whichever you prefer.

k0001 commented 11 years ago

Oops, that didn't occur to me. Thanks for mentioning it.

And about these commits not being able to be merged with master, well, that was my mistake. I should have made the pull request against the 4.0.0 branch. I'll close this and open another one doing what you suggest.

k0001 commented 11 years ago

OK, nevermind. Ignore all this discussion. It seems the 4.0.0 branch I was working on is old, and master has the most recent development and builds just fine. So, nothing in this pull-request matters, sorry for wasting your time.

Gabriella439 commented 11 years ago

No apologies necessary! :)