FsMake


Make Module

Module for working with a Make

Types

Type Description

BaseBuilder

Base class for Make computation expression builders.

Builder

A Make computation expression builder.

This is used with MakeBuilders.make.

MemoBuilder

A computation expression builder for creating a memoized Make.

This is used with MakeBuilders.memo.

MemoRaceBuilder

A computation expression builder for creating a memoized Make with parallel access.

This is used with MakeBuilders.memoRace.

RetryBuilder

A computation expression builder for creating a retryable Make.

This is used with MakeBuilders.retry.

Functions and values

Function or value Description

bind binder make ctx

Full Usage: bind binder make ctx

Parameters:
Returns: Result<'U, MakeError> A new Make.

Takes a binder function to create a new Make from the result of an existing Make.

This is typically used in computation expressions automatically, but can be used manually.

binder : 'T -> Make<'U>

The binder function.

make : Make<'T>

The existing Make.

ctx : MakeContext

The current MakeContext.

Returns: Result<'U, MakeError>

A new Make.

Example

 let newMake : Make<unit> =
     let exampleMake : Make<string list> =
         fun (ctx: MakeContext) -> Ok ctx.ExtraArgs

     exampleMake |> Make.bind (fun args -> Cmd.createWithArgs "dotnet" args |> Cmd.run)

context arg0

Full Usage: context arg0

Parameters:
Returns: Result<MakeContext, MakeError> The Make contains a MakeContext.

Gets a Make that can be used to retrieve the current MakeContext.

This is typically used in computation expressions.

arg0 : MakeContext
Returns: Result<MakeContext, MakeError>

The Make contains a MakeContext.

Example

 let ctxMake =
     make {
         let! ctx = Make.context
         printfn "%s" ctx.PipelineName
     }

fail message arg2

Full Usage: fail message arg2

Parameters:
    message : string - The message to be printed as the failure reason.
    arg1 : MakeContext

Returns: Result<'T, MakeError> An ErrorMake

Fails the current Make with a message.

message : string

The message to be printed as the failure reason.

arg1 : MakeContext
Returns: Result<'T, MakeError>

An ErrorMake

Example

 let errMake =
     make {
         do! Make.fail "Oh no!"
     }

failMessages messages arg2

Full Usage: failMessages messages arg2

Parameters:
Returns: Result<'T, MakeError> An ErrorMake

Fails the current Make with a list of Message to be printed. This can be used to create detailed multi-line failures.

messages : Message list

The messages to be printed.

arg1 : MakeContext
Returns: Result<'T, MakeError>

An ErrorMake

Example

 let failMake =
     make {
         do!
             [ Console.error "Oh " |> Console.appendToken "no!" ]
             |> Make.failMessages
     }

map mapping make ctx

Full Usage: map mapping make ctx

Parameters:
Returns: Result<'U, MakeError> A new Make.

Takes a mapping function to create a new Make from the result of an existing Make.

This is typically used in computation expressions automatically, but can be used manually.

mapping : 'T -> 'U

The mapping function.

make : Make<'T>

The existing Make.

ctx : MakeContext

The current MakeContext.

Returns: Result<'U, MakeError>

A new Make.

Example

 let boolMake : Make<bool> =
     let stringMake : Make<string> =
         fun (ctx: MakeContext) -> Ok ctx.StepName

     stringMake |> Make.map (fun stepName -> stepName = "build")

memo make

Full Usage: memo make

Parameters:
    make : Make<'T> - The Make to memoize.

Returns: Make<'T> A new memoized Make.

Memoizes a Make so it is only executed once. Subsequent executions return the result immediately.

This only allows single access to the Make, so if it is run in parallel, only one will run and the rest will block until a result is available.

make : Make<'T>

The Make to memoize.

Returns: Make<'T>

A new memoized Make.

Example

 let versionMake =
     Cmd.createWithArgs "dotnet" [ "gitversion" ]
     |> Cmd.run
     |> Make.memo

memoRace make

Full Usage: memoRace make

Parameters:
    make : Make<'T> - The Make to memoize.

Returns: Make<'T> A new memoized Make.

Memoizes a Make so it is only executed once. Subsequent executions return the result immediately. Unlike Make.memo, this allows parallel executions to occur.

If it is run in parallel, it will be run multiple times until a result has been stored. Once a result has been stored, subsequent runs will immediately return the result.

make : Make<'T>

The Make to memoize.

Returns: Make<'T>

A new memoized Make.

Example

 let versionMake =
     Cmd.createWithArgs "dotnet" [ "gitversion" ]
     |> Cmd.result
     |> Make.memoRace

retry attempts make

Full Usage: retry attempts make

Parameters:
    attempts : int - The amount of attempts in total to try.
    make : Make<'T> - The Make to add retries to.

Returns: Make<'T> The new Make.

Creates a new Make from an existing one, that adds retry behaviour. This will "catch" all errors except for MakeError.MakeAbort.

attempts : int

The amount of attempts in total to try.

make : Make<'T>

The Make to add retries to.

Returns: Make<'T>

The new Make.

Example

 let cmdWithRetry =
     Cmd.createWithArgs "dotnet" [ "test" ]
     |> Cmd.run
     |> Make.retry 2

return' value arg2

Full Usage: return' value arg2

Parameters:
    value : 'T - The value to be wrapped.
    arg1 : MakeContext

Returns: Result<'T, MakeError> The wrapped value.

Wraps a value in a Make.

This is typically used in computation expressions automatically, but can be used manually.

value : 'T

The value to be wrapped.

arg1 : MakeContext
Returns: Result<'T, MakeError>

The wrapped value.

Example

 let wrappedValue : Make<int> = Make.return' 5

zero arg1

Full Usage: zero arg1

Parameters:
Returns: Result<unit, MakeError> An empty Make.

Creates an empty Make.

This is typically used in computation expressions automatically, but can be used manually.

arg0 : MakeContext
Returns: Result<unit, MakeError>

An empty Make.

Example

 let emptyMake : Make<unit> = Make.zero

zip make1 make2 ctx

Full Usage: zip make1 make2 ctx

Parameters:
Returns: Result<('T * 'T1), MakeError> The tupled result.

Takes two Make and creates a tuple Make of their results.

This is typically used in computation expressions automatically, but can be used manually.

make1 : Make<'T>

The first make.

make2 : Make<'T1>

The second make.

ctx : MakeContext

The current MakeContext.

Returns: Result<('T * 'T1), MakeError>

The tupled result.

Example

 let make1 = Make.zero
 let make2 = Make.zero

 let exampleMake : Make<unit * unit> = Make.zip make1 make2