Combining RequiredTypeArguments and type class methods?
Anthony Clayden <[email protected]> Mon, 14 Jul 2025 17:17:22 +1200
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <CABU_mxgKEvTTFaaUyxF2QMpv_Q7cNmLP=7Q-XG_q0fmFrSP3Sg@mail.gmail.com> |
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 ...
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.