[Haskell-beginners] RankNTypes + ConstraintKinds to use Either as a "union"
Thiago Negri
evohunz
Wed Oct 9 18:28:26 UTC 2013
Is there a way to compile this code?
If not, why?
{-# LANGUAGE RankNTypes, ConstraintKinds #-}
-- This compiles
bar :: (Num a, Num b) => (forall c. Num c => c -> c) -> Either a b ->
Either a b
bar f (Left a) = Left (f a)
bar f (Right b) = Right (f b)
bar' = bar (+ 2)
-- This doesn't compile because foo' does not typecheck
foo :: (tc a, tc b) => (forall c. tc c => c -> c) -> Either a b -> Either a
b
foo f (Left a) = Left (f a)
foo f (Right b) = Right (f b)
foo' = foo (+ 2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131009/2d8002e6/attachment.html>
More information about the Beginners
mailing list