query
On this page

haskellPathsInDir

lib.filesystem.haskellPathsInDir

Docs pulled from | This Revision | 13 minutes ago


A map of all haskell packages defined in the given path, identified by having a cabal file with the same name as the directory itself.

Inputs

root

The directory within to search

Type

Path -> Map String Path

Noogle detected

Implementation

The following is the current implementation of this function.

haskellPathsInDir =
    root:
    let # Files in the root
        root-files = builtins.attrNames (builtins.readDir root);
        # Files with their full paths
        root-files-with-paths =
          map (file:
            { name = file; value = root + "/${file}"; }
          ) root-files;
        # Subdirectories of the root with a cabal file.
        cabal-subdirs =
          builtins.filter ({ name, value }:
            builtins.pathExists (value + "/${name}.cabal")
          ) root-files-with-paths;
    in builtins.listToAttrs cabal-subdirs;