cabal-auto-expose-0.1.0.0: Build time library that autodetects exposed modules

Distribution.Simple.AutoExpose

Description

Import this module in your Setup.hs to auto detect library modules in your project The API does not conceal it's internals but in most cases you should only need the functions and datatype under 'Quick Start Functions' (Distribution.Simple.AutoExpose). For more granular access the ones under 'Internal Functions' (Distribution.Simple.AutoExpose) are available but subject to change.

Synopsis

# Quick Start Functions

The common case top level function where this library is the only custom part of your project

import qualified Distribution.Simple.AutoExpose
main = AutoExpose.defaultMain

If you have already using custom UserHooks use this in your Setup.hs's main

import qualified Distribution.Simple.AutoExpose as AutoExpose
main = AutoExpose.defaultMainWithHooks myHooks

The common case top level function where this library is the only custom part of your project

It also generates an explicit Cabal file at /system-temp-directory/package-name-package-version-generated.cabal

import qualified Distribution.Simple.AutoExpose
main = AutoExpose.defaultMainGenerateCabal

If you have already using custom UserHooks use this in your Setup.hs's main and also provide a way to generate an explicit Cabal file.

import qualified Distribution.Simple.AutoExpose as AutoExpose
main = do
cabalWriter <- defaultWriteGeneratedCabal
AutoExpose.defaultMainWithHooksGenerateCabal cabalWriter myHooks

A datatype that wraps a function that outputs the name of the explicity generated Cabal file and an absolute path to a directory into which to write it.

Constructors

 WriteGeneratedCabal

Write the Cabal file to the system temp directory by default using defaultGeneratedCabalName for the filename.

# Internal Functions

Arguments

 :: [String] File extensions of valid Haskell modules, includes pre-processor extensions -> [FilePath] File paths to search -> [ModuleName]

Search for file paths that look like valid modules and convert to the components to the Cabal internal ModuleName.

Arguments

 :: HasCallStack => FilePath Directory to search (path must be absolute) -> [FilePath] Paths to ignore (paths must be absolute) -> IO [FilePath] File paths made relative to the search directory

Recursively collect the files in a directory, optionally excluding some files. Symlinks are ignored and collected paths are relative to the search directory, eg. if the search directory is /home/user/myproject/src the path /home/user/myproject/src/A/B/C.hs is returned as A/B/C.hs so it can converted by moduleNamesToExpose to a valid module name.

Captures the detected Haskell modules and signatures in a library

Constructors

 ExposedLib Fields

#### Instances

Instances details
 Source # Instance detailsDefined in Distribution.Simple.AutoExpose MethodsshowList :: [ExposedLib] -> ShowS #

The common pieces of GenericPackageDescription and PackageDescription which we need to auto detect Haskell modules and signatures. We can't make do with just the PackageDescription because the confHook which instantiates the library with signatures only has access to GenericPackageDescription.

#### Instances

Instances details
 Source # Instance detailsDefined in Distribution.Simple.AutoExpose Methods

Source directories for all non-library components (benchmarks, executables etc.) so that we can exclude their modules if they appear inside the library's source directory

indexWithNeighbors :: [a] -> [(a, [a])] Source #

Associate each item in a list will it's left and right elements, eg. > indexWithNeighbors [1,2,3,4] == [(1,[2,3,4]),(2,[1,3,4]),(3,[1,2,4]),(4,[1,2,3])]

Used to associate a source directory with possibly inner directories that should be ignored with searching for Haskell modules.

Arguments

 :: HasCallStack => [String] Known Haskell and/or preprocessor extensions -> [FilePath] The source trees for this component -> [[FilePath]] The source trees for all the other components -> IO [ModuleName] Detect modules in this component

Drill into the source trees for a component and find modules excluding the source trees for other components

Arguments

 :: HasCallStack => PackageDescriptionSubset -> UserHooks So we can grab the hookedPreProcessors extensions -> IO ExposedLib

Get a list of detected Haskell modules and signatures in the main library

Arguments

 :: HasCallStack => IO a The IO action that auto detects modules & signatures -> IO a

Since the hs-source-dirs fields in a .cabal file take a source tree path relative to the .cabal file itself we need to make sure the current working directory in which to search for module detection is the directory in which the .cabal file resides.

Update the exposed modules and signatures of a Library

Update the PackageDescription of this package to include auto detected library modules. Also just to be nice fill in the .. module in otherModules field of the library's BuildInfo.

Update the GenericPackageDescription of this package so the library can be properly instantiated with Backpack signatures at configure time when the confHook is run.

The default name to use when generating an explicit Cabal file It defaults to package-name-package-version-generated.cabal

Modify a set of UserHooks so that all relevant hooks see a PackageDescription or GenericPackageDescription with auto detected modules and signatures filled in.

Also optionally write an explicit Cabal file at confHook time.

The supported Haskell source extensions, currently hs and lhs

Backpack signature extensions, currently hsig and lhsig