
6 Apr
2014
6 Apr
'14
1:39 p.m.
On Sun, Apr 6, 2014, at 09:28 AM, martin wrote:
The problem with this approach is that I end up with two representations of GuitarString. One is the accessor functions above, but there is also a datatype GuitarString which I need to express things like "put your finger on the nth fret of the mth string".
You could try using an array: data StringIndex = S1 | S2 | S3 | S4 | S5 | S6 deriving (Eq, Ord, Enum, Bounded, Read, Show) type Guitar = Array StringIndex StringState http://hackage.haskell.org/package/array-0.5.0.0/docs/Data-Array.html The Enum and Bounded constraints on StringIndex let you do fun things like: allStrings = [minBound .. maxBound] -Karl