From what I know about dependent types, I think that it should possible, but I\'ve never seen an example of this before in a dependently typed language, so I\'m not exactly
I remember a paper by Stephanie Weirich on arity-generic programming in Agda which you might find relevant. It goes quite a bit further than just what you ask about, but the introductory sections might offer a good explanation.