Monadic constraint solver: almost got it right.