Here is a snippet that I think makes (type) sense, but which ghc doesn't like. I was hoping that some tricky use of type annotations could make it work, but my experiments have failed. Any suggestions?
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Ex where
data T a where
T :: Functor f => (f a -> a) -> T a
foo :: (forall a . T a) -> Bool
foo (T f) = bar f
bar :: Functor f => (forall a . f a -> a) -> Bool
bar _f = True
It could very well be impossible since it amounts to commuting a universal and existential quantifier, but I was hoping.