question about a failure to generalize
Norman Ramsey wrote: : | This code fails to compile because the compiler is willing to | use 'fold' at only one type (CmmExpr as it happens) : When it failed to compile, was fold = foldRegsUsed a top-level declaration in the module, rather than local to foldRegsUsed? If so, try working around the monomorphism restriction by changing from a pattern binding to a function binding. fold f = foldRegsUsed f Regards, Tom
On Mon, Sep 17, 2007 at 04:15:10PM +1200, Tom Pledger wrote:
Norman Ramsey wrote: : | This code fails to compile because the compiler is willing to | use 'fold' at only one type (CmmExpr as it happens) :
When it failed to compile, was
fold = foldRegsUsed
a top-level declaration in the module, rather than local to foldRegsUsed?
If so, try working around the monomorphism restriction by changing from a pattern binding to a function binding.
fold f = foldRegsUsed f
The monomorphism restriction is not affected by top-level-or-not, see sections 4.5.1 and 4.5.5 in the Haskell 98 Language and Libraries Report. Stefan
Quoting Stefan O'Rear <stefanor@cox.net>:
On Mon, Sep 17, 2007 at 04:15:10PM +1200, Tom Pledger wrote:
Norman Ramsey wrote: : | This code fails to compile because the compiler is willing to | use 'fold' at only one type (CmmExpr as it happens) :
When it failed to compile, was
fold = foldRegsUsed
a top-level declaration in the module, rather than local to foldRegsUsed?
If so, try working around the monomorphism restriction by changing from a pattern binding to a function binding.
fold f = foldRegsUsed f
The monomorphism restriction is not affected by top-level-or-not, see sections 4.5.1 and 4.5.5 in the Haskell 98 Language and Libraries Report.
Stefan
Aargh! Sorry, I'm having a Bad Details Day. 3 in 1 message: - Overlooking the "to make the code work, I had to expand 'fold' into 'foldRegsUsed' everywhere it appears" part in the original question, - Chopping a letter out of Norman's email address, and - Mixing up the MR with other issues, possibly something from the binding groups section of Typing Haskell In Haskell. The one saving grace is that I tested my suggestion before posting, and it worked. :-) - Tom
participants (3)
-
Norman Ramsey -
Stefan O'Rear -
Tom Pledger