[Haskell-cafe] Does this typeclass have a name?

Andras Slemmer 0slemi0 at gmail.com
Mon Apr 21 13:49:13 UTC 2014


Oh, and bar = mempty


On 21 April 2014 15:46, Andras Slemmer <0slemi0 at gmail.com> wrote:

> I think what you're looking for are monoid actions:
> http://hackage.haskell.org/package/monoid-extras-0.2.2.0/docs/Data-Monoid-Action.html
> And the laws the typeclass should satisfy:
> foo bar = id
> foo f . foo g = foo (f `mappend` g)
>
> The identity law is optional, in whihc case your 'e' would be a semigroup
> without a default 'bar'
>
>
> On 21 April 2014 11:46, Tobias Brandt <tob.brandt at googlemail.com> wrote:
>
>> Your class looks like Unfoldable from Data.Collections<http://hackage.haskell.org/package/collections-api-1.0.0.0/docs/Data-Collections.html>.
>> foo is insert and bar is empty. The other three methods can be defined in
>> terms of insert and empty.
>>
>>
>> On 21 April 2014 07:09, Bardur Arantsson <spam at scientician.net> wrote:
>>
>>> Hi all,
>>>
>>> I was wondering if anyone out there knows if this type class has a name?
>>>
>>>   class Foo a e where
>>>      foo :: e -> a -> a
>>>      bar :: a
>>>
>>> (I also have a fundep a -> e, but that's not essential.)
>>>
>>> Essentially the usage is:
>>>
>>>    You have a sequence of "events" e_i and a starting value
>>>    "bar" and can use the "foo" function to apply all events
>>>    to that starting value
>>>
>>>       foo e_n $ foo e_{n-1} $ ... $ foo e_0 $ bar
>>>
>>>    and thus get the final value of the a induced by the
>>>    events e_i.
>>>
>>> (I've included the "bar" starting value in the type class, but I suppose
>>> it could be supplied by a Default instance.)
>>>
>>> Regards,
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140421/c7a2ed10/attachment.html>


More information about the Haskell-Cafe mailing list