Monday 30 May 2016

Haskell: getHomeDirectory: get user home directory

System.Directory module provides getHomeDirectory function to get the user home directory. Following is the signature of getHomeDirectory function.

Prelude System.Directory> :t getHomeDirectory
getHomeDirectory :: IO FilePath

As per documentation, you may get following errors while working with getHomeDirectory.

Error
Description
UnsupportedOperation
The operating system has no notion of home directory.
isDoesNotExistError
The home directory for the current user does not exist, or cannot be found.

Prelude System.Directory> getHomeDirectory
"/Users/harikrishna_gurram"

Note

On Unix, getHomeDirectory returns the value of the HOME environment variable. On Windows, the system is queried for a suitable path; a typical path might be C:/Users/<user>.


Previous                                                 Next                                                 Home

No comments:

Post a Comment