[Haskell-cafe] Does this typeclass have a name?
Bardur Arantsson
spam at scientician.net
Mon Apr 21 08:08:30 UTC 2014
On 2014-04-21 09:04, Ivan Lazar Miljenovic wrote:
> On 21 April 2014 15: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
>
> = foldr foo bar [e_n, e_{n-1} .. e_0] ?
>
Yes, indeed, but I want the type class to constrain things since there
are other interacting constraints on the types "a" and "e" (plus there's
the fundep that I mentioned). The "single instance" part of type classes
is also very desirable.
Regards,
More information about the Haskell-Cafe
mailing list