Created
May 25, 2018 21:21
-
-
Save jfischoff/7ee09a7c30e61d6b93cac1baa7f833cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecordWildCards #-} | |
module TH where | |
import Language.Haskell.TH | |
import System.FilePath | |
import Control.Monad ((<=<)) | |
import System.Directory (getCurrentDirectory, canonicalizePath) | |
fileRelativeToAbsolute :: String -> Q Exp | |
fileRelativeToAbsolute = stringE <=< fileRelativeToAbsoluteStr | |
fileRelativeToAbsoluteStr :: String -> Q String | |
fileRelativeToAbsoluteStr relativeFilePath = do | |
Loc {..} <- location | |
currentDir <- runIO getCurrentDirectory | |
let baseDir = takeDirectory loc_filename | |
runIO $ canonicalizePath $ currentDir </> baseDir </> relativeFilePath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment