This seems to be impossible, but here is an example of what I'm working on:
{-
data Proxy a = Proxy
class Test pt t where
test :: pt -> t -> IO ()
instance Test (Proxy t) t where
test _ _ = putStrLn "MATCHES"
-- I would like to combine these:
instance Test (Proxy t) (t a) where
test _ _ = putStrLn "MATCHES2"
instance Test (Proxy t) (t a b) where
test _ _ = putStrLn "MATCHES3"
--etc.
instance Test (Proxy t) x where
test _ _ = putStrLn "FAIL"
C PolyKinds, and our instances above ours tin Proxy tmay be arity * -> *or * -> * -> *, and the code works correctly, however, support for ta higher arity requires the addition of an arbitrary number of additional instances. Is there a way to combine these two instances into one instance, which means that " tfully applies to any arguments k"?
source
share