Proposal: Add concatMapM function (#2042)

Roman Leshchinskiy rl at cse.unsw.edu.au
Fri Feb 1 08:30:14 EST 2008


Bulat Ziganshin wrote:
> Hello Roman,
> 
> Friday, February 1, 2008, 11:03:36 AM, you wrote:
> 
>>> the right way to deal with "modifiers" is to attach them to the Handle
>>> itself like this:
>>>
>>> f <- openFile "name" >>= withLocking >>= withEncoding utf8
> 
>> IMO, global state is never "the right way" if it can be avoided. It will
>> always lead to problems. Especially in a functional language like Haskell.
> 
> so you propose something like this:
> 
> s <- readString "/path/filename" TextMode "utf8" line_num

No. In my view, file handles and encodings exist on completely different 
levels of abstraction. The former are (or ought to be) simply an 
interface to the underlying OS capabilities. The latter would be part of 
a high-level I/O library which shouldn't even have the concept of a 
handle (and should use typed I/O). Also, it doesn't always make sense to 
associate an encoding with an entire file. For instance, a Russian-Greek 
dictionary might use ISO 8859-5 for Russian words and ISO 8859-7 for 
Greek ones.

Roman



More information about the Libraries mailing list