|
|
|
|
|
by nemetroid
2506 days ago
|
|
It's some time since I last worked in Haskell (and I never worked on anything useful), but I would write the function this way: getSocketAPIPort :: Int -> IO Int
getSocketAPIPort defaultPort = do
maybeEnvPort <- lookupEnv "socketPort"
return $ case maybeEnvPort of
Nothing -> defaultPort
Just port -> fromMaybe defaultPort (readMaybe port)
|
|