about summary refs log tree commit diff
path: root/nix/yants/default.nix (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-02-19 r/2222 fix(nix/yants): make (typedef …).checkType return a result setsterni1-3/+7
Previously, for types defined using typedef (like all primitive types) type.checkType would return a boolean. This is largely fine since in most places `type.checkToBool (type.checkType x)` or similar is used. However, some functions actually take type.checkType up on the promise that it returns a set of the form: { ok = <bool>; err = <option string>; } This is the case for restrict which has checkToBool = v: v.ok; and will generate a proper set except if `t.checkToBool (t.checkType v) == false` in which case it will return t.checkType v. If t was a primitive type or defined using typedef, previously `t.checkType v` would be a boolean which meant as soon as (restrict …).checkToBool was called on a restrict checkType result in cases where the wrapped type didn't match, an unrelated error would be thrown: nix-repl> with nix.yants; restrict "foo" (_: true) int "lol" error: value is a boolean while a set was expected, at /home/lukas/src/depot/nix/yants/default.nix:38:39 This is fixed by making typedef return a proper set from checkType and adjusting its checkToBool accordingly. Unfortunately I don't think we can easily add test cases for this except by using recursive nix or VM tests as there is no way to introspect error messages. Change-Id: I96a7be065630f04ca33358f21809284911ec14fe Reviewed-on: https://cl.tvl.fyi/c/depot/+/2536 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-03 r/2050 feat(nix/yants): add restrictProfpatsch1-0/+23
`restrict` uses a predicate function to restrict a type, giving the restricting a descriptive name in the process. First, the wrapped type definition is checked (e.g. int) and then the value is checked with the predicate, so the predicate can already depend on the value being of the wrapped type. Change-Id: Ic3edde45a8f34c31bc164414580d0a1aa5a821d5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2312 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: tazjin <mail@tazj.in>
2020-06-27 r/1103 feat(nix/yants): add unit typeProfpatsch1-0/+1
Has one less value than bool. Change-Id: I2f2db07b1eb1f49172942bc1d8c6ceb30d987d84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/661 Reviewed-by: tazjin <mail@tazj.in>
2019-12-20 r/249 fix(yants): Allow extra import argumentsVincent Ambo1-1/+1
Required for readTree compatibility.
2019-12-20 chore(yants): Prepare for depot-mergeVincent Ambo1-0/+298
Yants is being integrated at //depot/nix/yants