tweag / capability

Extensional capabilities and deriving combinators
BSD 3-Clause "New" or "Revised" License
214 stars 9 forks source link

Make `HasStream` a super class of `HasWriter` #64

Closed Ericson2314 closed 5 years ago

Ericson2314 commented 5 years ago

Does the good half of #63.

I went ahead to give that idea a spin, and found a few interesting things in the process. Will comment in line notes.

Ericson2314 commented 5 years ago

Thanks @aherrmann. I'm quite willing to add all the docs you or anyone wants for these changes; I definitely agree these changes are quite surprising up front for people used to the MTL/seeing Writer as an atom of capability. You may want to look at #63 for all the discussion that this has generated so far.

Writer is a funny thing in that it almost doesn't need the Monoid constraint at all. pass, for example, could work by mapping the function on each tell argument, rather than after they've been mappended together (the laws here permits either). It's just listen which, in containing a runWriterT or it's moral equivalent), speaks to how the effect is eliminated thus forces the Monoid.

My view is sort of syntactic. yield/tell alone cannot speak to whether the garbage chute ends in a monoid trash heap or conveyor belt for further processing :). If I write code using just that one method/capability, I wish my code to be open to as many possible interpretations as possible.

aherrmann commented 5 years ago

@Ericson2314

I'm quite willing to add all the docs you or anyone wants for these changes;

Thank you! Yes, I think this is a good addition to capability. I'll be happy to merge it with some more docs.

Ericson2314 commented 5 years ago

OK added some documentation.

aherrmann commented 5 years ago

@Ericson2314 Sorry for leaving this hanging for so long. Thanks for the added documentation! Looks good to me.

I noticed that the examples needed fixing. I added the corresponding changes.

Ericson2314 commented 5 years ago

Oh, right. Thanks for fixing those!