purescript / purescript-transformers

Monad and comonad transformers
BSD 3-Clause "New" or "Revised" License
69 stars 44 forks source link

Add subclasses to enforce the type class laws #126

Closed ursi closed 3 years ago

hdgarrood commented 3 years ago

I’m hesitant about this one, because we are now carrying extra dictionaries around which we weren’t before. At the very least this should allow us to relax some constraints elsewhere, in instances for these classes.

hdgarrood commented 3 years ago

Sorry, that’s not quite right - instances will likely still need the same constraints. I was thinking that there may now be redundant constraints on functions which use MonadTell or MonadWriter generically, but we only have two of those (listens and censor) and neither of them have an additional Semigroup or Monoid constraint. So :+1: from me. Thanks!

ursi commented 3 years ago

oopsie daisy, I added superclasses, not subclasses. I think I was confused when I made this PR (<= while being an arrow, can also be interpreted as less-than-or-equal-to)

Edit: actually I don't even know what to call it, since it's a type class constraint on one of the two types in the type class.

hdgarrood commented 3 years ago

Haha, so you did! I didn't realise until just now either.

hdgarrood commented 3 years ago

I think superclasses is still accurate - it's a relationship between the classes themselves, not the type parameters.

ursi commented 3 years ago

I'm willing to redo the commit and submit another PR if you'd like it to be named appropriately.

hdgarrood commented 3 years ago

I wouldn't worry about it. We'd need to rewrite the history, which is a much bigger no-no in my mind.