genDispatcher :: [(FDesc, Int)] -> String
genDispatcher tags = "void* _idris_get_wrapper(VAL con)\n" ++
                     "{\n" ++
                     indent 1 ++ "switch(TAG(con)) {\n" ++
                     concatMap makeSwitch tags ++
                     indent 1 ++ "}\n" ++
                     indent 1 ++ "fprintf(stderr, \"No wrapper for callback\");\n" ++
                     indent 1 ++ "exit(-1);\n" ++
                     "}\n\n"
                        where
                            makeSwitch (_, tag) =
                                    indent 1 ++ "case " ++ show tag ++ ":\n" ++
                                    indent 2 ++ "return (void*) &" ++ wrapperName tag ++ ";\n"
genDispatcher :: [(FDesc, Int)] -> String
genDispatcher tags = "void* _idris_get_wrapper(VAL con)\n" ++
                     "{\n" ++
                     indent 1 ++ "switch(TAG(con)) {\n" ++
                     concatMap makeSwitch tags ++
                     indent 1 ++ "}\n" ++
                     indent 1 ++ "fprintf(stderr, \"No wrapper for callback\");\n" ++
                     indent 1 ++ "exit(-1);\n" ++
                     "}\n\n"
                        where
                            makeSwitch (_, tag) =
                                    indent 1 ++ "case " ++ show tag ++ ":\n" ++
                                    indent 2 ++ "return (void*) &" ++ wrapperName tag ++ ";\n"
genDispatcher tags = "void* _idris_get_wrapper(VAL con)\n" ++
                     "{\n" ++
                     indent 1 ++ "switch(TAG(con)) {\n" ++
                     concatMap makeSwitch tags ++
                     indent 1 ++ "}\n" ++
                     indent 1 ++ "fprintf(stderr, \"No wrapper for callback\");\n" ++
                     indent 1 ++ "exit(-1);\n" ++
                     "}\n\n"
                        where
                            makeSwitch (_, tag) =
                                    indent 1 ++ "case " ++ show tag ++ ":\n" ++
                                    indent 2 ++ "return (void*) &" ++ wrapperName tag ++ ";\n"