Proposal: System.Environment.getEnv should return Maybe

Ryan Newton rrnewton at gmail.com
Thu Feb 23 04:17:56 CET 2012


+1

On Wed, Feb 22, 2012 at 6: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
> up Control.Exception every time, and then add LANGUAGE
> ScopedTypeVariables).  I wind up using 'fmap lookup k
> Environment.getEnvironment' instead.
>
> So I propose a function: lookupEnv :: String -> IO (Maybe String)
>
> Then getEnv can be deprecated and eventually removed.  Or maybe not if
> people want to argue the current getEnv is useful and deprecation
> warnings would be too annoying.
>
> Yeah, it's a trivial thing, but it's nice to sand off some of these rough
> edges.
>
> Discussion: 2 weeks, March 7
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20120222/e6368380/attachment.htm>


More information about the Libraries mailing list