[Haskell-cafe] AMQP framing layer: design help requested.

Derek Elkins derek.a.elkins at gmail.com
Sat Mar 22 12:50:49 EDT 2008


On Sat, 2008-03-22 at 16:08 +0000, Paul Johnson wrote:
> Dean Herington wrote:
> > At 6:41 PM -0700 3/21/08, Adam Langley wrote:
> >>
> >> Also
> >>>    getter <- fmap (amqpGetTable !)  getWord8
> >>>    getter
> >>
> >> is just
> >>
> >>  > fmap (amqpGetTable !)  getWord8
> >
> > I don't think so.  Aren't there two "gettings": the first to get the 
> > "type" byte and the second to get the item?
> >
> Yes.  I didn't use it because it seemed obfuscated, but in fact the
> point-free version is
> 
> >  fmap (amqpGetTable !) getWord8 >>= id
> 
Nah, the point-free version wouldn't be this.  First,
join = x >>= id so
fmap (ampqGetTable !) getWord8 >>= id
=== join (fmap (ampqGetTable !) getWord8)
Next, m >>= f = join (fmap f m) so
join (fmap (ampqGetTable !) getWord8)
=== getWord8 >>= (ampqGetTable !)
This would be the point-free version

So the original code was a round-about way of saying:
do word <- getWord8; ampqGetTable ! word




More information about the Haskell-Cafe mailing list