Transmitting Haskell values

Hal Daume III hdaume at ISI.EDU
Tue Oct 28 09:20:07 EST 2003


> What sent me first into deep confusion is that I found all of
> {Text,GHC}.{Read,Show} first, and the Read classes marked as 
> "nonportable GHC extensions". Quite disheartening :-(
> Well, then I found the Prelude definition (though it's entirely unclear 
> how they relate to the Text and GHC versions).

The GHC versions are simply more efficient versions.  Show and Read are 
completely portable.

> Hmm... I can write out functions using the "Show (a -> b)" instance, but
> there's no matching "Read (a -> b)".

Show (a -> b) is a bogus instances -- you won't actually be able to use it 
for marshalling functions.

> > Or you could use the Binary class to get binary representations, but
> > these (sometimes, depending on which implementation you use) have
> > endianness issues if you're transmitting between different
> > architectures.
> I didn't find Binary in my GHC 6.0.1 distro. Is it a library that I have
> to install as an add-on?

I have a version on my web page:
you want Binary.hs from there, as well as FastMutInt.lhs.  Unfortunately, 
these are GHC-specific, though they are a port of the Binary library from 
NHC.  My version adds support for bit operations and is just an addition 
to the original port by Simon Marlow.  Still can't do functions though -- 
you need internal compiler support for that.

> In all, I'm finding it rather difficult to find my way in the 
> documentation (just as a data point for the documentation folks).
> To make the critique helpful instead of just a critique, here are a few 
> ideas of what might have helped me (YMMV):

I like going to google and searching for ' haddock Show' 
or something like that.  I find it's a reasonable way to find things, 
though of course not perfect.

> 2. Remove the split between "type/class index" and "function/constructor 
> index" in the Haddockish doc-index.html file. For newbies like me, the 

I agree :); or perhaps have the split as well as a big index without the 

 - Hal

 Hal Daume III                                   | hdaume at
 "Arrest this man, he talks in maths."           |

More information about the Glasgow-haskell-users mailing list