Thanks for sharing!
Nice, thanks for sharing! However, I can’t help but notice that the solution is heavy on string usage. I really expected these to be ADTs
workout = ["Push day", "Pull day", "Leg day", "No workout"]
running = ["Long run", "Short run", "No run"]
weekdays = ["Seg.", "Ter.", "Qua.", "Qui.", "Sex.", "Sab.", "Dom."]
At least that’s what my Haskell instinct tells me when I look at these lists
That’s right, I would have done that for any proper program too. Given the more general audience and format I was targeting, and the scripty nature of it, this approach seemed fine enough though, and a runtime error here is costless .
The heavy lifting is done by the
logict
package.
I think that’s too much credit to logict
, my suspicion is that pretty much everything in the post can use the normal list monad without an issue. I cannot spot any calls to (>>-)
or interleave
.
so IIUC interleave should be used instead of (<|>) to search down both branches at equal rate?
Yes, interleave
instead of (<|>)
(but not in the definition of choose
) and some (but likely only some!) of implicit monadic (>>=)
should be replaced by (>>-)
.