Cute :) Any sufficiently advanced type system is indistinguishable from an interpreter!
Show HN: Conway's Game of Life in TypeScript's type system
11–20 of 48 posts
Re: Show HN: Conway's Game of Life in TypeScript's type system
#12Uncomment one of the PGunXX types that you want to see, then below it type this:
const boardstr: PGun10 = ``;
Then put the cursor inside the two backticks and press Control+Space for intellisense autocomplete, and press enter on the first entry there. Then intellisense will put the computed board into a string literal, looking like: const boardstr: PGun10 = `............................................
........................xx..................
........................x..x................
..........x.x...............x......xx.......
........x...x..xxx..........x......xx.......
.xx.....x...................x...............
.xx....x....x.......xx..x..x................
........x.......x.x..x..xx..................
........x...x.....xxx.......................
..........x.x...............................
............................................`;Re: Show HN: Conway's Game of Life in TypeScript's type system
#13Re: Show HN: Conway's Game of Life in TypeScript's type system
#14In college I did it in assembler (a couple hundred bytes of code) on a PDP11/34 and displayed the results on an oscilloscope screen :)
Re: Show HN: Conway's Game of Life in TypeScript's type system
#15Re: Show HN: Conway's Game of Life in TypeScript's type system
#16type MyType = someFunc(T)
Of course these functions might be typed too…
Re: Show HN: Conway's Game of Life in TypeScript's type system
#17[0] https://aphyr.com/posts/342-typing-the-technical-interview
[1] https://www.richard-towers.com/2023/03/11/typescripting-the-...
Re: Show HN: Conway's Game of Life in TypeScript's type system
#18Sometimes I think I don't understand TypeScript's type system and then I see something like this and I realize I know even less than I thought
These advanced type systems are essentially a form of pre-compile time scripting to assert certain guarantees about user defined types. It's the same mechanism that makes C++ templates turing complete.
Re: Show HN: Conway's Game of Life in TypeScript's type system
#19At this point, TypeScript should just let us define types using plain imperative TS code that will execute during static analysis. Might as well. type MyType = someFunc(T) Of course these functions might be typed too…
Re: Show HN: Conway's Game of Life in TypeScript's type system
#20At this point, TypeScript should just let us define types using plain imperative TS code that will execute during static analysis. Might as well. type MyType = someFunc(T) Of course these functions might be typed too…