
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". HTH Christian
data StdMethod = GET | POST | HEAD | PUT | DELETE | TRACE | CONNECT | OPTIONS deriving (Show, Eq, Ord, Enum, Bounded)
method :: StdMethod -> Method method = Ascii.pack . show
methodListB :: [(Method, StdMethod)] methodListB = map (\ s -> (method s, s)) [minBound .. maxBound]
methodToStdMethod :: Method -> Maybe StdMethod methodToStdMethod = flip lookup methodListB
Cheers Christian