[Haskell-cafe] A function synonym is not (by default) as polymorphic as the original.

Jeffrey Brown jeffbrown.the at gmail.com
Wed Aug 15 03:33:00 UTC 2018


Today I was writing a lot of Hashable instances, and found it hard to read
code littered long lines mostly consisting of `hashWithSalt`, so I made a
synonym:

infixl 5 ##
(##) = hashWithSalt

But when I replaced all the `hashWithSalt`s with ##, I got lots of weird
errors -- GHC kept wanting things to be Strings that were Ints, or vice
verse. The problem vanished when I added this type signature:

(##) :: Hashable a => Int -> a -> Int

That's exactly the same type signature that hashWithSalt has.

Is this expected behavior? Desirable?


-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180814/bb907bee/attachment.html>


More information about the Haskell-Cafe mailing list