[Haskell-cafe] Printing and Referential transparency excuse
Cristian Baboi
cristian.baboi at gmail.com
Tue Dec 25 05:49:02 EST 2007
On Tue, 25 Dec 2007 11:05:59 +0200, Derek Elkins
<derek.a.elkins at gmail.com> wrote:
> On Mon, 2007-12-24 at 11:15 +0200, Cristian Baboi wrote:
>> How can I define a function to do the inverse operation ?
>> g :: String -> ( a -> b )
>>
>> This time I cannot see how referential transparency will deny it.
>> What's the excuse now ?
>
> Referential transparency has nothing to with this. The problem here is
> parametricity. However, if you give a non-parametric type (or add
> appropriate class constraints on a and b, or add (phantom) type
> information to the input), e.g. String -> (Int -> Int) then there is no
> trouble at all.
>
Thank you.
I finished reading the Haskell Language Report and I noticed that the
class Show and Read are "toys".
I'll try to define some String -> (a -> b) functions some other time.
I wonder if parametricity is the only problem.
I guess that I'll have some problem with the arity of the result, but
currying may help.
More information about the Haskell-Cafe
mailing list