HN user

sixbrx

1,118 karma
Posts1
Comments557
View on HN

Thats not particular to postgres, that's the same in Oracle (or any other db following ISO case handling I believe), just with true (quoted) table name being all uppercase instead for the latter but with same error.

You can quote the table name in the create statement to get the camelcase table name. Just remember to quote in both creation and usage or neither, is a good rule of thumb

Here's an example I constructed after reading the TS docs [1] about flow-based type inference and thinking "that can't be right...".

It yields no warnings or errors at compile stage but gives runtime error based on a wrong flow-based type inference. The crux of it is that something can be a Bird (with "fly" function) but can also have any other members, like "swim" because of structural typing (flying is the minimum expected of a Bird). The presence of a spurious "swim" member in the bird causes tsc to infer in a conditional that checks for a "swim" member that the animal must be a Fish or Human, when it is not (it's just a Bird with an unrelated, non-function "swim" member).

    type Fish = { swim: () => void };
    type Bird = { fly: () => void };
    type Human = { swim?: () => void; fly?: () => void };

    function move(animal: Fish | Bird | Human) {
      if ("swim" in animal) {
        // TSC infers wrongly here the presence of "swim" implies animal must be a Fish or Human
        onlyForFishAndHumans(animal); 
      } else {
        animal;
      }
    }

    function onlyForFishAndHumans(animal: Fish | Human) {
      if (animal.swim) {
        animal.swim(); // Error: attempt to call "not-callable".
      }
      // (receives bird which is not a Fish or Human)
    }

    const someObj = { fly: () => {}, swim: "not-callable" };
    const bird: Bird = someObj;

    move(bird);

    // runtime error: [ERR]: animal.swim is not a function
[1] https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...

I'm pretty sure the thunk would be tagged by the effects of the inner function, so couldn't be called from an external context not declaring those effects. That's what the effect tracking is for.

Unison Cloud 2 years ago

Unison looks like a neat functional language. Do abilities subsume the role of type classes also (without any "effects")? If so, would there be a loss of efficiency for using pure abilities in this way (since a "handler" needs to interpret the ops)? Sorry I've only had a brief look so I'm not sure this makes sense.

Edit: Shorter: do you have type classes

Global CO2 Levels 3 years ago

The vast majority of that time had neither modern humans nor anything like our civilization, so wouldn't really be relevant though. Hell at 600 million years ago there were just the first "complex" (not individually microscopic) life forms emerging.

Also the ups and downs in temperatures happened over a far longer period of time than what we're experiencing now, giving life more time to adapt.

Nushell 0.86 3 years ago

One advantage or Powershell though is that in it you can put something into the pipeline from anywhere in your code, even within imperative code like in the middle a loop, just by mentioning a bare value at nearly any spot. And traditional shells are the same way (though they only support byte streams output), where you can send stuff to stdout/err at any point.

But in nu, it's more like you're just dealing with collections as in most programming languages. If your collection isn't amenable to being generated by a simple expression like a map or fold, then you have to create a collection, prep the collection to be what you want it to be, then you return it.

In that sense it's really different from both Powershell and traditional shells, and more like just using a traditional programming language. So in Nu I miss being able to just "yield" a value from anywhere without staging into a temporary collection first.

Yes I believe this is often used as part of Oracle's APEX (Application Expresss) tool which has similar goals to Omnigres. It's used to put together internal business CRUD and reporting apps very quickly for some orgs I've worked for.

It's not the saturation at the peak absorbtion frequencies that is driving the warming, it's the widening of the curves which raises absorbtion levels in nearby frequencies. The "saturated" argument was one of the first objections when the science was poorly understood. Krauss's book Physics of Climate CHange has a good account of this history. Check IPCC summaries to see how many models from the literature predict flattening at 0.7C additional warming if we don't curb emissions (spoiler alert: slim to none with many positing 5C or more additional warming in the 2100's if emissions aren't curbed).

Upsert in SQL 3 years ago

Good article, but I wouldn't characterize MERGE as strictly better than the older "ON CONFLICT ..." for Postgres, because MERGE doesn't support any sort of RETURNING clause.

Lean 4.0 3 years ago

It seems general programming is more in focus now, but for context, the "Programming in Lean" book was only completed recently as compared to the multiple theorem proving documents which have been around for a while. The Christiansen book looks worth waiting for though and I really hope Lean can gain popularity as a general purpose language.

Powershell is good, but one downside is that you have to explicitly check the exit code of each external program called and stop the script yourself for non-zero exit codes if that's what you want to do. Ie. there's no "set -e".

You can make a helper function or commandlet of course, but it obfuscates the code and is a pain to distribute around always where needed. They argue that non-zero exit codes for errors in external programs is a convention that doesn't exist consistently where Powershell is used. OK, but all the programs I use do follow that convention and so I find that very painful.

Similar thing noticed when visiting Korea as US natives. My wife was in a group that all headed off to the restroom at a restaurant just after getting a table, with a couple of in-laws who live there leaving their purses on the table. My wife exclaimed that they were forgetting their purses, to which they replied that it was on purpose and how else would they make sure somebody doesn't get their table!?

My wife and I had a recent bad experience on SouthWest, where we boarded the plane at Love Field in Dallas and then were made to wait 2.5 hours on the tarmac, because their IT system had a different passenger count than what the crew counted. After several attempts at counting again, they ended up having to go to each passenger row by row with a manifest in hand, and verify the passenger boarding pass and driver's license. I think aside from their IT system problems, this situation was made worse because as a passenger you don't have an assigned seat, so it's not obvious when someone is missing or a seat has two or more contending passengers.

JSON vs. XML 3 years ago

Problems are that some tools will rewrite the file and reorder the "comment" away from what it's meant to comment on. Also might complain the "comment" item isn't expected there. I seem to remember package.json suffering from both of these under the control of npm.

What's the role of the "Kind" language in all of this? I see only lisp-like expressions when showing the capabilities of the new VM. IIRC Kind language was done by the same organization and I really liked Kind as a fresh take on pure functional programming with dependent types. I can't find it now, but it had a different notion of dependency where a dependent function type could depend on an argument (as usual) and (IIRC) the function value itself as well (not usual).

I find Java pretty nice for handling JSON serialization/deserialization these days. Just define some records for the expected structure, and Jackson's object mapper handles the rest.

Link in first sentence is 404.

Looks interesting. The biggest problem I have with Docker Desktop on MacOS though is the constant cpu draw of 3-5% (or more, I can't tell if "kernel_task" seeming more busy when Docker is running is real). Wondering if we get any improvement there?