-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running functions? #208
Comments
The best would be if we could support that in |
I was thinking of running the function on every keypress, so yeah, it would technically work, but.. it's an ugly solution IMHO. The only values I'd pass back and forth would be nats, so data conversion wouldn't be a huge problem! Would this require so much code that I'd have to change it a lot on each revision of the crate? |
This is not ideal but you can do the function application in Dhall: fn run_dhall_fn(func: &str, input: u64) -> serde_dhall::Result<u64> {
let input = serde_dhall::serialize(&input).to_string()?;
serde_dhall::from_str(&format!("({}) {}", func, input)).parse()
}
fn main() {
assert_eq!(run_dhall_fn("λ(x : Natural) -> x + 3", 5).unwrap(), 8);
} If you need higher performance by only doing parsing, import resolution and typechecking once, then I think you'll have to use the less stable |
I realize that the internal dhall crate is not stable, but I'd like to parse a function, then run it multiple times with different inputs. Is this possible? Thanks beforehand.
The text was updated successfully, but these errors were encountered: