module GHC.Debug.Convention (socketDirectory, snapshotDirectory, ghcDebugDirectory) where

import System.FilePath
import System.Directory

-- | The default socket directory in which to place unix domain sockets in
-- ghc-debug-stub. This is currently your XDG data directory.
ghcDebugDirectory :: IO FilePath
ghcDebugDirectory :: IO FilePath
ghcDebugDirectory = do
    FilePath
xdgDir <- XdgDirectory -> FilePath -> IO FilePath
getXdgDirectory XdgDirectory
XdgData FilePath
""
    FilePath -> IO FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return (FilePath
xdgDir FilePath -> FilePath -> FilePath
</> FilePath
"ghc-debug/debuggee/")

socketDirectory :: IO FilePath
socketDirectory :: IO FilePath
socketDirectory = (FilePath -> FilePath -> FilePath
</> FilePath
"sockets")  (FilePath -> FilePath) -> IO FilePath -> IO FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO FilePath
ghcDebugDirectory

snapshotDirectory :: IO FilePath
snapshotDirectory :: IO FilePath
snapshotDirectory = (FilePath -> FilePath -> FilePath
</> FilePath
"snapshots")  (FilePath -> FilePath) -> IO FilePath -> IO FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO FilePath
ghcDebugDirectory