diff options
Diffstat (limited to 'HostName.hs')
| -rw-r--r-- | HostName.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/HostName.hs b/HostName.hs new file mode 100644 index 00000000..dfe9efb4 --- /dev/null +++ b/HostName.hs @@ -0,0 +1,16 @@ +module HostName where + +import Data.Maybe +import Control.Applicative +import System.Environment + +import qualified Utility.Network as Network + +type HostName = String + +getHostName :: IO HostName +getHostName = go =<< getArgs + where + go (h:_) = return h + go [] = fromMaybe nohostname <$> Network.getHostname + nohostname = error "Cannot determine hostname! Pass it on the command line." |
