Skip to content

Conditional contract definition #851

Answered by yannham
oneingan asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

I think this is related to #459. Indeed CUE does have a specific constructs to conditionally define part of contract depending on other fields. It's not totally obvious how to implement this for Nickel, so for now, we don't have that yet.

I think your approach is actually not that bad 🙂 since you can write arbitrary expressions for contract, if you'd like, you can actually inline the condition, which in the end kinda resembles the if construct of CUE:

let Component = {
  name | Str,
  type | [| `webservice, `database |],
  properties
    | (if (type == `webservice) then
        webserviceProperties
      else
        databaseProperties),
} in

It's maybe not totally satisfying, but at…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@oneingan
Comment options

@yannham
Comment options

Answer selected by oneingan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants