I try to define list of constrained polymorphic values, e.g.
myList = ["foo", 5] :: [Show a => a]
which yields the following error (GHCi, version 8.6.5)
GHC doesn't yet support impredicative polymorphism
Anyways, is it possible to specify a type such that, for example, functions of the form f :: Show a => [a] -> [String] could consume a constrained value like above?
In other words, is there a way to verify the following code by the compiler?
(++ "fork") . show <$> ["foo", 5]
I currently try to test a Show type class instance of a GADT by defining a dataset of values and expected results [(value, "expectedResult")]. But, due to the fact that GADTs constructors specify the values type, it is not possible to do this naively.