Hacker Newsnew | past | comments | ask | show | jobs | submit | ycitm's commentslogin

The next sentence in the quote hasn't aged so well - "What weather they shall have is not ours to rule."


Most importantly, this means my type system N-queens solution now works for an 8x8 chessboard (actually up to 10x10) instead of complaining about recursion depth:

https://www.richard-towers.com/2023/03/11/typescripting-the-...


Doesn't seem to be any discernable improvement on the Zoom Cat Lawyer.


I am not a cat


You can also play around with the code in the TypeScript playground:

https://www.typescriptlang.org/play?#code/PTAEEkDsAsEMBsCmAa...


Ah, thank you so much! Great spot.

I've corrected this, and credited you in the errata - https://www.richard-towers.com/2023/03/11/typescripting-the-...


I wondered if anyone would spot this :)

There's a recursion depth limit of 500 on the TypeScript compiler, which prevents this solution working for N > 7

Even Aphyr's original Haskell solution only demonstrates N = 6, so in some sense this is an improvement on the state of the art for type-level N Queens solutions /s


I don't really know what it means, but I've seen it used to work around depth issues in Typescript, but can this use a "trampoline"?


I don't think there's any way to do iteration in the type system (other than recursion), so there's no way around it.

I considered forking the compiler to set a deeper limit, but at some point Typescript itself is going to stack overflow. Also that probably goes a bit beyond what Criss is expecting in an interview...


I don't know about the typescript compiler, but the way around template recursion limits in "classic" C++ template metaprogramming is to figure out a way to make it O(log N) depth instead of O(N) (for some value of N). Like instead of linearly iterating through a range of types through recursion, you divide and conquer. Easier said than done, but possible in some cases.



Thanks! I was aware of the Aphyr series, but he said Richard also had a series.


The runes are mostly "just because", but there is a reason.

Ideally, I would have written:

  type Nil = unique symbol
Which would ensure the Nil type wouldn't match with anything but itself. Unfortunately, the compiler doesn't allow unique symbol other than on const variables initialised with Symbol(). So I needed some meaningless symbols.

I could also have done

  type Nil = "nil"
But then it would have looked like the string meant something.


If you've got any experience or interest in programming, I'd recommend having a stab at Google Summer of Code[0].

[0] - https://developers.google.com/open-source/gsoc/


One of my new years resolutions was to learn to type faster. To get some practice I started taking notes in all the meetings I attend. This wasn't common practice in my team before, but I've found it to be really useful. I've lost track of the number of times someone's said "didn't we talk about this in that meeting a couple of weeks back" and I've been able to point them at my notes.

I've found a really simple way of authoring and sharing notes is to write them in Org mode and then push them to a wiki on github. Github understands how to render Org markup nicely, so you get a nicely formatted wiki pretty much for free.

As an added benefit I can now touch type :)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: