[Haskell-beginners] RankNTypes + ConstraintKinds to use Either as a "union"

Kim-Ee Yeoh ky3
Wed Oct 9 20:08:17 UTC 2013


On Thu, Oct 10, 2013 at 2:24 AM, Thiago Negri <evohunz at gmail.com> wrote:

> I want to use something like "type class variable".


Right, my bad, I just noticed the ConstraintKinds.

One way of getting round this is:

> type F tc a b =  (tc a, tc b) => (forall c. tc c => c -> c) -> Either a b
-> Either a b
> foo' = (foo :: F Num a b) (2+)

As to why the type inference isn't powerful enough, you might want to ask
on cafe. It's really tricky to get it right. Too much power and it'll loop.
Too little and you end up with cases like this. And that's not even
considering bugs!

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131010/5da392ec/attachment.html>



More information about the Beginners mailing list