LayeredHaskell-make-0.1.0.0: Superimposition of Happy and Haskell program fragments.
Copyright(c) Hangil Kim 2026
Kairon Johnson 2026
Leonidas Sallos 2026
Oscar Abelanet 2026
LicenseMIT
Maintainerkimhang@oregonstate.edu
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

LHMake.Data.Feature

Description

This module provides definitions for language features and operations on them, such as superimposition and combination generation. It also provides a number of definitions supporting the specification of dependencies between features.

Synopsis

Features

type FeatureName = String Source #

The name of a Feature.

type ModuleName = String Source #

The name of a Haskell module or Happy grammar (which itself denotes a Haskell module).

data Feature Source #

A language feature \(f\) is represented using four components: the files holding its Haskell modules, at most one Happy grammar file, and two nested sets of feature names that represent what \(f\) depends on, and in what cases \(f\) is automatically enabled.

dependsOn and impliedBy use conjunctive and disjunctive normal form respectively as those choices lead to the most "natural" implementation.

dependsOn
...denotes all conditions holding.
impliedBy
...denotes some condition holding.

See feature.

Constructors

Feature 

Fields

feature Source #

Arguments

:: String

A short description of \(f\). See descrip.

-> [FilePath]

Haskell source files (specified relatively, e.g. E/AbsSyn.hs). See modules.

-> Maybe FilePath

A Happy grammar, if any (specified relatively, e.g. E/Parser.y). See grammar.

-> Dependency

What \(f\) depends on. See dependsOn.

-> Dependency

What implies \(f\). See impliedBy.

-> Bool

Whether \(f\) may only be enabled automatically. See hidden.

-> Feature 

Builds a Feature \(f\) specified in terms of values of type Dependency. The two Dependency arguments are automatically converted into the respective normal forms. See cnf and dnf.

The filepaths feature expects should be written relative to LayeredHaskell-make/src/LH/Feature/.

Note that since feature takes Dependency arguments, it's easier to construct features using this over the original constructor Feature.

Registries

type Registry = Map FeatureName Feature Source #

A registry maps names to their Features.

registry :: Registry Source #

The set of all features.

Features

Expand

Layered Haskell defines the following features. Hidden features are italicized.

E
Expressions. All other features, whether it be directly or indirectly, depends on E.
B
Basic types, namely Int and Bool. Depends on E.
D
(Monomorphic) algebraic datatypes. Depends on E.
F
Functions and basic pattern matching. Depends on B or D.
C
Case expressions. Implied by F and D.
P
Prenex polymorphism (with implicit foralls). Depends on D.
L
List and tuple syntax. Depends on F and D.

Superimposing features

type FeatureSet = Set FeatureName Source #

A feature set is a set of features, which we simply identify by their names.

resolve :: Registry -> FeatureSet -> LHsMakeError [FeatureName] Source #

Decides which features are really needed for a selection.

resolve generates an error if any of the following are true.

  • One or more hidden features were manually enabled.
  • The registry is ill-formed in that it contains unknown features.
  • The enabled features have dependencies that cannot be unambiguously resolved.

The last case occurs when, say, a feature A depends on features B or C, but only A was manually enabled. To avoid an arbitrary choice between B and C, an error is emitted.

superimpose :: [FeatureName] -> FilePath -> IO () Source #

Superimposes features (and implicit dependencies), and outputs files to a specified directory. The directory should written in the format of, say, src/LH/Feature, since superimpose simply appends it to the front of the filepath using (</>).

Note that superimpose will write to a file only if its contents have changed.

Listing features

list :: IO () Source #

Lists all non-hidden features in the registry including their descriptions. See descrip.

listAll :: IO () Source #

Lists all features, including hidden ones, in the registry including their descriptions. See descrip.

listDeps :: IO () Source #

Lists all feature dependencies and implications.

Listing feature combinations

combos :: LHsMakeError [[(FeatureName, Bool)]] Source #

Generates a list of all feature combinations.

The Boolean paired with a FeatureName is True when the feature must be enabled manually.

generate :: IO () Source #

Generates and prints a list of all possible (non-redundant) feature combinations, with dependencies and implications automatically resolved. Dependencies that must be manually enabled are printed in color.

generateCombos :: IO [[FeatureName]] Source #

Produces the feature combinations colored by generate.

One can interpret generateCombos as a filtering of combos lifted into the IO monad.

Dependencies

data Dependency Source #

A dependency is expressed as a Boolean formula of feature names.

Constructors

None

A dependency that can always be satisfied.

Has FeatureName

A dependency on a single feature.

All [Dependency]

All specified dependencies must be satisfied.

Any [Dependency]

At least one specified dependency must be satisfied.

Instances

Instances details
Show Dependency Source # 
Instance details

Defined in LHMake.Data.Feature

Eq Dependency Source # 
Instance details

Defined in LHMake.Data.Feature

Convenient synonyms

(/\) :: Dependency -> Dependency -> Dependency infixr 3 Source #

A convenient synonym for describing a conjunction of dependencies, that is, A /\ B means A and B must be enabled.

(\/) :: Dependency -> Dependency -> Dependency infixr 2 Source #

A convenient synonym for describing a disjunction of dependencies, that is, A \/ B means A or B must be enabled.

Normalization

cnf :: Dependency -> Set (Set FeatureName) Source #

Computes the conjunctive normal form (CNF) of a Dependency. See dependsOn.

CNF denotes a set of requirements, each a set of features that must all be enabled.

dnf :: Dependency -> Set (Set FeatureName) Source #

Computes the disjunctive normal form (DNF) of a Dependency. See impliedBy.

DNF denotes a set of alternatives, each a set of features that of which one must be enabled.