It might be useful to think about this as an "Elemwise" generation template for RaggedArrays.  You have one or more elemwise code generators. The input to the code generator is the list of arguments and the body that reads and writes numbers. Whatever refactoring you can do between the code generators is convenient, but it remains that they are different code generators.