←back to thread

99 points agnishom | 10 comments | | HN request time: 0.931s | source | bottom
1. codethief ◴[] No.44363911[source]
Reminds me of this classic: https://aphyr.com/posts/342-typing-the-technical-interview
replies(3): >>44364822 #>>44365630 #>>44366038 #
2. the_other ◴[] No.44364822[source]
This gives me a message "Unavailable Due to the UK Online Safety Act" which sounds like nonsense for a blog post, but IANAL. Can anyone summarise the post, or suggest why there'd be a reason my online safety is compromised by it?
replies(2): >>44364937 #>>44365208 #
3. mdrzn ◴[] No.44364937[source]
It's pretty clear that the issue is not the post, but the fact that you are in UK, and the site author does not deem you important enough.

The site author himself has blocked users from the UK because of that stupid law that you cite in your comment: "The UK's Online Safety Act requires operators of 'user to user services' to read through hundreds (if not thousands) of pages of documentation to attempt to craft "meaningful" risk assessments and 'child access assessments' or face £18,000,000 fines, even imprisonment."

4. codethief ◴[] No.44365208[source]
Here you go: https://web.archive.org/web/20250213135223/https://aphyr.com...
5. MattPalmer1086 ◴[] No.44365630[source]
A thing of beauty! Was going to post the same.
6. mightybyte ◴[] No.44366038[source]
As a professional haskeller, I feel it necessary to point out for people in this thread who are less exposed to Haskell and who may be Haskell-curious...this is not what real-world commercial Haskell code looks like. To use a C analogy, I'd say it's closer to IOCCC entries than Linux kernel code.
replies(2): >>44366389 #>>44368718 #
7. ralferoo ◴[] No.44366389[source]
Thanks for that. Having read the article, I was left with the overwhelming impression that I'd have solved it in a totally different way if I was trying in OCaml.

Briefly, I'd have started with an array which for each colour had an array containing the coordinate pairs for that colour. I'd probably then have sorted by length of each array. The state also has an empty array for the coordinates of each placed queen.

To solve, I'd take the head array as my candidates, and the remaining array of arrays as the next search space. For each candidate, I'd remove that coordinate and anything that was a queen move from it from the remaining arrays, and recursively solve that. If filtering out a candidate coordinate results in an empty list for any of the remaining arrays, you know that you've generated an invalid solution and can backtrack.

At no point would I actually have a representation of the board. That feels very imperative rather than functional to me.

To me, this solution immediately jumps out from the example - one of the queens in on a colour with only 1 square, so it HAS to be there. Placing that there immediately rules out one of the choices in both colours with 2 squares, so their positions are known immediately. From that point, the other 2 large regions have also been reduced to a single candidate each.

replies(1): >>44367047 #
8. mightybyte ◴[] No.44367047{3}[source]
Yeah, comparing to how you'd solve this in any other mainstream language is really an apples-to-oranges comparison here because this is explicitly tackling the contrived problem of solving it at the type level rather than at the much more common value level. Very few languages in existence have the ability to do this kind of type-level computation. I'd say Haskell is really the only language that could conceivably be called "viable for mainstream use" that currently supports it, and even in Haskell's case the support is new, largely experimental, in a state of active research, and not well integrated with the ergonomics of the rest of the language.
9. tmtvl ◴[] No.44368718[source]
As someone who has never touched Haskell and who knows nearly nothing about it, Haskell is not, in fact, a "dynamically typed, interpreted language", which, "has no currying".
replies(1): >>44372710 #
10. agnishom ◴[] No.44372710{3}[source]
At the risk of explaining away a perfectly good joke, that person is writing programs at the type level. The joke is that the type system is turing complete if you enable the right extensions.