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

Dojang.Types.EnvironmentPredicate.Evaluate

Synopsis

Documentation

data EvaluationWarning Source #

A warning that occurred during evaluation.

Constructors

UndefinedMoniker MonikerName

A moniker was referenced that was not defined.

UnrecognizedOperatingSystem OperatingSystem

The operating system was not recognized.

UnrecognizedArchitecture Architecture

The architecture was not recognized.

evaluate Source #

Arguments

:: Environment

The Environment to evaluate against.

-> MonikerMap

The MonikerMap to resolve MonikerNames against.

-> EnvironmentPredicate

The EnvironmentPredicate to evaluate.

-> (Bool, [EvaluationWarning])

The result of the evaluation. The snd of the result is a list of warnings that occurred during evaluation. Note that warnings can be present even if the result is True.

Evaluates the given predicate against the given environment.

>>> import Dojang.Types.Environment (Environment (..))
>>> import Dojang.Types.MonikerMap (MonikerMap)
>>> import Dojang.Types.MonikerName (MonikerName, parseMonikerName)
>>> let (Right linuxAmd64) = parseMonikerName "linux-amd64"
>>> :{
let monikerMap =
      [ (linuxAmd64, And [OperatingSystem "linux", Architecture "x86_64"])
      ] :: MonikerMap
:}
>>> let environment = Environment "linux" "x86_64"
>>> evaluate environment monikerMap (OperatingSystem "linux")
(True,[])
>>> evaluate environment monikerMap (Architecture "aarch64")
(False,[])

The snd of the result is a list of warnings that occurred during evaluation:

>>> let (Right nonExistentMoniker) = parseMonikerName "non-existent"
>>> evaluate environment monikerMap (Moniker nonExistentMoniker)
(False,[UndefinedMoniker (MonikerName "non-existent")])

evaluate' Source #

Arguments

:: Environment

The Environment to evaluate against.

-> MonikerResolver

A function that resolves MonikerNames to EnvironmentPredicates.

-> EnvironmentPredicate

The EnvironmentPredicate to evaluate.

-> (Bool, [EvaluationWarning])

The result of the evaluation. The snd of the result is a list of warnings that occurred during evaluation. Note that warnings can be present even if the result is True.

Same as evaluate, but takes a resolver function instead of a MonikerMap.