[Haskell-cafe] some way to reverse engineer lambda expressionsout of the debugger?

Claus Reinke claus.reinke at talk21.com
Thu Jan 11 13:47:20 EST 2007


> Looks very nice!

thanks!-) 

it is far from a full-blown solution to the question in the subject, but it has its uses.
 
> However, I'm doing my learning on ghci and got an error when I tried to load it.
> 
> Is this hugs only, or should I try harder?

I was using Hugs when I wrote that, but it works in GHC almost as well. the
error message really ought to point to the option needed, which is -fglasgow-exts

if you don't want to set the options by hand, just add the following pragma to 
the top of R.hs:

{-# OPTIONS_GHC -fglasgow-exts #-}

more annoying is that ghci will ignore the default directive, so you'll need to
give explicit types when you want representations:

    *Main> foldr (+) 0 [1..4]
    10
    *Main> foldr (+) 0 [1..4] :: R Int
    (1 + (2 + (3 + (4 + 0))))
    *Main> map (*) [1,2]

    <interactive>:1:0:
        No instance for (Show (t -> t))
          arising from use of `print' at <interactive>:1:0-12
        Possible fix: add an instance declaration for (Show (t -> t))
        In the call (print it)
        In the expression: print it
        In a 'do' expression: print it
    *Main> map (*) [1,2] :: [R Int -> R Int]
    [\x->(1 * x),\x->(2 * x)]

claus
 
> 2007/1/11, Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk>:
>> Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
>>
>> > tphyahoo wrote:
>> >
>> > > *UnixTools> explodeLambda( map (*) [1,2] )
>> > >[(\x ->> 1*x),(\x -> 2*x)]
>>
>> Have a play with this, from Claus Reinke:
>>     http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/R.hs
>>
>>
>> Regards,
>>     Malcolm
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list