Discussion: Allow custom constraint for elem in Foldable

Carter Schonwald carter.schonwald at gmail.com
Fri Jul 28 00:49:16 UTC 2017


i wasnt aware of such guidelines for the libraries list

constrained monads/ functors are still an area of study / experimentation,
they need experimentation and more community knowledge before they land in
base for core type classes

On Thu, Jul 27, 2017 at 8:37 PM, David Feuer <david.feuer at gmail.com> wrote:

> Off-list: Repeating what Eric Mertens said does not contribute to the
> discussion. Perhaps you can offer an answer to my follow-up question to him.
>
> On Jul 27, 2017 8:26 PM, "Carter Schonwald" <carter.schonwald at gmail.com>
> wrote:
>
>> agreed.
>>
>> this needs to be tested out in a user space lib first.
>>
>>
>> On Thu, Jul 27, 2017 at 7:35 PM, Eric Mertens <emertens at gmail.com> wrote:
>>
>>> I would prefer to see designs for something like this explored in a
>>> separate package before we worried about changing base’s Foldable class.
>>>
>>> > On Jul 27, 2017, at 3:45 PM, David Feuer <david.feuer at gmail.com>
>>> wrote:
>>> >
>>> > The Foldable class offers the method
>>> >
>>> >  elem :: Eq a => a -> t a -> Bool
>>> >
>>> > Unfortunately, this is really awful for sets, hash maps, etc. See
>>> > https://stackoverflow.com/questions/45361801/implement-an-ol
>>> og-n-foldable-elem-for-binary-search-trees-in-haskell#45362110
>>> > for an example. We could fix it, kinda:
>>> >
>>> > class Foldable t where
>>> >  type ElemConstr t :: * -> Constraint
>>> >  type ElemConstr t = Eq
>>> >
>>> >  elem :: ElemConstr t a => a -> t a -> Bool
>>> >  default elem :: (ElemConstr t ~ Eq, Eq a) => a -> t a -> Bool
>>> >
>>> > One might legitimately complain that such a wild type is ad hoc, but
>>> > one might counter that complaint by saying that most of Foldable is
>>> > already ad hoc.
>>> >
>>> > David
>>> > _______________________________________________
>>> > Libraries mailing list
>>> > Libraries at haskell.org
>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170727/8c6ff491/attachment-0001.html>


More information about the Libraries mailing list