Skip to content

Commit

Permalink
Add helper to add-tags to all steps
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaymankar committed Feb 25, 2020
1 parent b0162f1 commit 152dd52
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 69 deletions.
80 changes: 80 additions & 0 deletions helpers/addTags.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
let Prelude = ../lib/prelude.dhall

let Types = ../types/package.dhall

let Step = Types.Step

let StepConstructors = Types.StepConstructors

let translateHooks = ./translateHooks.dhall

let mergeTags
: Optional (List Text) List Text Optional (List Text)
= λ(origTags : Optional (List Text))
λ(newTags : List Text)
Some
( merge
{ None = newTags
, Some =
λ(tags : List Text)
Prelude.List.concat Text [ tags, newTags ]
}
origTags
)

let addTagsToGet
: List Text Types.GetStep Types.StepHooks Step Step
= λ(tags : List Text)
λ(g : Types.GetStep)
λ(h : Types.StepHooks Step)
λ(S : Type)
λ(c : StepConstructors S)
c.get (g { tags = mergeTags g.tags tags }) (translateHooks S c h)

let addTagsToPut
: List Text Types.PutStep Types.StepHooks Step Step
= λ(tags : List Text)
λ(p : Types.PutStep)
λ(h : Types.StepHooks Step)
λ(S : Type)
λ(c : StepConstructors S)
c.put (p { tags = mergeTags p.tags tags }) (translateHooks S c h)

let addTagsToTask
: List Text Types.TaskStep Types.StepHooks Step Step
= λ(tags : List Text)
λ(t : Types.TaskStep)
λ(h : Types.StepHooks Step)
λ(S : Type)
λ(c : StepConstructors S)
c.task (t { tags = mergeTags t.tags tags }) (translateHooks S c h)


let addTagsToStep
: List Text Step Step
= λ(tags : List Text)
λ(s : Step)
s
Step
{ get = addTagsToGet tags
, put = addTagsToPut tags
, task = addTagsToTask tags
, aggregate = ./aggregateWithHooks.dhall
, do = ./doWithHooks.dhall
, try = ./tryWithHooks.dhall
, in_parallel = ./inParallelWithHooks.dhall
}

let addTags
: List Text List Types.Job List Types.Job
= λ(tags : List Text)
Prelude.List.map
Types.Job
Types.Job
( λ(j : Types.Job)
j
{ plan = Prelude.List.map Step Step (addTagsToStep tags) j.plan
}
)

in addTags
15 changes: 3 additions & 12 deletions helpers/aggregateWithHooks.dhall
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
let Types = ../types/package.dhall

let Prelude = ../lib/prelude.dhall

in ( λ(steps : List Types.Step)
λ(hooks : Types.StepHooks Types.Step)
λ(Step : Type)
λ(constructors : Types.StepConstructors Step)
let stepTypeFix =
Prelude.List.map
Types.Step
Step
(λ(s : Types.Step) s Step constructors)
steps

in constructors.aggregate
stepTypeFix
(./translateHooks.dhall hooks Step constructors)
constructors.aggregate
(./translateSteps.dhall Step constructors steps)
(./translateHooks.dhall Step constructors hooks)
)
: List Types.Step Types.StepHooks Types.Step Types.Step
15 changes: 3 additions & 12 deletions helpers/doWithHooks.dhall
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
let Types = ../types/package.dhall

let Prelude = ../lib/prelude.dhall

let doStep
: List Types.Step Types.StepHooks Types.Step Types.Step
= λ(steps : List Types.Step)
λ(hooks : Types.StepHooks Types.Step)
λ(Step : Type)
λ(constructors : Types.StepConstructors Step)
let stepTypeFix =
Prelude.List.map
Types.Step
Step
(λ(s : Types.Step) s Step constructors)
steps

in constructors.do
stepTypeFix
(./translateHooks.dhall hooks Step constructors)
constructors.do
(./translateSteps.dhall Step constructors steps)
(./translateHooks.dhall Step constructors hooks)

in doStep
2 changes: 1 addition & 1 deletion helpers/getWithHooks.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ in ( λ(getStep : Types.GetStep)
λ(constructors : Types.StepConstructors Step)
constructors.get
getStep
(./translateHooks.dhall hooks Step constructors)
(./translateHooks.dhall Step constructors hooks)
)
: Types.GetStep Types.StepHooks Types.Step Types.Step
35 changes: 3 additions & 32 deletions helpers/inParallelWithHooks.dhall
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
let Types = ../types/package.dhall

let Prelude = ../lib/prelude.dhall

let typeFixSteps
: (T : Type) Types.StepConstructors T List Types.Step List T
= λ(T : Type)
λ(constructors : Types.StepConstructors T)
Prelude.List.map Types.Step T (λ(s : Types.Step) s T constructors)

let typeFix
: (T : Type)
Types.StepConstructors T
Types.InParallelStep Types.Step
Types.InParallelStep T
= λ(T : Type)
λ(constructors : Types.StepConstructors T)
λ(parallel : Types.InParallelStep Types.Step)
merge
{ Steps =
λ(s : List Types.Step)
(Types.InParallelStep T).Steps (typeFixSteps T constructors s)
, Config =
λ(cfg : Types.InParallelConfig Types.Step)
(Types.InParallelStep T).Config
(cfg { steps = typeFixSteps T constructors cfg.steps })
}
parallel

let inParallelWithHooks
: Types.InParallelStep Types.Step Types.StepHooks Types.Step Types.Step
= λ(parallelSteps : Types.InParallelStep Types.Step)
λ(hooks : Types.StepHooks Types.Step)
λ(Step : Type)
λ(constructors : Types.StepConstructors Step)
let stepTypeFix = typeFix Step constructors parallelSteps

in constructors.in_parallel
stepTypeFix
(./translateHooks.dhall hooks Step constructors)
constructors.in_parallel
(./translateInParallelStep.dhall Step constructors parallelSteps)
(./translateHooks.dhall Step constructors hooks)

in inParallelWithHooks
3 changes: 3 additions & 0 deletions helpers/package.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
, tryWithHooks =
./tryWithHooks.dhall sha256:b1808275879f924e73fd9c12393f04a9563c8f1a74743f5ac125d9849b912b0d
? ./tryWithHooks.dhall
, addTags =
./addTags.dhall sha256:e802dce26e2b99c4dd7c529baa520b95199916e3b4a0733eabbb1d31d975e7a4
? ./addTags.dhall
}
2 changes: 1 addition & 1 deletion helpers/putWithHooks.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ in ( λ(putStep : Types.PutStep)
λ(constructors : Types.StepConstructors Step)
constructors.put
putStep
(./translateHooks.dhall hooks Step constructors)
(./translateHooks.dhall Step constructors hooks)
)
: Types.PutStep Types.StepHooks Types.Step Types.Step
2 changes: 1 addition & 1 deletion helpers/taskWithHooks.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ in ( λ(taskStep : Types.TaskStep)
λ(constructors : Types.StepConstructors Step)
constructors.task
taskStep
(./translateHooks.dhall hooks Step constructors)
(./translateHooks.dhall Step constructors hooks)
)
: Types.TaskStep Types.StepHooks Types.Step Types.Step
8 changes: 4 additions & 4 deletions helpers/translateHooks.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ let Types = ../types/package.dhall
let Prelude = ../lib/prelude.dhall

let translateHooks
: Types.StepHooks Types.Step
(S : Type)
: (S : Type)
Types.StepConstructors S
Types.StepHooks Types.Step
Types.StepHooks S
= λ(hooks : Types.StepHooks Types.Step)
λ(S : Type)
= λ(S : Type)
λ(constructors : Types.StepConstructors S)
λ(hooks : Types.StepHooks Types.Step)
let translateOptionalStep =
Prelude.Optional.map
Types.Step
Expand Down
26 changes: 26 additions & 0 deletions helpers/translateInParallelStep.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
let Types = ../types/package.dhall

let translateInParallelStep
: (T : Type)
Types.StepConstructors T
Types.InParallelStep Types.Step
Types.InParallelStep T
= λ(T : Type)
λ(constructors : Types.StepConstructors T)
λ(parallel : Types.InParallelStep Types.Step)
merge
{ Steps =
λ(s : List Types.Step)
(Types.InParallelStep T).Steps
(./translateSteps.dhall T constructors s)
, Config =
λ(cfg : Types.InParallelConfig Types.Step)
(Types.InParallelStep T).Config
( cfg
{ steps = ./translateSteps.dhall T constructors cfg.steps
}
)
}
parallel

in translateInParallelStep
13 changes: 13 additions & 0 deletions helpers/translateSteps.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let Step = ../types/Step.dhall

let StepConstructors = ../types/StepConstructors.dhall

let Prelude = ../lib/prelude.dhall

let translateSteps
: (S : Type) StepConstructors S List Step List S
= λ(S : Type)
λ(c : StepConstructors S)
Prelude.List.map Step S (λ(s : Step) s S c)

in translateSteps
8 changes: 3 additions & 5 deletions helpers/tryWithHooks.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ let tryStep
λ(hooks : Types.StepHooks Types.Step)
λ(Step : Type)
λ(constructors : Types.StepConstructors Step)
let stepTypeFix = step Step constructors

in constructors.try
stepTypeFix
(./translateHooks.dhall hooks Step constructors)
constructors.try
(step Step constructors)
(./translateHooks.dhall Step constructors hooks)

in tryStep
2 changes: 1 addition & 1 deletion package.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
./schemas/package.dhall sha256:bf3838a202e3d5d7f5b764229b069423ec54d2c6a8ea1658a1036ad855750bbd
? ./schemas/package.dhall
, helpers =
./helpers/package.dhall sha256:334d50f7b6248b79c2d9c944d49dd60cb5ccd6e2812f42a83d4282eb6cf9a299
./helpers/package.dhall sha256:a67c79710e278028af87b35e9320224a6b217540126b5fc7095a67ce416c0068
? ./helpers/package.dhall
, render =
./render/package.dhall sha256:102ffaeffabf83db684c6c1ee9c30023ad080aea4a776328f6fd7d3a8d4b1309
Expand Down

0 comments on commit 152dd52

Please sign in to comment.