-
Notifications
You must be signed in to change notification settings - Fork 89
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
Special syntax for fully-applied primitive operations #243
Conversation
e1cb155
to
9fb8df7
Compare
self.load_stdlib( | ||
"<stdlib/records.ncl>", | ||
nickel_stdlib::RECORDS, | ||
&mut global_env, | ||
)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe stdlib.rs
should export a list of all its Nickel modules. I feel that it's rather impractical to have to add said modules in two different files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I'm currently reworking the program module to prepare for the REPL anyway, I will do that.
concat : List -> List -> List = fun l1 l2 => l1 @ l2; | ||
|
||
foldl : forall a. (a -> Dyn -> a) -> a -> List -> a = | ||
fun f fst l => | ||
if length l == 0 then | ||
if %length% l == 0 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR, but I hope that %length% l
is O(1). Otherwise foldl
(and fold
) as written here is quadratic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, list are currently implemented as vectors so length
is O(1). I suspect this was written because at that time equality was implemented only for numbers though, so l == []
is probably more future-proof.
Close #228. Use a specific syntax for fully applied built-in operators,
%operator%
, and wrap this primitive version in vanilla functions of the standard library.This has the unfortunate consequence described in #226, that is that wrapped operator does not behave as unwrapped operator with respect to typing, but this is a separate topic that needs to be addressed anyway.
This also led to #244. This PR currently assigns correct but less ergonomic types - the ones with
Dyn
- to primitive operators wrapped in the standard library, while the actual primitive ones stay polymorphic. We'll have to resolve this discrepancy together with #244.