[Haskell-cafe] Use cases of empty type classes
Mitchell Rosen
mitchellwrosen at gmail.com
Thu Mar 10 18:42:05 UTC 2016
One empty typeclass I use often not only has no methods, but also has no
members.
class Void
This is useful in type families that return Constraint, when you want to
say this constraint is "unsatisfiable". I suppose returning something like
"True ~ False" would also suffice, but isn't as pretty.
On Monday, March 7, 2016 at 10:10:48 PM UTC-8, Tomas Tauber wrote:
>
> Hi everyone,
>
> I have one question. What are current use cases of type classes with no
> methods?
>
> I saw early uses in type-level programming (e.g. HList [1]).
> In the OO world, interfaces with no methods are called marker interfaces
> -- their use cases range from things that could be done with datatype
> generic programming in Haskell (e.g. serialization) to metadata annotations
> (e.g. RandomAccess [2]).
>
> Regards,
>
> Tomas Tauber
>
>
> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf
> [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html
> _______________________________________________
> Haskell-Cafe mailing list
> Haskel... at haskell.org <javascript:>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160310/5519a47b/attachment.html>
More information about the Haskell-Cafe
mailing list