hasura / kriti-lang

A minimal JSON templating language
Apache License 2.0
56 stars 9 forks source link

Feature/new operators #42

Closed solomon-b closed 2 years ago

solomon-b commented 2 years ago

This is PR adds the additional standard operators from #37 without making any of the syntactic changes. This half of the RFC is entirely non-controversial so I think we may as well merge it right away.

It adds >=, <=, not, and in.

> runKriti  "{{ if \"foo\" in [\"foo\"] }} 1 {{ else }} 0 {{ end }}" []
Right (Number 1.0)

> runKriti  "{{ if 7 in [7] }} 1 {{ else }} 0 {{ end }}" []
Right (Number 1.0)

> runKriti  "{{ if \"foo\" in { \"foo\": true } }} 1 {{ else }} 0 {{ end }}" []
Right (Number 1.0)

> runKriti  "{{ if 2 >= 1 }} 1 {{ else }} 0 {{ end }}" []
Right (Number 1.0)

> runKriti  "{{ if not 2 >= 1 }} 1 {{ else }} 0 {{ end }}" []
Right (Number 0.0)
jkachmar commented 2 years ago

I just had one question on the RFC (cf. https://github.com/hasura/kriti-lang/pull/37#issuecomment-1011124394), but otherwise this PR makes sense to me!

I'll add an approval here when/if you get a chance to check whether what I said makes any sense.