[Haskell-cafe] "show" for functional types
Brian Hulley
brianh at metamilk.com
Sat Apr 1 07:50:54 EST 2006
Greg Buchholz wrote:
>
> Hmm. It must be a little more complicated than that, right? Since
> after all you can print out *some* functions. That's what section 5
> of _Fun with Phantom Types_ is about. Here's a slightly different
> example, using the AbsNum module from...
>
> http://www.haskell.org/hawiki/ShortExamples_2fSymbolDifferentiation
>
>> import AbsNum
>>
>> f x = x + 2
>> g x = x + 1 + 1
>>
>> y :: T Double
>> y = Var "y"
>>
>> main = do print (f y)
>> print (g y)
>
> ...which results in...
>
> *Main> main
> (Var "y")+(Const (2.0))
> (Var "y")+(Const (1.0))+(Const (1.0))
>
> ...is this competely unrelated?
Interesting! Referential transparency (as I understand it) has indeed been
violated. Perhaps the interaction of GADTs and type classes was not
sufficiently studied before being introduced to the language.
So I'm now just as puzzled as you.
Thanks for this example,
Brian.
More information about the Haskell-Cafe
mailing list