purescript/purescript-transformers

Potential circular dependency with purescript-yoneda

ethul opened this issue · 18 comments

I wanted to submit a PR to add a new type to Free called FreeC defined as:

type FreeC f a = Free (Coyoneda f) a

However, since there is a MonadTrans instance for Coyoneda, the dependencies don't quite work out. Would it make sense to bring Coyoneda into this repo? Alternatively, I could define FreeC in the purescript-yoneda repo, but I was thinking it fit better along side of Free. Since we'd also have functions like goMC and goEffC to run FreeCs.

Thanks!

I've forgotten why we merged transformers and free to begin with, to be honest :) Was there a dependency which forced it?

I'd be in favour of moving (Co)yoneda into transformers.

I'd also be interested in moving Free out into a package with (Co)yoneda but that seems like much more work.

The discussion on merging Free with transformers was:
purescript/purescript-free#7

I don't know if there is still a dependency forcing Free to be included in transfomers, but if not, I would be open to either option you propose. We do still have the purescript-free repo, so we could definitely bring that back and include yoneda.

Oh I remember now. If I remember correctly, the issue was that people wanted Trampoline to be with the standard transformers so that it was obvious that they could be used together.

Personally, I'm still in favour of breaking the two up, but given the relative difficulty, adding Yoneda to transformers is probably the best option.

I don't know if it would be too bad to bring Free back into purescript-free. Are you suggesting to leave Trampoline in transformers and then require Free from purescript-free? I'd be happy to make this change.

However, I am also up to submit a PR to bring yoneda into transformers.

What do you think?

Well if we were to break it up at all, I'd vote for keeping the "standard" transformers, and moving Free, Trampoline and Yoneda into another package. But I don't feel strongly either way.

Sounds good on keeping the standard transformers and moving Free, Yoneda, and Trampoline.

However, I suppose it depends if Free or Trampoline will be needed by any transfomers for stack safety, as mentioned in purescript/purescript-free#7. I think we'd run into a circular dependency if that was the case. If not, I am open to bring back purescript-free.

Isn't there a free monad transformer too? I thought that was why we moved it, along with the stack safety issue.

There is, but we don't define FreeT, only Free. Free is itself an instance of MonadTrans but not the same one.

https://hackage.haskell.org/package/control-monad-free-0.5.3/docs/Control-Monad-Free.html#t:FreeT

Amount of work aside, I've just been thinking that it might make sense to simplify transformers since the Free-like things don't always tend to get used together with transformers, and the dependencies all flow in one direction.

I'm happy to do whatever... but reading back up to the original post, does moving Free, Yoneda and Trampoline out fix the MonadTrans Coyoneda instance issue?

Do we need to move MonadTrans out of transformers even?

Yes, the dependencies would all be from the new package back to transformers.

While things are getting split, can Identity also come out? I think it's strong enough to stand on its own and would make a nice intro to ADT's and typeclasses if you want to show someone unfamiliar with them what this all means without blowing up heads.

Identity isn't even in the right place, it should be Data.Functor.Identity, I didn't know what I was doing at the time.

Const should probably go with it too.

Why Data.Functor.Identity and not just Data.Identity? Genuine question, not trying to argue. I pretty much don't understand the namespaces we use. Or haskell for that matter.

Data.Identity works for me too.

If we all agree the way to go is to move Free, Trampoline, Yoneda, and Coyoneda into purescript-free, I will update the purescript-free repo and then submit a PR here to remove Free and Trampoline. I am almost done fixing up purescript-free. Just let me know if this is a go and I will push those changes either tonight or tomorrow.

Sounds good to me. 👍

👍 from me as well.