refactor: fully qualify Set module for clarity

This commit is contained in:
wi11-holdsworth 2025-10-07 19:33:28 +11:00
parent 136ba9d1d5
commit 0ce98af868

View file

@ -58,7 +58,7 @@ import Data.Function (on)
import Data.List
import Data.Map qualified as Map
import Data.Ord (comparing)
import Data.Set qualified as S
import Data.Set qualified as Set
-- ==== DATA STRUCTURES =======================================================
@ -142,17 +142,17 @@ feedback target guess = (pitches, notes, octaves)
where
-- since pitches are unique in a guess,
-- we can use set math to count how many are correct
targetSet = S.fromList target
guessSet = S.fromList guess
targetSet = Set.fromList target
guessSet = Set.fromList guess
pitchSet = S.intersection targetSet guessSet
pitchSet = Set.intersection targetSet guessSet
pitches = length pitchSet
-- since notes and octaves are not unique in a guess,
-- we can compare the guess to all possible permutations of the target
-- and count the pairwise note/octave matches
targetNoPitches = S.toList $ S.difference targetSet pitchSet
guessNoPitches = S.toList $ S.difference guessSet pitchSet
targetNoPitches = Set.toList $ Set.difference targetSet pitchSet
guessNoPitches = Set.toList $ Set.difference guessSet pitchSet
notes = matches (map note targetNoPitches) (map note guessNoPitches)
octaves = matches (map octave targetNoPitches) (map octave guessNoPitches)