Sorry that I couldn't respond to the previous thread.. I'm using Gmail and not an email client so I couldn't use the reply button. I'll try to resolve this issue soon !<div><br><div>Thanks Phillip for responding so quickly,</div>
<div><br></div><div>I tried Data.Map first and ran into the issue you mentioned..</div><div><br></div><div>I've found a way to get around it, but it's ugly and verbose..</div><div><br></div><div>Instead, I'm wondering if there is a way to use the constructors for the "Val" types below, in place of the keys such as:</div>
<div><br></div><div>data Val = Root Root | Oct Oct | Mode Mode deriving (Show, Eq, Ord)</div><div><br></div><div>And matching against the constructors, instead of resorting to this:</div><div><br></div><div><br></div><div>
<div>import IO</div><div>import qualified Data.Map as Map</div><div><br></div><div>type Root = String</div><div>type Oct = Integer</div><div>type Mode = Integer</div><div><br></div><div>data Key = Root | Oct | Mode deriving (Show, Eq, Ord)</div>
<div>data Val = Root_v Root | Oct_v Oct | Mode_v Mode deriving (Show, Eq, Ord)</div><div><br></div><div>test = Map.insert Oct (Oct_v 3) . Map.insert Mode (Mode_v 0) . Map.insert Root (Root_v "2") $ Map.empty</div>
<div><br></div><div>main = print test</div><div><br></div><div>-- ----> fromList [(Root,Root_v "2"),(Oct,Oct_v 3),(Mode,Mode_v 0)]</div><div><br></div><div><br></div><div>Many Thanks,</div><div><br></div><div>
Tom</div></div></div>