[web-devel] ALPHA: http-types 0.1

Christian Maeder Christian.Maeder at dfki.de
Fri Feb 4 11:49:37 CET 2011

Am 04.02.2011 11:22, schrieb Christian Maeder:
> Am 04.02.2011 11:04, schrieb Aristid Breitkreuz:
>> Interesting idea. I don't really like that StdMethod cannot encode
>> custom methos though.
> For any method (including custom ones) you have the type Method (just a
> ByteString).
>> data Method = Std StdMethod ¦ Ext ByteString
>> Might work. But is the complexity worth it?
> What complexity? It exactly models that you want to or need to
> distinguish between custom and standard methods. (Converting "data
> Method" to and from byte strings is no issue.)
> Either choice "StdMethod" + "type Method = ByteString" or "StdMethod" +
> "data Method" (above) is better than "MethodADT".

Well, one disadvantage remains for:

  data Method = Std StdMethod ¦ Ext ByteString

'Std GET' and 'Ext (Ascii.pack "GET")' are different Method values,
but identically sent. So "data Method" would need some encapsulation,
i.e. "Ext" should be hidden and separate functions to construct methods
should be provided.

The disadvantage for just strings are possible spelling errors. With
constants or constructors spelling errors are detected by the compiler
(but you still can confuse constants having the same type).


More information about the web-devel mailing list