[EMAIL PROTECTED] wrote:
> > data Polar = P Int Int deriving Show
> >
> > polarToCart :: Polar -> (Int, Int)
> > polarToCart (P a b) = (a, b)
> >
> > cartToPolar :: (Int, Int) -> Polar
> > cartToPolar (a, b) = P a b
> >
> > %fun mirror :: Polar -> Polar
> > %call (< polarToCart / cartToPolar > (int x) (int y))
> > %code x = -x;
> > %     y = -y;
> > %result (< polarToCart / cartToPolar > (int x) (int y))
> 
> the error is this:
> 
> > [...]
> >
> > End of search list.
> >  [...]/2.8.1/cc1 /tmp/cca32238.i -quiet -dumpbase ghc32227.c -O -Wimplicit 
>-version -fomit-frame-pointer -fno-defer-pop -o ghc32227.s
> > GNU C version 2.8.1 (i586-pc-linux-gnu) compiled by GNU C version 2.8.1.
> > /tmp/ghc32227.hc:479: redeclaration of `x'
> > /tmp/ghc32227.hc:479: `x' previously declared here
> > /tmp/ghc32227.hc:479: redeclaration of `y'
> > /tmp/ghc32227.hc:479: `y' previously declared here
 
I believe that greencard may not be smart enough to realize that the
input variable names are the same as the output variable names. Thus, it
redeclares the same variable names twice. Try:

> %fun mirror :: Polar -> Polar
> %call (< polarToCart / cartToPolar > (int x) (int y))
> %code x_inv = -x;
> %     y_inv = -y;
> %result (< polarToCart / cartToPolar > (int x_inv) (int y_inv))


- Michael Hobbs

Reply via email to