Proposal: System.Environment.getEnv should return Maybe
wren ng thornton
wren at freegeek.org
Fri Feb 24 04:22:50 CET 2012
On 2/23/12 7:18 AM, John Lato wrote:
>> From: Jon Fairbairn<jon.fairbairn at cl.cam.ac.uk>
>> Brandon Allbery<allbery.b at gmail.com> writes:
>>> On Wed, Feb 22, 2012 at 18:51, John Meacham<john at repetae.net> wrote:
>>>> On Wed, Feb 22, 2012 at 3:05 PM, Evan Laforge<qdunkan at gmail.com> wrote:
>>>>> It's awkward and surprising how getEnv throws an exception when an env
>>>>> var is not set, since it's very common for env vars to be optional,
>>>>> and it's not convenient to catch exceptions in haskell (I have to look
>>>> For true IO exceptions, you should be using the Prelude.catch mechanism.
>>> This still assumes that it's an exceptional condition that is being
>>> modeled. It is not; it is correctly modeled as a Maybe.
>> +1. And it?s always irritated me that read at EOF raises an
>> exception. Files having ends is not exceptional! (This is partly
>> addressed by iteratees, I imagine, but I haven?t found time to
>> get my head round those yet.)
> This irritates me too; I don't think that Haskell exceptions should be
> used for much of anything, exceptional condition or not.
> +1 for the proposal.
> Also, the unix-bytestring package
> (http://hackage.haskell.org/package/unix-bytestring) exposes IO
> functions that don't raise exceptions at EOF.
+1 for having getEnv return Maybe instead of throwing an exception.
More information about the Libraries