[Haskell-cafe] Need help using a typeclass within an existing API

Ben Franksen ben.franksen at online.de
Tue Jan 28 02:35:33 UTC 2020

> This compiles but I don't get the proper instance of the typeclass
> when I run it

You did not tell us to which concrete type M you instantiate the type
variable m when you run your code. Your wording suggests that you may
misunderstand how instantiation of type variables works: it is the
caller of the debit function who chooses the M; in fact it can choose
/any/ M, as long as it satisfies the listed constraints.

If your code compiles but doesn't work, then the M your caller has
chosen has a wrong instance that doesn't do what it should do. If it is
not obvious from the calling code what the M is, try to use local type
annotations with type holes, so the compiler tells you what the type is.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 4211 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200128/1f709433/attachment.key>

More information about the Haskell-Cafe mailing list