# dep-t-value Pair resources files with types within your program. Part of the [dep-t-framework](https://github.com/danidiaz/dep-t-framework). ## How to use - Take a datatype that you want to associate to a resource file, and derive a `Dep.Resource.FromResource` instance for it. - Make your program logic take a `Value yourdatatype` record. - When assembling the global application environment, - Use `dataDirLoader` to define a `Loader` that searches for resource files by following the datatype's module path, and uses the dataype's name as file name. - Build the `Value yourdatatype` by using functions form `Dep.Value.JSON` or `Dep.Value.Text`. ## Links - the built-in [`Paths_pkgname` mechanism for accessing data files from package code](https://cabal.readthedocs.io/en/latest/cabal-package.html#accessing-data-files-from-package-code). - the [data-files](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-data-files) cabal field. > If you decide to import the Paths_pkgname module then it must be listed > in the other-modules field just like any other module in your package and > on autogen-modules as the file is autogenerated. - the [data-dir](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-data-dir) cabal field. - [prefix-independence](https://cabal.readthedocs.io/en/latest/setup-commands.html#prefix-independence) - [Paths in the simple build system](https://cabal.readthedocs.io/en/latest/setup-commands.html?#paths-in-the-simple-build-system) - GitHub issue: [Rework data-file handling to be file-embed-like?](https://github.com/haskell/cabal/issues/6096) - Another issue, opened by me: [Questions about prefix-independence for data files](https://github.com/haskell/cabal/issues/7888). - The "prefix-independence" feature seems to be in bad shape: when ("${pkgroot}" `isPrefixOf` prefix dirs) $ warn verbosity $ "Using ${pkgroot} in prefix " ++ prefix dirs ++ " will not work if you rely on the Path_* module " ++ " or other hard coded paths. Cabal does not yet " ++ " support fully relocatable builds! " ++ " See #462 #2302 #2994 #3305 #3473 #3586 #3909" ++ " #4097 #4291 #4872" - However, overriding the data dir using an environment variable is different from "prefix-independence" and it [*does* work](https://cabal.readthedocs.io/en/3.6/cabal-package.html?highlight=data-files#accessing-data-files-from-package-code): > The actual location of all these directories can be individually overridden at runtime using environment variables of the form pkg_name_var, where pkg_name is the name of the package with all hyphens converted into underscores, and var is either bindir, libdir, dynlibdir, datadir, libexedir or sysconfdir. For example, the configured data directory for pretty-show is controlled with the pretty_show_datadir environment variable. - [file-embed: Use Template Haskell to embed file contents directly.](https://hackage.haskell.org/package/file-embed) - [data-embed: Embed files and other binary blobs inside executables without Template Haskell.](https://hackage.haskell.org/package/data-embed)