Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Add Alt and Plus instances #66

Open
tslawler opened this issue Jul 9, 2016 · 3 comments
Open

Add Alt and Plus instances #66

tslawler opened this issue Jul 9, 2016 · 3 comments

Comments

@tslawler
Copy link

tslawler commented Jul 9, 2016

Both Map k and StrMap should be instances of Alt and Plus, with union and empty as the corresponding methods.

Also, something odd I've noticed: While Map k a has a Semigroup instance as long as Ord k, StrMap a seems to require a Semigroup a instance... which means if I have a type Foo with no Semigroup instance, I have a Monoid instance for Map String Foo but not StrMap Foo, which is... odd, to say the least.

@paf31
Copy link
Contributor

paf31 commented Jul 9, 2016

👍

The Semigroup and Monoid instances for StrMap definitely look inconsistent with the ones for Map. Maybe they are the ones induced by the Applicative instance, but we should try to be consistent.

@tslawler
Copy link
Author

tslawler commented Jul 11, 2016

There's no Applicative instance either; not that this is a problem since Alt and Plus only require Functor. (There couldn't be an Applicative instance either, since there's no way to write pure :: v -> Map k v. I might be able to imagine an Apply instance given by zipping two maps together by the keys they have in common, but I'd have to think about it to make sure it's law-abiding.)

@paf31
Copy link
Contributor

paf31 commented Jul 11, 2016

I meant the Apply instance, for which there is definitely a law-abiding instance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants