Proposal: System.Environment.getEnv should return Maybe

Erik de Castro Lopo mle+hs at mega-nerd.com
Thu Feb 23 11:36:04 CET 2012


Evan Laforge 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)

+1

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the Libraries mailing list