suntheme/app/Getters.hs
q9i 76973ba364 refactor: create getters module
group helper funcs for creating directory names and fetching network resources into a single module
2024-07-22 15:39:35 -07:00

17 lines
513 B
Haskell

module Getters where
import Const (prog)
import System.FilePath ((</>))
import System.Directory (XdgDirectory(XdgCache, XdgConfig), getXdgDirectory)
import Control.Exception (SomeException, try)
import Network.HTTP.Request (Response, get)
pathToCache :: String -> IO String
pathToCache str = (</> str) <$> getXdgDirectory XdgCache prog
pathToConfig :: String -> IO String
pathToConfig str = (</> str) <$> getXdgDirectory XdgConfig prog
fetch :: String -> IO (Either SomeException Response)
fetch = try . get