
Bulat Ziganshin wrote:
from one my module:
copyStream :: (BlockStream h1, BlockStream h2, Integral size) => h1 -> h2 -> size -> IO ()
in my library and found the way to simplify most of their signatures:
copyStream :: BlockStream* -> BlockStream** -> Integral -> IO ()
i think that second block of signatures is an order of magnitude more readable
I think template haskell could do this translation. Eg if you declared some dummy phantom types so the arg to the template function could be parsed, and as a way of telling the function which types were to be replaced by type variables with class constraints the block of signatures would just be declared in a splice: $(expandSigs [d| data BlockStream' data BlockStream'' data Integral' copyStream :: BlockStream' -> BlockStream'' -> Integral' -> IO () ... |]) Though I leave the definition of expandSigs :: Q [Dec] -> Q () as a little exercise for the reader... :-) Best regards, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com