Ad
  • Default User Avatar

    I think that error message is a result of UndecidableInstances masking the real problem. Without that option, GHC throws an error, that it can not see, that the functional dependency t → r is satisfied in the second instance:

        • Illegal instance declaration for ‘Variadic a r (a' -> t)’
            The coverage condition fails in class ‘Variadic’
              for functional dependency: ‘t -> r’
            Reason: lhs type ‘a' -> t’ does not determine rhs type ‘r’
            Un-determined variable: r
            Using UndecidableInstances might help
        • In the instance declaration for ‘Variadic a r (a' -> t)’
       |
    13 | instance (a ~ a', Variadic a r t) => Variadic a r (a' -> t) where
       |  
    

    Removing the functional dependency resolves that, but then GHC complains about an ambiguous type in polyList.
    I have no idea how to resolve that. I have been banging my head against the wall for a whole day trying to get a similar solution working, before settling for a less elegant solution.

  • Custom User Avatar

    As mentioned in initial code, the combinators are already defined in Preloaded. They should be used instead of defining your own.