Closed ElvishJerricco closed 8 years ago
This is intentional, for performance reasons, and the design choice is documented in the module header of Pipes.Internal
: https://hackage.haskell.org/package/pipes-4.2.0/docs/Pipes-Internal.html
The law-abiding solution is to make Proxy
equivalent to something like this:
data ProxyF a' a b' b x = Request a' (a -> x) | Respond b (b' -> x)
type Proxy a' a b' b = FreeT (ProxyF a' a b' b)
... where FreeT
is the one from the free
library
The public pipes
API (i.e. everything except Pipes.Internal
) doesn't expose a way to detect the law violation and the speed-up from this internal "cheating" is significant.
Cool. I figured.
The simplest example is this:
lift (return a)
should equalreturn a
. But, withProxy
,lift
returns anM _
, andreturn
returnsPure
. The free monad transformer falls to the same problem (which I'm sure you're aware of, as I believe you created that transformer; EDIT: "you" being Gabriel Gonzalez), so I'm tempted to say the solution would be similar toFree
's.That said, it could be a matter of observability. I'm not sure if it's actually possible to observe the difference, since I don't believe the constructors of
Proxy
are exported to external libraries. I just thought it was worth bringing up, in case it hadn't been noticed yet.