[Haskell-cafe] Use cases of empty type classes
heraldhoi at gmail.com
Tue Mar 8 15:48:37 UTC 2016
Thanks everybody. I found this helpful (:
вт, 8 мар. 2016 г. в 19:58, Alex Rozenshteyn <rpglover64 at gmail.com>:
> You can use them to claim something about multiple type classes at once,
> with some advantages over using ConstraintKinds for the same purpose:
> On Tue, Mar 8, 2016 at 6:36 AM Adam Bergmark <adam at bergmark.nl> wrote:
>> I have two use cases for them
>> - In fay-jquery there’s an empty Selectable class that has instances
>> for all elements that can be passed to the jQuery function, there is no
>> need for methods since we in the background just pass the object along, but
>> we want to make sure we don’t pass something nonsensical.
>> - In a rest API serving JSON you need ToJSON and FromJSON instances
>> for each type, but since internal APIs may also use JSON it’s possible that
>> you by accident pass a type that isn’t versioned and supposed to be
>> included in the public API. There I can have an empty PublicApiType class
>> with instances for all public types to give a type error if I pass
>> something internal by mistake.
>> /Adam Bergmark
>> On Tue 08 Mar 2016 at 07:10 Tomas Tauber <Tomas Tauber
>> <Tomas+Tauber+%3Ctomtau at connect.hku.hk%3E>> wrote:
>>> Hi everyone,
>>> I have one question. What are current use cases of type classes with no
>>> I saw early uses in type-level programming (e.g. HList ).
>>> 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 ).
>>> Tomas Tauber
>>>  http://okmij.org/ftp/Haskell/HList-ext.pdf
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe