Gabriella439 / Haskell-Index-Core-Library

Indexed Types
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Generalize type signatures for "angelic binds" #2

Closed tomjaguarpaw closed 10 years ago

tomjaguarpaw commented 10 years ago

I think the types of the "angelic binds" can be generalized. The final return type does not need to be restricted. Please check you agree with me because I only learned about indexed monads yesterday!

Gabriella439 commented 10 years ago

I think you're right, actually. I will double-check this, though, because it has been a long time since I've used this library.

As a side note, one of the main reasons I haven't pushed this library a lot recently is that:

A) the more general bind it provides sometimes does not play well with Haskell's do notation desugaring (See this Stack Overflow question of mine for more details)

B) It's harder to define indexed monad instances for certain kinds of monads than, say, Edward's indexed library

However, there are some cases where it is more powerful than indexed, so I would only recommend using it if you need that extra power.

Gabriella439 commented 10 years ago

So I have a second question: what is the intended use case for this generalization? Do you have an example of where this generalization is useful?

The only reason I'm asking is that the old version is more suggestive of the most common intended use, but if you have a specific plan in mind for the generalized version then I'm happy to make the switch.

tomjaguarpaw commented 10 years ago

I don't have a specific use case for the generalization, but it matches Conal's original version on page 6 of his paper (https://personal.cis.strath.ac.uk/conor.mcbride/Kleisli.pdf).

Perhaps you could give the generalized versions as the formal type signatures and also show the specialized form as a comment in the Haddock? Control.Lens does that kind of thing a lot.

Gabriella439 commented 10 years ago

Alright, that sounds good. Could you modify this pull request to include the specialized type signatures in the Haddocks?

tomjaguarpaw commented 10 years ago

OK, done.

Gabriella439 commented 10 years ago

Thanks a lot! :)