| I would think the easiest way to go about this would be to extend the
| rules pragma.
| 
| {-# RULES "shift/const-inline"  forall x y# . shift x y# = ... #-}
| 
| where variables ending in # will only match constants known at compile time

Interesting idea.  GHC can do that *internally* using a "BuiltinRule", and it's 
internal precisely because there's no obvious way to say "match only a literal".

I suppose that you might also want to say "match only a constructor"?  To have 
a rule for 'f' that would fire only when you saw
                f (Just x)
or              f Nothing
but not f (g y)

For that, a # would not really be appropriate.  


Would this be valuable?  If so, think of a nice syntax.  It's not trivial to 
implement, but not hard either.

Simon

| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
| On Behalf Of John Meacham
| Sent: 18 October 2006 06:37
| To: glasgow-haskell-users@haskell.org
| Subject: Re: [Haskell] Expecting more inlining for bit shifting
| 
| On Mon, Oct 09, 2006 at 03:54:41PM +0100, Ian Lynagh wrote:
| > It might be possible, but it sounds tricky. I guess it would have to go
| > something like "try inlining this, run the simplifier, see if it got
| > small enough, if not back out", which could waste a lot of work if it
| > fails in lots of cases.
| 
| I would think the easiest way to go about this would be to extend the
| rules pragma.
| 
| {-# RULES "shift/const-inline"  forall x y# . shift x y# = ... #-}
| 
| where variables ending in # will only match constants known at compile
| time. or perhaps..
| 
| {-# RULES "shift/const-inline"  forall x (y::const Int) . shift x y# = ... #-}
| 
| or something like that.
| 
| I imagine such a thing would have other uses as well...
| 
|         John
| 
| --
| John Meacham - ⑆repetae.net⑆john⑈
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to