
Hello Johan, Thursday, January 31, 2008, 6:19:40 PM, you wrote:
data Encoding = Encoding { encode :: String -> String , decode :: String -> String }
With this approach I would like some facility (e.g. table) to lookup common encodings as the encoding used for a particular datum is not know at compile time in many applications (e.g. it's read from a HTTP Content-Type header or similar.)
lookupEncoding :: String -> Maybe Encoding
you may have several libs installed each one providing its own set of encodings, moreover some libs (e.g. iconv-based) may provide this info only at run-time (i.e. in IO monad) so it have meaning to require from authors of encoding libs/modules to provide "dictionaries" of encodings implemented, and combine these dictionaries yourself: myLookup = do iconvEncodings <- IConv.lookupEncoding return (stdEncodings <+> iconvEncodings <+> OtherLib.lookupEncoding) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com