git-annex/Utility/Network.hs
Joey Hess ec267aa1ea rejigger imports for clean build with ghc 7.10's AMP changes
The explict import Prelude after import Control.Applicative is a trick
to avoid a warning.
2015-05-10 16:20:30 -04:00

22 lines
505 B
Haskell

{- network functions
-
- Copyright 2012 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
module Utility.Network where
import Utility.Process
import Utility.Exception
import Control.Applicative
import Prelude
{- Haskell lacks uname(2) bindings, except in the
- Bindings.Uname addon. Rather than depend on that,
- use uname -n when available. -}
getHostname :: IO (Maybe String)
getHostname = catchMaybeIO uname_node
where
uname_node = takeWhile (/= '\n') <$> readProcess "uname" ["-n"]