2,427 karma · joined June 15, 2023
I would get in trouble for "talking back" when I pointed out that anyone can make a website or write a book, too.
Result<Users> userRes = getExpiredUsers(db);
if(isError(userRes)) {
return userRes.error;
}
/* This probably wouldn't actually need to return a Result IRL */
Result<Email> emailRes = generateExpireyEmails(userRes.value);
if(isError(emailRes)) {
return emailRes.error;
}
Result<SendResult> sendRes = sendEmails(emailRes.value);
if(isError(sendRes)) {
return sendRes.error;
}
return sendRes; // successful value, or just return a Unit type.
This is in my "functional C++" style, but you can write pipe helpers which sort of do the same thing: Result<SendResult> result = pipe(getExpiredUsers(db))
.then(generateExpireyEmails)
.then(sendEmails)
.result();
if(isError(result)) {
return result.error;
}
If an error result is returned by any of the functions, it terminates immediately and returns the error there. You can write this in most languages, even imperative/oop languages. In java, they have a built in class called Optional with options to treat null returns as empty: Optional.ofNullable(getExpiredUsers(db))
.map(EmailService::generateExpireyEmails)
.map(EmailService::sendEmails)
.orElse(null);
or something close to that, I haven't used java in a couple years.C++ also added a std::expected type in C++23:
auto result = some_expected()
.and_then(another_expected)
.and_then(third_expected)
.transform(/* ... some function here, I'm not familiar with the syntax*/); IEnumerable<User> getExpiredUsers(DbSet<User> users)
=> users.Where(u => u.ExpiresAt < DateTime.UtcNow);
Such simple logical expressions (called expression trees) get converted to SQL queriesWith too little process, people release bugs that I then have to scramble to fix. The CEO who pushed to skip QA and unit testing and everything in the name of release never has to deal with the consequences of their impatience
So yeah, where is the money going? When you combine state, local, and federal, the US spend nearly a trillion dollars a year on education (more than our military!) but where does it go? We regularly churn out illiterate graduates and teachers have to commute from another state away in order to find somewhere affordable to live. We spend more money per capita on healthcare than anyone else in the world for worse coverage and worse outcomes.
I hypothesize that the dollar's status as the world reserve currency is actually a bad thing. It makes it cheap for us to borrow money and as a result encourages all kinds of social pathologies associated with ZIRP
In powershell I just do
> echo '{"foo": "bar"} | ConvertFrom-Json | ConvertTo-Json
{
"foo": "bar"
}
But as a functionIn your post, you say:
>Compile to standard Java bytecode and run anywhere the JVM runs
But in github, the readme says that it transpiles to Java. Does this compile to bytecode, or transpile to java?
But I use the phrase "thought to" intentionally: I don't know what the science says now, but at the time there were reported cases of myocarditis in people who took the JnJ vaccine. This was like May of 2021, so I don't know if the science ever panned out on that, but it definitely drove discussions around health equity with the vaccine
IEnumerable<Product> GetExclusiveProducts(List<Product> source) =>
source
.Where(p => p.ProductTitle == "iPhone")
.OrderBy(p => p.TypeOfPhone);
That way the user can decide if they want a List or Array or Set or whatever, and you can also add additional queries to thisAlso better to pass IEnumerable to the function instead of List, for the same reasons
Also I forget the syntax but you can use an extension method to add it to linq I think