[Haskell-cafe] Serialization of (a -> b) and IO a

John Lato jwlato at gmail.com
Fri Nov 12 04:51:05 EST 2010

On Thu, Nov 11, 2010 at 10:28 PM, Dan Doel <dan.doel at gmail.com> wrote:

> On Thursday 11 November 2010 12:34:21 pm John Lato wrote:
> > I think the only way this would work would be if you consider functions
> to
> > be equal only to themselves, i.e. "x+x" and "2*x" are not equal.  That's
> > not a trade-off I would be willing to make.
> In general, it doesn't even have to be based on a mathematical identity. As
> has been stated, this would in general simply break referential
> transparency.
> Are these two functions equal:
>  f x = k (h x) (h x)
>  g x = let y = h x in k y y
> Presumably, no, if serialize exists (and they may have different
> performance
> characteristics).
> You cannot factor out or inline subexpressions or without the difference
> being
> observable (presumably) by serialize.

Yes, exactly.  Thanks for this example, because it illustrates better how
far-reaching this would be.  And it's true not just when these
transformations are manually performed, but also when they're performed by
the compiler.  Haskell without referential transparency simply wouldn't be
Haskell any more.  And any code that used a pure serialize may or may not
work, depending on compiler magic.

Of course, this is presuming that serialize is pure.  I suppose it might be
possible for a serialize with type "a -> IO ByteString" to just dump
stack+heap+whatever.  You could use TH+Hint, LLVM, or likewise to get a
similar effect now.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101112/b2e72de4/attachment.html

More information about the Haskell-Cafe mailing list