dojang-0.2.1: A cross-platform dotfiles manager
Safe HaskellNone
LanguageHaskell2010

Dojang.Types.EnvironmentPredicate

Description

A predicate expression that can be used to match an environment, e.g., And [OperatingSystem "linux", Architecture "x86_64"].

Synopsis

Documentation

data EnvironmentPredicate Source #

A predicate that can be used to match an environment.

Constructors

Always

A predicate that always matches.

Not EnvironmentPredicate

A predicate that matches if the given predicate does not match.

And (NonEmpty EnvironmentPredicate)

A predicate that matches if all of the given predicates match.

Or (NonEmpty EnvironmentPredicate)

A predicate that matches if any of the given predicates match.

Moniker MonikerName

A predicate that matches to another moniker. Mostly used to eliminate duplication.

OperatingSystem OperatingSystem

A predicate that matches to the given operating system (e.g. linux). For a list of possible values, see the os field.

Architecture Architecture

A predicate that matches to the given architecture (e.g. x86_64). For a list of possible values, see the arch field.

KernelName (CI Text)

A predicate that matches to the given kernel name (e.g. Darwin).

KernelRelease (CI Text)

A predicate that exactly matches to the given kernel release (e.g. 23.1.0).

KernelReleasePrefix (CI Text)

A predicate that matches to the given kernel release prefix (e.g. 23.1 for 23.1.0).

KernelReleaseSuffix (CI Text)

A predicate that matches to the given kernel release suffix (e.g. amd64 for 4.19.0-16-amd64).

normalizePredicate :: EnvironmentPredicate -> EnvironmentPredicate Source #

Normalize an environment predicate by removing redundant predicates.

>>> normalizePredicate $ And [Not Always, Always]
Not Always
>>> normalizePredicate $ Or [Not Always, Always]
Always
>>> import Dojang.Types.MonikerName (parseMonikerName)
>>> let Right foo = parseMonikerName "foo"
>>> normalizePredicate $ And [Moniker foo, Not $ Moniker foo]
Not Always
>>> normalizePredicate $ Or [Moniker foo, Not $ Moniker foo]
Always
>>> let Right a = parseMonikerName "a"
>>> let Right b = parseMonikerName "b"
>>> let Right c = parseMonikerName "c"
>>> normalizePredicate $ And [Moniker a, And [Moniker b, Moniker c]]
And (Moniker (MonikerName "a") :| [Moniker (MonikerName "b"),Moniker (MonikerName "c")])