func writeDecoderFunc(w io.Writer, s *schema.Schema, funcName, typeName string, fields []schema.Field) {
	out := fmt.Fprintf
	out(w, "%s : Decoder %s\n", funcName, typeName)
	out(w, "%s =\n", funcName)
	out(w, "    Decode.success %s\n", typeName)
	writeDecoderFields(w, s, fields)
	out(w, "\n\n")
}
writeDecoderFunc to writer.
package elmclient
import (
	"fmt"
	"io"
	"strings"
	"github.com/apex/rpc/internal/format"
	"github.com/apex/rpc/internal/schemautil"
	"github.com/apex/rpc/schema"
)
var module = `
-- Do not edit, this file was generated by github.com/apex/rpc.
`
func Generate(w io.Writer, s *schema.Schema) error {
	fmt.Fprintf(w, module)
	generateTypes(w, s)
	generateMethodTypes(w, s)
	generateMethodFuncs(w, s)
	generateDecoderFuncs(w, s)
	return nil
}
func generateTypes(w io.Writer, s *schema.Schema) {
	out := fmt.Fprintf
	out(w, "-- TYPES\n\n")
	for _, t := range s.TypesSlice() {
		name := format.GoName(t.Name)
		out(w, "{-| %s %s -}\n", name, t.Description)
		out(w, "type alias %s =\n", name)
		writeFields(w, s, t.Properties)
		out(w, "\n\n")
	}
}
func generateMethodTypes(w io.Writer, s *schema.Schema) {
	out := fmt.Fprintf
	out(w, "-- METHOD PARAMS\n\n")
	for _, m := range s.Methods {
		name := format.GoName(m.Name)
		if len(m.Inputs) > 0 {
			out(w, "{-| %sInput params. -}\n", name)
			out(w, "type alias %sInput =\n", name)
			writeFields(w, s, m.Inputs)
			out(w, "\n\n")
		}
		if len(m.Outputs) > 0 {
			out(w, "{-| %sOutput params. -}\n", name)
			out(w, "type alias %sOutput =\n", name)
			writeFields(w, s, m.Outputs)
			out(w, "\n\n")
		}
	}
}
func generateMethodFuncs(w io.Writer, s *schema.Schema) {
	out := fmt.Fprintf
	out(w, "-- METHODS\n\n")
	for _, m := range s.Methods {
		name := format.JsName(m.Name)
		out(w, "%s : %sInput \n", name, format.GoName(m.Name))
		out(w, "%s = \n   ...", name)
		out(w, "\n\n")
	}
}
func generateDecoderFuncs(w io.Writer, s *schema.Schema) {
	out := fmt.Fprintf
	out(w, "-- DECODERS\n\n")
	for _, t := range s.TypesSlice() {
		fname := format.JsName(t.Name) + "Decoder"
		tname := format.GoName(t.Name)
		writeDecoderFunc(w, s, fname, tname, t.Properties)
	}
	for _, m := range s.Methods {
		if len(m.Inputs) > 0 {
			fname := format.JsName(m.Name) + "InputDecoder"
			tname := format.GoName(m.Name) + "Input"
			writeDecoderFunc(w, s, fname, tname, m.Inputs)
		}
		if len(m.Outputs) > 0 {
			fname := format.JsName(m.Name) + "OutputDecoder"
			tname := format.GoName(m.Name) + "Output"
			writeDecoderFunc(w, s, fname, tname, m.Outputs)
		}
	}
}