From c622af481e26f938db3f06a299d5b5bcb71bb12f Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 28 Aug 2024 20:26:02 +0300 Subject: [PATCH] feat(tvix/eval): allow external users to construct native thunks This interface is the only way to construct lazy builtins outside of eval, which is actually a useful feature to have. Change-Id: I386323af20aa3134bb4f669fa66fbb21e9b05fd4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12386 Reviewed-by: flokli Tested-by: BuildkiteCI Autosubmit: tazjin Reviewed-by: Yury Shvedov --- tvix/eval/src/value/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index aaa052306..2e78f20b4 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -888,6 +888,12 @@ impl Value { | Value::FinaliseRequest(_) => "an internal Tvix evaluator value".into(), } } + + /// Constructs a thunk that will be evaluated lazily at runtime. This lets + /// users of Tvix implement their own lazy builtins and so on. + pub fn suspended_native_thunk(native: Box Result>) -> Self { + Value::Thunk(Thunk::new_suspended_native(native)) + } } trait TotalDisplay {