4 ms·
Thanks, I'm going to fix the post right now. I have been confused by the fact that I got errors while I was not constraining the type in the right way.
by msangi 14y ago
Thanks, I'm going to fix the post right now.
I have been confused by the fact that I got errors while I was not constraining the type in the right way.
- deleted 14y ago[deleted]
- jerf 14y agoMore specifically, you remove your type annotations for the target functions/values entirely, and then ask GHCi what it thinks by loading the module into it. You should then examine the result and make sure it is correct. In this case, you wrote the type signature incorrectly on an otherwise-correct function, but you will also frequently find that what you wrote is syntactically valid but has a type you did not intend at all, because it is actually wrong. For instance, it's easy to end up missing a parameter passing somewhere and ending up with an unexpected function showing up in the inferred signature. You can also find that the GHCi-inferred type signature is correct, but not what you particularly wanted. Sometimes you may want to deliberately constrain it to something tighter than it will infer. And the other major case I've seen is that you may want to write the type signature with synonyms you've created; if you fix the type signature with those, GHCi will use them in the future if you ask for the type.
- uvdiv 14y agoWere they errors like these? http://book.realworldhaskell.org/read/using-typeclasses.html#Monomorphism.hs:myShow http://book.realworldhaskell.org/read/using-typeclasses.html... http://www.haskell.org/haskellwiki/Monomorphism_restriction http://www.haskell.org/haskellwiki/Monomorphism_restriction