diff options
author | Nadrieril Feneanar | 2019-04-04 23:51:46 +0200 |
---|---|---|
committer | GitHub | 2019-04-04 23:51:46 +0200 |
commit | a9f4e9b10196d75e674d95160955360d388a772b (patch) | |
tree | 20d869202eadc1193e449d3b3320f9b1d89ae578 /dhall_core/src/core.rs | |
parent | 7336787af41adc4dfe650f7c7f10f9c7c3c011db (diff) | |
parent | 74eb88c42d938672137771fab33ef0118903b5e1 (diff) |
Merge pull request #42 from Nadrieril/move-to-upstream-grammar
Move to upstream grammar
Diffstat (limited to 'dhall_core/src/core.rs')
-rw-r--r-- | dhall_core/src/core.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 0ea8c83..afa3d3f 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -324,6 +324,25 @@ pub fn rc<T>(x: T) -> Rc<T> { Rc::new(x) } +pub fn app<N, E>(f: Expr<N, E>, args: Vec<SubExpr<N, E>>) -> Expr<N, E> { + if args.is_empty() { + f + } else { + Expr::App(rc(f), args) + } +} + +pub fn app_rc<N, E>( + f: SubExpr<N, E>, + args: Vec<SubExpr<N, E>>, +) -> SubExpr<N, E> { + if args.is_empty() { + f + } else { + rc(Expr::App(f, args)) + } +} + fn add_ui(u: usize, i: isize) -> usize { if i < 0 { u.checked_sub(i.checked_neg().unwrap() as usize).unwrap() |