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)
- Wrong version is reported by `nickel --version` for release artifacts HOT 7
- Variant of `std.contract.from_predicate` to specify an error message
- Some utilities in `std.array`: `remove_duplicates` and `filter_map` HOT 5
- Allow my users to use contracts shared on GitHub HOT 2
- `nickel doc` overflows the stack with recursive schemas HOT 2
- Forward the metadata when re-exporting a field HOT 1
- Hovering on a record field defined several times will only show the information for the first definition HOT 1
- Filter out the contract annotations on hover/completion when they don't add anything
- Output query results as JSON HOT 4
- Add empty YAML header when exporting
- Encode/decode JSON string HOT 2
- Make record pattern matching recursive HOT 6
- [Question] How to serialize sum type to json? HOT 3
- Bikeshed a name for `apply_as_custom`
- Short-circuiting version of `fold_left`
- Bikesheding: formatting of multi-line expressions enclosed in parentheses HOT 1
- Expose more math functions HOT 2
- Record row polymorphism can be destructive HOT 2
- 1.7.0 retag issue HOT 3
- Typechecking in recursive records shouldn't be confused by variables in an outer scope.
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.