Proposal: Add concatMapM function (#2042)

Johan Tibell johan.tibell at gmail.com
Thu Jan 31 10:19:40 EST 2008


On Jan 31, 2008 4:10 PM, Johannes Waldmann <waldmann at imn.htwk-leipzig.de> wrote:
> Bulat Ziganshin wrote:
>
> (very sound software engineering arguments -
> can someone with The Force please copy Bulat's mail
> to Haskell/Category/Style ...)
>
> I agree completely, and just add one remark here :
>
> > data Encoding = Encoding { encode :: String -> String
> >                          , decode :: String -> String }
> >
> > utf8 = Encoding encodeUtf8 decodeUtf8
>
> this is in fact a method table (Java speak) or a dictionary
> (Haskell), and Encoding is the interface (class) -
>
> except that we can have local instances
> by passing around dictionaries explicitly.
>
> This is similar to passing a Comparator object
> to some sorting routine.
>
> Best regards, Johannes.
>
> PS: go read any honest OO book on the benefits of interface
> oriented design - they know this stuff - they got there
> the hard way (that is, via C++ :-)

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

-- Johan


More information about the Libraries mailing list