loadAccessToken :: IO HTTP.AccessToken
loadAccessToken = catch readFileIfExists whenNotFound
    where
        readFileIfExists = do
            userHome <- getHomeDirectory
            content <- readFile (accessTokenFile userHome)
            case readMaybe content of
              Just at -> return at
              Nothing -> throwIO NotAuthenticated
        whenNotFound :: IOException -> IO HTTP.AccessToken
        whenNotFound _ = throwIO NotAuthenticated
loadAccessToken :: IO HTTP.AccessToken
loadAccessToken = catch readFileIfExists whenNotFound
    where
        readFileIfExists = do
            userHome <- getHomeDirectory
            content <- readFile (accessTokenFile userHome)
            case readMaybe content of
              Just at -> return at
              Nothing -> throwIO NotAuthenticated
        whenNotFound :: IOException -> IO HTTP.AccessToken
        whenNotFound _ = throwIO NotAuthenticated
loadAccessToken = catch readFileIfExists whenNotFound
    where
        readFileIfExists = do
            userHome <- getHomeDirectory
            content <- readFile (accessTokenFile userHome)
            case readMaybe content of
              Just at -> return at
              Nothing -> throwIO NotAuthenticated
        whenNotFound :: IOException -> IO HTTP.AccessToken
        whenNotFound _ = throwIO NotAuthenticated