
The answer is, I'm working on a recently semi-released package called TrieMap.
The objective of this package, building off of the work in this paperhttps://docs.google.com/Doc?docid=0AWuaUF8ZNTNDZHB3emdyaF8zMzNmZmtmcHo2Yw&hl=en, is to automatically derive the type of a generalized trie for any algebraic type based on its algebraic representation. (I am working on writing up my methods for publication.)
Of course, if I could get automatic access to the mechanisms of a type's constructors, I wouldn't even require users to describe the algebraic representation of their type...
Well, it's relatively easy to use Template Haskell to determine the structure of a datatype. Look in the "Generics" category on Hackage for a number of examples (e.g. emgm, regular, multirec) or see if the Derive package will do it for you. According to Neil Mitchell, you just need one example: http://www.cogsys.wiai.uni-bamberg.de/aaip09/aaip09_submissions/talk_mitchel... I don't know if it's easy or even possible to capture a sum-of-products view from SYB. Sean