2011/2/3 Christian Maeder <Christian.Maeder@dfki.de>
Am 02.02.2011 22:34, schrieb Aristid Breitkreuz:
> This is not a problem because constructing OtherMethod "POST" is
> forbidden and will/must never happen. byteStringToMethod will always
> construct POST, and not OtherMethod "POST",
My own conclusion is: avoid as many variants as possible, otherwise
you'll get lots of repetitions of similar code. A single variant
wrapping a String or ByteString is the best for uniform treatment (i.e.
just for implementing show).
I don't see how it follows that there will be lots of repetitions of similar code. Please explain why you think this occurs, and why it is presumably hard to avoid.
In my, possibly naïve, view, you only need to implement methodToByteString once, and methodToString can be implemented as B8.unpack . methodToByteString.
You loose (possibly faster and shorter) pattern matching, but I think it
is just as good to use predefined constants and "==" for comparisons.
With my Method type you also get case-insensitivity for free. :-) And it removes the temptation of just writing "PUT" instead of, say, HTTP.methodPut. (You can get non-standard methods with byteStringToMethod, which is a total function.)
Aristid