
Hi Martin, On Sun, Apr 06, 2014 at 03:20:14PM +0200, martin wrote:
I started out with assoc lists and hashmaps. However, I found it diffiult to ensure that all 6 GuitarString have a something attached and found myself messing with Maybes. In the real world, there is no way a GuitarString can have "no state at all", while the HashMap approach would provide this option.
I would start by designing the data structures that represent your possible states. That way you can also ensure that there can't be any non representable states. I really don't now what makes sense in your case, but something like: data StringState = Resting | Oscillating ... data Guitar = Guitar { string1 :: StringState , string2 :: StringState ... } If you have worked out the right data structures, then writing the surrounding code can become quite naturally. Greetings, Daniel