A brief demonstration of the Select monad in Javascript

I’m interested in monads and came across the Select monad while browsing the Haskell transformers package. It was implemented as a monad transformer (as you might expect) and was therefore a bit difficult to grok… however, once I wrapped my head around the basic concept, I realized it was actually very simple, so I thought it would be fun to implement it in Javascript. I was also inspired by a StackOverflow question on using the Select monad to solve the n-queens problem, so I figured I would throw in a solution for that specific puzzle as well.

Not much else beyond that… just thought I would share in case anyone here has an interest in the use of monads for backtracking search. Cheers!

1 Like