For the Trac ticket #14860
.
All these types are valid for h
, but its principal type involves -XQuantifiedConstraints
{-# Language FlexibleInstances, MultiParamTypeClasses, GADTs, QuantifiedConstraints #-}
import Data.Kind
type family FB (a::Type) (b::Type) :: Type where
FB Int _ = Bool
FB [a] b = FB a b
data Bar a where
K :: a -> xx -> Bar a
h :: Bar Int -> Bool
h :: Bar [Int] -> Bool
h :: Bar [[Int]] -> Bool
h :: Bar [[[Int]]] -> Bool
h :: Bar [[[[Int]]]] -> Bool
h (K a xx) = not (fb a xx)
fb :: a -> b -> FB a b
fb = undefined
We really want: h :: forall a. (forall b. FB a b ~ Bool) => Bar a -> Bool
.
This is possible with the following steps:
Class alias for
FB a b ~ Bool
Quantify over alias
Helper function that converts
(a -> xx -> FB a xx)
into(a -> xx -> Bool)
given a witness ofFB_Bool a xx
where we can instantiate
h