Comments (5)
Just a couple of side remarks:
-
{a: Num, b: String, _ : Bool}
isn't valid in Nix since records are always finite (unless_: Bool
also allows the fields to be missing) -
You can also pattern match on optional fields like
let f = { x ? 4 }: x+1; in f { x=5; } + f {}
I guess the framework should handle these (which can be done fairly easily if you have the Δ contract, not sure otherwise)
from nickel.
since records are always finite (unless _: Bool also allows the fields to be missing)
Yeah, I'd say that _ : Bool
allows the field to be missing. I guess the reason of saying _ : Bool U Δ
is that the type information is forwarded, and you can force to use an or
at the type level, right?
which can be done fairly easily if you have the Δ contract
That's true if you also have union types, we're putting that on standby for the moment being. So maybe having ?
as a primitive
from nickel.
I guess the reason of saying
_ : Bool U Δ
is that the type information is forwarded, and you can force to use anor
at the type level, right?
Not sure I understand what you mean. The reason we had that is just that it made everything more consistent (because that way _ : A
is just an shortcut for forall x. x: A
), but since it can always be used when the type contains Δ
it's also sensible to imply it.
That's true if you also have union types, we're putting that on standby for the moment being. So maybe having
?
as a primitive
Oh yes, I didn't follow that part. Then yes, you probably need something like a x :? Bool
construct to replace x : Bool \/ Δ
from nickel.
Regarding Flow
Flow is Facebook's answer to typing JS (the main difference with TypeScript is that is not a different language, and is designed to be used with JavaScript's code "out of the box", but I'm not an expert on either). They have Object type, which are more or less what we want.
They have a bunch of stuff that is of interest to us:
- Optional fields
- They have open and close records (unsealed and sealed) with regards to usability:
- sealed know all of its fields, and every access is checked,
- unsealed objects sometimes can check if an access is safe, but it's usually considered unsafe
- They also have a notion of exact objects, where only an object with exactly those fields matches. This is what we consider a close record.
- Lastly, there is an "indexer property", that is similar to the catch all idea presented above, it let's you use an object as a map/dictionary.
Main differences (or stuff we don't really care):
- Objects are modifiable
I think their development is quite similar to the idea of having a catch all case, and a special type stating that field doesn't exist. Their difference with unsealed and indexed objects is because Objects may grow and shrink during execution, I don't think we need to make this difference. I'll keep looking into their stuff, but this is just to have an idea of what a good set of capabilities might be, and there doesn't seem to be anything too different from the previous set of thoughts.
from nickel.
Closing old stale issue. Ideas mostly implemented (see #158).
from nickel.
Related Issues (20)
- Unicode operators HOT 1
- Website: docs out of date HOT 2
- Issues installing Nickel in a Nix flake devshell HOT 3
- Deal with potential infinite recursion `stdlib` <-> `internals.ncl` HOT 1
- Default values in dictionary contracts HOT 5
- Suprising semantics of capture inside a destructuring pattern HOT 1
- Array and Record comprehension HOT 2
- Make the pretty printer configurable
- Embed topiary as "nickel format" HOT 4
- composing nodes with input/output ports in Nickel HOT 2
- Function error messages are unhelpful HOT 11
- Imports in nls get read from disk, not the in-memory version
- support scientific notation for numbers HOT 4
- Extended error backtrace
- Include syntax highlighting in vscode extension HOT 5
- Publish vscode extension to the extension marketplace HOT 6
- Better document the behavior of nested function contracts
- Exporting as yaml produces ambiguous yaml (base 60 numbers) HOT 1
- Unsound generalization
- Some type annotations don't fire a contract check at runtime
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nickel.