Comments (3)
Do the sum types (which don't currently have a corresponding screenshot in the README :S) work for this?
let thing = sum "thing" {
a = int;
b = option string;
c = struct { name = string; };
};
in thing { a = 42; }
This requires explicit tagging of (named) variants, it sounds like you want anonymous variants?
from yants.
Sadly, I am typing values as they appear in nixpkgs, so I have no control over the values and must assign types a posteriori. So I don't get to tag them.
Equally sadly, fields as they appear in nix derivations have all sorts of quirks, with no guidance as to what they should be. This came up in particular as I was trying to assign a structured type to the urls
field of a derivation's source. It turns out that urls
, as they appear in the wild, can be, at least, any of:
- a string
- a list of strings
- a list of lists of strings
So far those are the only use cases I have encountered (and since this is dynamic typing, I only get to know about other cases when I end up evaluating them!).
So yeah, discriminated unions are great, and people should use them, but sometimes life sucks and you have untagged unions. :-(
from yants.
Okay, this makes sense - I might not get around to adding this in the next couple of days though, it's going to be a busy week over here. Feel free to send a pull request for it (should be straightforward to implement), otherwise I'll do it once I get the chance!
from yants.
Related Issues (3)
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 yants.