[Haskell-cafe] Type unions

Eric Stansifer eric.stansifer at gmail.com
Sat May 10 12:26:27 EDT 2008


> Try making a type class for the functions.  That will allow you both varargs
> and unions.
> Have a look at Text.Printf.

Thank you -- looking at Printf was very helpful.  My syntax is much
happier as a result.

I also see now that I am approaching the problem from the wrong
direction -- that by writing a whole slew of functions whose behavior
depends arbitrarily upon their argument type, I would need to code the
desired behavior for each function and each argument type;  getting
hung up on making the syntax manageable hid this realization from me.
The solution is for me to try much harder to extract common behavior
across argument types and only code special cases when truly
necessary.

Eric


More information about the Haskell-Cafe mailing list