r/purescript • u/moondaddi80 • Aug 13 '21
Can I ask for the code review?
I'm actually learning this language for a couple of months now. I don't have any experience with Haskell. And I don't have any colleagues or developers around to discuss the idioms or Haskell/PureScript way to code. I'm solving the AoC puzzles to learn and try to get used to it. I think the AoC 2020 d4 puzzle is the one of the best puzzles to practice how to parse and process the data after parsing. Here is my code. Can I have a code review for the idioms or a better way to use this language?
https://github.com/mattdamon108/aoc-purescript/blob/main/src/aoc2020/D4.purs
4
u/kindaro Aug 13 '21
Looks beautiful!
I would split the definition of
part2in two, maybe with awhereclause.part1andpart2and thus avoid repetition.Naming is nice overall. You can improve further if you reduce the amount of meaningless names. Naming is documentation.
If your function's parameters' names contribute nothing to the understanding of what it does, try to rewrite the function in point-free style.
extractValueAtis a good candidate for being made point-free.If the function is hard to write and understand in point-free style, then keep it pointy but name variables exactly as their types. For example,
stringif it is a string,arrayOfStringsif it is an array of strings.anyFieldis a good candidate here.The same goes for names bound in do blocks and other local names.
anyFieldis a good candidate here, again. What the hell iskv?