Could the type synonym for Parser in Pipes.Parse be incorrect?

It's as follows:
type Parser a m r = forall x. StateT 
<http://hackage.haskell.org/package/mtl-2.1.2/docs/Control-Monad-State-Strict.html#t:StateT>
 
(Producer 
<http://hackage.haskell.org/package/pipes-4.1.0/docs/Pipes-Core.html#t:Producer>
 
a m x) m r

It should maybe be:
type Parser a m = forall x. StateT (Producer a m x) m

On Wednesday, July 2, 2014 4:02:48 PM UTC+10, Gabriel Gonzalez wrote:

You were on the right track with your first approach. The only issue is 
that Haskell requires that all type synonyms are fully saturated. You 
defined your type synonym to take two parameters, `m` and `r`, so Haskell 
complained when you only partially applied it to just `m` in the type for 
`processHandshake`.

Fortunately, the solution is really simple: just leave out the `r` in the 
definition of `ServerState`:

type ServerState m = Parser ByteString (ErrorT ServerPipelineException m)

That's equivalent, but more generally useful, since you can now apply it to 
only `m`.

This is also the same reason that `pipes` defines `Producer` like this:

type Producer b = Proxy X () () b

... and not like this:

type Producer b m r = Proxy X () () b m r


On 7/1/14, 10:46 PM, Kyle Van Berendonck wrote:


Hi, 


I'm using mtl and pipes-parse. 


I have the following: 

type ServerState m r = Parser ByteString (ErrorT ServerPipelineException m) 
r 


When I try and put it in a pipe though, like so: 


processHandshake :: Monad m => Pipe InboundPacketHandshake 
OutboundPacketHandshake (ServerState m) () 


I get this error: 



Type synonym ‘ServerState’ should have 2 arguments, but has been given 1
In the type signature for ‘processHandshake’:
processHandshake :: Monad m =>
Pipe InboundPacketHandshake OutboundPacketHandshake (ServerState m) () 


But, if I bring the () inside the ServerState, I get: 


The third argument of ‘Pipe’ should have kind ‘* -> *’,
but ‘ServerState m ()’ has kind ‘*’
In the type signature for ‘processHandshake’:
processHandshake :: Monad m =>
Pipe InboundPacketHandshake OutboundPacketHandshake (ServerState m ()) 


I'm confused. How do I layer arbitrary numbers of transformers inside 
pipes? 
-- 
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] <javascript:>.
To post to this group, send email to [email protected] 
<javascript:>.

-- 
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].

Reply via email to