cartel-0.2.0.0: Specify your Cabal files in Haskell

Safe HaskellNone

Cartel.Tools

Contents

Synopsis

Building constraints

Helpers to build many common version constraints.

Building constraint trees

Building package specifications

closedOpenSource

Arguments

:: String

Package name

-> [Int]

Version number for lower bound

-> [Int]

Version number for upper bound

-> Package

Resulting contraints

Creates a package interval that is closed on the left, open on the right. Useful for the common case under the PVP to specify that you depend on a version that is at least a particular version, but less than another version.

 closedOpen "bytestring" [0,17] [0,19] ==> bytestring >= 0.17 && < 0.19

apiVersion :: String -> [Int] -> PackageSource

Specifies a particular API version. Useful to lock your package dependencies down to a particular API version.

 apiVersion "base" [1] ==> base >= 1 && < 2
 apiVersion "base" [1,2] ==> base >= 1.2 && < 1.3
 apiVersion "base" [1,2,3] ==> base >= 1.2.3 && < 1.2.4

nextBreaking :: String -> [Int] -> PackageSource

Depends on the version given, up to the next breaking API change.

 nextBreaking "base" [4] ==> base >= 4 && < 4.1
 nextBreaking "base" [4,1] ==> base >= 4.1 && < 4.2
 nextBreaking "base" [4,7,0,0] ==> base >= 4.7.0.0 && < 4.8

nextMajor :: String -> [Int] -> PackageSource

Depends on the version given, up to the next time the first digit increments. Useful for base.

 nextBreaking "base" [4] ==> base >= 4 && < 5

exactly :: String -> [Int] -> PackageSource

Depends on exactly this version only.

 exactly "base" [4,5,0,0] ==> base ==4.5.0.0

Rendering a cabal file

renderSource

Arguments

:: String

The name of the program used to produce this output. Put the name of your script here so it can appear in the output. This is optional; to omit it, use the empty string here.

-> Cabal 
-> IO () 

Render a Cabal file to standard output. The output will have comments at the beginning indicating that it was built with Cartel, and what version of the Cartel library was used, and when the output was produced, along with (optionally) the filename of the program used to produce the output.

Ensures that the output is UTF-8, as required by Cabal.

renderStringSource

Arguments

:: String

Name of program used

-> ZonedTime

When this output is being created

-> Version

Cartel package version

-> Cabal 
-> String 

Renders a Cabal data type as a string.

Getting a list of all modules in a directory tree

modulesSource

Arguments

:: FilePath

Start searching within this directory.

-> IO [String]

A list of Haskell modules in the given directory tree. The file contents are not examined; only the file names matter. Returned as a list of dotted names.

Gets all Haskell modules in a given directory tree. Only files with one of the extensions listed in fileExtensions are returned. Files and directories that do not begin with an uppercase letter are ignored. (This also ignores files that start with a dot.) Directories with a dot anywhere in the name are ignored.

fileExtensions :: [String]Source

Common extensions of Haskell files and files that are preprocessed into Haskell files. Includes:

  • hs (Haskell) * lhs (literate Haskell) * gc (greencard) * chs (c2hs) * hsc (hsc2hs) * y and ly (happy) * x (alex) * cpphs

modulesWithExtensionsSource

Arguments

:: [String]

Look for files that have one of these extensions. fileExtensions covers the most common cases. Files without one of these extensions are ignored. Files and directories that do not begin with an uppercase letter are ignored. (This also ignores files that start with a dot.) Directories with a dot anywhere in the name are ignored.

-> FilePath

Start searching within this directory.

-> IO [String]

A list of Haskell modules in the given directory tree. The file contents are not examined; only the file names matter. Returned as a list of dotted names.

Gets all Haskell modules in a given directory tree. Allows you to specify what extensions you are interested in.