examples icon indicating copy to clipboard operation
examples copied to clipboard

example suggestion: avoiding `{} <-` `|> await` boilerplate

Open Anton-4 opened this issue 1 year ago • 0 comments

We should make an example for this once we figure it out ourselves :p

Example of a problematic case:

{} <- log "Extracting current rust version from rust-toolchain.toml..." |> await
{ stable: currentStable, nightly: currentNightly } <- getCurrentVersionsFromToml |> await
{} <- log "Found versions:\n\t- stable: \(versionToStr currentStable)\n\t- nightly with date: \(dateToStr currentNightly)" |> await
# TODO Task.map to avoid repeated `{} <-`?
{} <- log "Searching for nightly matching stable-\(newRustVersion)..." |> await

newNightly <-
    findMatchingNigthly (versionFromStr newRustVersion) currentNightly
    |> await

{} <- log "New nightly: nightly-\(dateToStr newNightly)" |> await

TODO can we avoid boiler plate of `{} <-` and `await` here?
{} <-
    Path.fromStr "rust-toolchain.toml"
    |> updateToml newRustVersion
    |> await

{} <-
    Path.fromStr "examples/platform-switching/rust-platform/rust-toolchain.toml"
    |> updateToml newRustVersion
    |> await

{} <-
    Path.fromStr "Earthfile"
    |> updateEarthFile newRustVersion
    |> await

Anton-4 avatar Aug 30 '23 17:08 Anton-4