RE: SpecConstr

Simon Peyton-Jones <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.all,gmane.comp.lang.haskell.cvs.ghc
Message-ID <DCA83D5F3861C941808187D4D3878750344BABA6@EA-EXMSG-C312.europe.corp.microsoft.com>
Roman, Don,

I have finally found time to fix this (see Roman's message below).  Once I found the problem it was easy to fix. Now SpecConstr should work just fine on Booleans.  I'm guessing this will also solve Don's problem alluded to here:

| Oh, this is slower than it should be, too. Those Bools get in the way of
| GHC's specConstr optimisation. Instead it shoudl use a strict Either.

(Bools never got in the way; but SpecConstr was stupid.  Forget those Eithers!)

This email may overtake my push, but the push message should be obvious

Simon

| 2. No SpecConstr for Bools
|
| foo :: Bool -> Int -> Int
| foo True  0 = 0
| foo True  n = foo True (n-1)
| foo False n = foo True n
|
| For foo we get
|
| foo b (I# n) = I# ($wfoo b n)
| $wfoo True  0 = 0
| $wfoo True  n = $wfoo True (n -# 1)
| $wfoo False n = $wfoo True n
|
| Here, we have a conditional in every iteration which is definitely not what we want! In particular, it
| prevents Bools (and, I guess, enumerations in general) from ever being used in seeds.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.