[Haskell-cafe] rewrite rules

Sjoerd Visscher sjoerd at w3future.com
Wed Jun 24 03:44:38 EDT 2009


Thanks for looking into this.

Your code does give me 2 firings. But not when I replace [] with  
FMList. See the attached code.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rules.hs
Type: application/octet-stream
Size: 773 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090624/d7fd50a0/Rules.obj
-------------- next part --------------



Sjoerd

On Jun 23, 2009, at 5:59 PM, Simon Peyton-Jones wrote:

> | I have a rewrite rule as follows:
> |
> | {-# RULES
> | "transform/transform" forall (f::forall m. Monoid m => (a -> m) ->  
> (b -
> |  > m))
> |                               (g::forall m. Monoid m => (b -> m) - 
> > (c
> | -> m))
> |                               (l::FMList c). transform f  
> (transform g
> | l) = transform (g.f) l
> |    #-}
> |
> | It fires on this code:
> |
> |    print $ transform (. (*2)) (transform (. (+1)) (upto 10))
> |
> | But it doesn't fire on this code:
> |
> |    print $ map (*2) (map (+1) (upto 10)))
>
> That's odd. It works for me.
>
> Specifically, I compiled the attached code with GHC 6.10, and I get  
> two firings of transform/transform.
>
> Does that not happen for you?
>
> Simon
>
> <Rules.hs>

--
Sjoerd Visscher
sjoerd at w3future.com





More information about the Haskell-Cafe mailing list