
Helly all for ad-hoc benchmarking I wrote bench x = (timeIt . print) x Hlint suggested Found: bench x = (timeIt . print) x Why not: bench = (timeIt . print) but when I do this, I get No instance for (Show a0) arising from a use of ‘print’ Why is that so?

On Wed, Apr 15, 2015 at 3:31 PM, martin
Hlint suggested
Found: bench x = (timeIt . print) x Why not: bench = (timeIt . print)
hlint is kinda dumb sometimes, like any heuristic analyzer. In particular, it recognizes patterns of code, but knows nothing about types. Or, in this case, the monomorphism restriction, which is likely messing with the inferred type (since the inferred type is correct when it has a parameter). -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hello, Well, writing out all top-level types is generally considered good style amongst Haskell community, as far as I know. But whenever you get weird type errors on unannotated toplevel functions, try {-# LANGUAGE NoMonomorphismRestriction #-} at the beginning of the soruce file, just as Brandon Allbery (sort of) said, and see https://wiki.haskell.org/Monomorphism_restriction for the explanation. Best regards, Marcin Mrotek
participants (3)
-
Brandon Allbery
-
Marcin Mrotek
-
martin