It seems as though this isn't possible, but here's an example of what I have working:
{-# LANGUAGE PolyKinds , MultiParamTypeClasses , FlexibleInstances , OverlappingInstances #-}
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"
With PolyKinds
and our instances above our t
in Proxy t
can be arity * -> *
, or * -> * -> *
and the code works correctly, however supporting t
s of higher arity requires adding an arbitrary number of additional instances. Is there a way to combine those two instances into a single instance that means "t
fully-applied to any k
arguments"?