This is why the `Producer` type synonym exists, because the
polymorphic`Producer'` type synonym does not play well as a field within
a larger type. The correct way to do this is to change the type to:
procMessage = undefined :: (StateT (GlobalState, Producer ByteString
IO ()) IO) (Maybe r)
To answer your question about the error, the issue is that `ghc` is
automatically lifting the forall to the top level before matching on
types, so it infers that your code has this type:
forall x' x . StateT (GlobalState, Proxy x' x ByteString m ()) IO Bool
... whereas the type signature you gave is equivalent to:
StateT (GlobalState, forall x' x . Proxy x' x ByteString m ()) IO Bool
Those two types are not the exact same thing, and that's what the type
error was trying to tell you.
This is the reason why `Parser`s (from `pipes-parse`) store a
non-universally quantified `Producer` (with no apostrophe) in the
`StateT`, because of this issue with polymorphism.
Also, if you haven't read it already, you should check out the first
appendix of the `pipes` tutorial, which goes into detail about when to
use each kind of type synonym:
http://hackage.haskell.org/package/pipes-4.1.1/docs/Pipes-Tutorial.html#g:9
The second error you got is that you misspelled `handshakeInfo`. You
accidentally spelled it as `handshaekInfo` (the `a` and `e` are backwards).
On 4/16/14, 1:38 PM, Kai Wang wrote:
Hi:
I've been trying to write something in pipes.
https://gist.github.com/accelas/10929044
GHC keeps giving me this error:
Couldn't match type `forall x' x. Proxy x' x () ByteString IO ()'
with `Proxy x'0 x1 () ByteString m0 ()'
Expected type: StateT
(GlobalState, Proxy x'0 x1 () ByteString m0 ()) IO Bool
Actual type: StateT
(GlobalState, Producer' ByteString IO ()) IO Bool
In the first argument of ``runStateT` st', namely `procHandshake'
In a stmt of a 'do' block:
(res, nSt) <- (`runStateT` st) procHandshake
In the expression:
do { let st
= (,) (GlobalState conf sock 0) ((fromSocket sock 4096));
(res, nSt) <- (`runStateT` st) procHandshake;
when res
$ do { rThread <- async $ void $ (`runStateT` nSt) $
procMessage;
aThread <- async $ app reqOut;
.... } }
Why is that GHC can't infer `forall x' x. Proxy x' x () ByteString IO
()' is `Proxy x'0 x1 () ByteString m0 ()'
And why GHC couldn't compile "zoom _1" part of the code? If I
uncomment that part,
GHC now complains:
Not in scope: `handshaekInfo'
Perhaps you meant one of these:
`handshakeInfo' (line 41), `_handshakeInfo' (line 37)
Can anyone give me a hint?
Cheers,
Kai
--
You received this message because you are subscribed to the Google
Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
--
You received this message because you are subscribed to the Google Groups "Haskell
Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].