[Haskell-cafe] Combining RequiredTypeArguments and type class methods?
Anthony Clayden
anthony.d.clayden at gmail.com
Mon Jul 14 05:17:22 UTC 2025
On Sun, Jul 13, 2025 at 11:47:36AM +0100, Tom Ellis wrote:
> >* There is, however, a known trick. This works:
*>
Ah yes. Same solution here
https://discourse.haskell.org/t/how-to-use-requiredtypearguments-with-typeclasse-methods/12187/3
Currently, `RequiredTypeArguments` is documented as " only partially
implemented in GHC". Full specification to be found in proposal #281.
That proposal doesn't give examples of how to write instances for
`sizeOf`, as and when we get Dependent Haskell in full. Will it still
need the type equality trick?
>
>* (But I prefer your [Viktor's] solution: the wrapper.)*
*>*
Yes. That in effect still uses a term-level proxy for the type, as argument
to _sizeOf. For example I could go
pattern Bool :: Bool
pattern Bool = undefined
... _sizeOf Bool ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20250714/174dc1a3/attachment.html>
More information about the Haskell-Cafe
mailing list