[Haskell] question about a failure to generalize

Stefan O'Rear stefanor at cox.net
Mon Sep 17 00:47:10 EDT 2007


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell/attachments/20070916/d957dc89/attachment.bin


More information about the Haskell mailing list