Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Twisol
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
55 ms
·
571.
▲
by
Twisol
6y ago
Sure. Now can we do the same with the other fourteen types, or is the primary value here that there are two kinds of people: INTx and non-INTx? There's probably some bias here, but I've only ever heard INTx specifically singled ou
572.
▲
by
Twisol
6y ago
Not particularly having a horse in this race, if a theory can't reliably make useful predictions, it's not a very useful theory. There's certainly something to be said about identifying correlations, but it isn't yet cle
573.
▲
by
Twisol
6y ago
Without having a horse in a race, it's probably the idea that the results persist between multiple tests and vary by who's taking the test. Persistence seems like a decent lower standard to say that there's _something_ presen
574.
▲
by
Twisol
6y ago
> Do you know if there is a formal term for this kind of dependency chain and update order scheduling is called? ECS might make this an independent-enough concern that techniques from build systems would be applicable. See "Build sy
575.
▲
by
Twisol
6y ago
> Doesn't the fungus get its name from the oxidized metal though and not the other way around? Huh, apparently so! So Rust-the-language isn't necessarily named after oxidized metal, but it _is_ named after something that's
576.
▲
by
Twisol
6y ago
On the other hand, Rust was apparently named after the fungus, not iron oxide. There seems to be a new category of low-level tools named after life forms that grow in ecological niches :D
577.
▲
by
Twisol
6y ago
Hm. "Safely repeatable"? Idempotence is a pretty specific concept.
578.
▲
by
Twisol
6y ago
Most of the common examples are mathematical widgets. For example, for any two vector spaces V, W, there's a vector space of linear transformations from V to W. Given a vector in V and a transformation W^V, you can get a vector in W --
579.
▲
by
Twisol
6y ago
We may never know for sure, but I bet they avoided a whole bunch of problems by using Go instead of C. Probably wise to go lower only when needs must.
580.
▲
by
Twisol
6y ago
Exponents are probably the easier aspect to understand. For instance, what is the number of distinct functions between a set X and a set Y? Well, for every input value of X, we get to choose any single output value of Y. There are |Y| choic
581.
▲
by
Twisol
6y ago
(Thanks for continuing to engage on this. It's a fun conversation :) ) Yes, I suspect the blog post is more interesting if you already have a theoretical background, and are interested in the various ways that theory plays out in appli
582.
▲
by
Twisol
6y ago
> I guess maybe it’s that you could implement the visitor pattern in Haskell using a record that contains functions. But that’s a straightforward vtable implementation, and you wouldn’t really want to anyway. On the contrary: typeclasses
583.
▲
by
Twisol
6y ago
> Who wants to write a function that takes 50 functions as parameters? At least use a struct of functions. The struct serves as a vtable, so you might as well use an object-oriented language’s built-in vtables. Okay, I think I see where
584.
▲
by
Twisol
6y ago
The point of the original article is that the Visitor pattern is the Church encoding of sum types. It sounds like you see a stronger difference between what the article describes and what I understand the Visitor pattern to be. There migh
585.
▲
by
Twisol
6y ago
A and B are free to be chosen by a producer of the generic Sum type. However, T can be chosen "late", by a consumer of Sum; a value of type Sum A B must work for any T you decide to use down the line. If it helps, the equivalent
586.
▲
by
Twisol
6y ago
I'm not sure I follow your point, because the thing you don't need to do in Haskell is precisely the visitor pattern, and you don't need to do it in Haskell because you have sum types; but you don't have sum types in Jav
587.
▲
by
Twisol
6y ago
Shh, you've said the quiet part out loud ;)
588.
▲
by
Twisol
6y ago
That's why we usually group all of these handlers into a single Visitor interface. Then you only add one class and one extra method to the Visitor, and all the other variants stay the same. You're brushing up against the so-called
589.
▲
by
Twisol
6y ago
After many years of not having them ;) I'll be very glad to be able to retire this well-used gripe.
590.
▲
by
Twisol
6y ago
"Algebraic data types" refers to having both product and sum types, where products are the records/structs that just about every language has, and sums are indeed the "discriminated unions" under discussion. Most la
591.
▲
by
Twisol
6y ago
You're speaking at the level of the code, while I'm speaking at the level of the domain. Neither of us are wrong, but we're talking past each other. The Shape class itself is formally the sum of Circle and Rectangle -- you ca
592.
▲
by
Twisol
6y ago
My takeaway from the article is that you almost always want a proper sum (discriminated union) type, but if you find yourself in a world without (hello, Java), here's a way to encode them precisely. As the OP notes, though, this stil
593.
▲
by
Twisol
6y ago
> Obviously, not. Not even apples versus oranges. Formally, `A + B` is isomorphic to `forall T. (A -> T, B -> T) -> T`, where the inner `(A -> T, B -> T)` is the type of a visitor. a + b -- CPS transform = fo
594.
▲
by
Twisol
6y ago
> The things which are instances of Shape are functions that accept circles or rectangles, not actual circles or rectangles. The naming is confusing, but it's misled you in the opposite direction. Things that are instances of Shap
595.
▲
by
Twisol
6y ago
The code you've selected is not "for circles", per se. This is classic double-dispatch -- the function itself represents a circle (via the `x, y, r` values it closes over), and it chooses which receiver to invoke based on i
596.
▲
by
Twisol
6y ago
Sure. Then, if you're set on using lambdas, I'd recommend this, to at least take away the ability to choose <T> from the caller. static Shape<?> Circle(int x, int y, int r) { return (circle, rectangle) ->
597.
▲
by
Twisol
6y ago
As with the TypeScript examples, we can make the top-level apply method generic instead of the whole class to avoid some casts. In particular, notice that the <T> inferred from calling Circle() and Rectangle() is the unmeaningful <
598.
▲
by
Twisol
6y ago
> Now, in order for it to work, a language has to support closures, not just functions. Objects are a reasonable stand-in for closures. Pass in the first batch of arguments to the constructor, and store them as fields. Access them from t
599.
▲
by
Twisol
6y ago
Here's a slightly different Java example, for variety in the examples you're getting ;) I also recommend checking out the paper on object algebras [0], which takes this approach much further. Notice that in some sense, the structu
600.
▲
by
Twisol
6y ago
If GHC intrigues you, I recommend looking up the CC class of languages as well. [1] The change from get/set to ask/tell has a surprisingly significant impact on how one thinks about shared state and communication between concurren
More ›