cartel-0.10.0.2: Specify your Cabal files in Haskell

Safe HaskellNone

Cartel.Tools

Contents

Synopsis

Logic trees

class LogicTree a whereSource

Methods

(&&&) :: a -> a -> aSource

(|||) :: a -> a -> aSource

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

Field class

class Field a whereSource

Things that can be an item in a field in a Cabal file.

Methods

conditional :: CondBlock a -> aSource

Takes a conditional block and wraps it in the field type.

buildInfo :: BuildInfoField -> aSource

Takes a build information field and wraps it in the field type.

Conditionals

cifSource

Arguments

:: Field a 
=> CondTree

Condition to satisfy

-> [a]

Use these results if condition is true

-> [a]

Use these results if condition if false

-> a 

Builds if statements. Use with the following functions, such as flag, to make it easy to build conditional blocks. For example:

 cif (flag "buildExe") [buildable True] [buildable False]

A little more complicated:

 cif (flag "buildExe" &&& system "windows")
   [buildable True] [buildable False]

system :: String -> CondTreeSource

Operating system; tested against System.Info.os on the target system.

arch :: String -> CondTreeSource

Argument is matched against System.Info.arch on the target system.

impl :: Compiler -> Maybe ConstrTree -> CondTreeSource

Tests for the configured Haskell implementation.

flag :: String -> CondTreeSource

Evaluates to the current assignment of the flag of the given name. Flag names are case insensitive. Testing for flags that have not been introduced with a flag section is an error.

true :: CondTreeSource

Always true.

false :: CondTreeSource

Always false.

Build info builders

includes :: Field a => [String] -> aSource

cSources :: Field a => [String] -> aSource

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.