Making rule application less fragile

Johan Tibell johan.tibell at gmail.com
Fri Mar 14 13:32:58 EDT 2008


On Fri, Mar 14, 2008 at 6:28 PM, John Meacham <john at repetae.net> wrote:
> Note also that you are attaching your rule to 'fmap', however, since
>  your rule only applies to the 'Parser' monad (if I am reading it
>  properly) then 'fmap' will have been replaced by the 'fmap' in the
>  Functor Parser instance. So you would probably be better off doing
>  something like
>
>  instance Functor Parser where
>         fmap = parserFmap
>
>  {-# RULES forall x . parserFmap S.pack ( ...

Didn't think of that. I'll change my code accordingly.

>  Also, you have to be careful attaching rules to functions you don't
>  define, as you don't know how it will interact with other rules, inline
>  pragmas or whatnot that might already be attached to that function.

Sounds like good advice.

Thanks.


More information about the Glasgow-haskell-users mailing list