When constructing a value of type DynTerm
using the DynTerm
constructor, GHC has to know the concrete types x
and y
in order to decide which Typeable
dictionaries should be packed in. In your test expression, you are not providing sufficient type information to determine concrete types, therefore you get an error that certain type variables are ambiguous. It works if you specifically pick a concrete Typeable
type.
Example (with ScopedTypeVariables
):
test :: forall repr. Program repr => DynTerm repr
test = DynTerm (intro1 :: repr Int (Int, ()))