[Hugs-users] Old bug hanging around?

Ross Paterson ross at soi.city.ac.uk
Wed Mar 7 18:37:52 EST 2007


On Wed, Mar 07, 2007 at 10:54:55PM +0000, Dave at haskell.org wrote:
> io f    = interact (unlines . f . lines)
> showln  = (++ "\n") . show
> 
> -- Compute a simple cksum of a file
> 
> main = interact $ showln . foldl' k 5381
>     where k h c = h * 33 + ord c
> 
> ========
> 
> Hugs> :load chksum.hs
> ERROR "chksum.hs":15 - Unresolved top-level overloading
> *** Binding             : showln
> *** Outstanding context : Show b
> 
> Text.Printf>  
> 
> This error has been around for a while.

Yes, it's a documented divergence from Haskell 98 in the handling of
the Monomorphism Restriction.

Workarounds are to give an explicit signature for showln, or to tweak
the definition so it's a function:

showln x = show x ++ "\n"

(or, better)

showln x = shows x "\n"



More information about the Hugs-Users mailing list