th-utilities-0.2.4.0: Collection of useful functions for use with Template Haskell

TH.RelativePaths

Description

Normally when building a cabal package, GHC is run with its current directory set at the package's root directory. This allows using relative paths to refer to files. However, this becomes problematic when you want to load modules from multiple projects, such as when using "stack ghci".

This solves the problem by getting the current module's filepath from TH via location. It then searches upwards in the directory tree for a .cabal file, and makes the provided path relative to the folder it's in.

Synopsis

# Documentation

Reads a file as a strict ByteString. The path is specified relative to the package's root directory, and addDependentfile is invoked on the target file.

Reads a file as a lazy ByteString. The path is specified relative to the package's root directory, and addDependentfile is invoked on the target file.

Reads a file as a strict Text. The path is specified relative to the package's root directory, and addDependentfile is invoked on the target file.

Reads a file as a lazy Text. The path is specified relative to the package's root directory, and addDependentfile is invoked on the target file.

Reads a file as a String. The path is specified relative to the package's root directory, and addDependentfile is invoked on the target file.

Runs the Q action, temporarily setting the current working directory to the root of the cabal package.

This utility takes a path that's relative to your package's cabal file, and resolves it to an absolute location.

Note that this utility does _not_ invoke qAddDependentFile.

Given the path to a file or directory, search parent directories for a .cabal file.