Would ixset or HiggsSet be suitable?<div><br></div><div><a href="http://hackage.haskell.org/package/ixset-1.0.5">http://hackage.haskell.org/package/ixset</a></div><div><a href="http://hackage.haskell.org/package/HiggsSet">http://hackage.haskell.org/package/HiggsSet</a>
</div><div><br><div class="gmail_quote">On Tue, Jul 31, 2012 at 12:56 PM, Alexander Foremny <span dir="ltr">&lt;<a href="mailto:alexanderforemny@gmail.com" target="_blank">alexanderforemny@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">At first glance I noticed some problems with the vault library for my<br>
particular approach.<br>
<br>
Despite from being unique, Key values don&#39;t appear to carry any<br>
information like the Label I need. However, it might be possible to<br>
work around that.<br>
<br>
The more grave problem seems to be that a Key cannot be<br>
(de-)serialized. This might be impossible due to the type parameter a<br>
in Key a.<br>
However, it is no problem to fix the types of values to some finite collection.<br>
<br>
Because of this some solution built around Dynamic seems to be more<br>
and more appropriate. But I&#39;ll try to investigate vault further.<br>
<br>
Regards,<br>
Alexander Foremny<br>
<br>
2012/7/31 Alexander Foremny &lt;<a href="mailto:alexanderforemny@gmail.com">alexanderforemny@gmail.com</a>&gt;:<br>
<div class="HOEnZb"><div class="h5">&gt; Dear Michael,<br>
&gt;<br>
&gt; thank you very much for your quick and interesting response. This<br>
&gt; looks very much like what I want!<br>
&gt;<br>
&gt; Regards,<br>
&gt; Alexander Foremny<br>
&gt;<br>
&gt; 2012/7/31 Michael Snoyman &lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;:<br>
&gt;&gt; On Tue, Jul 31, 2012 at 1:13 PM, Alexander Foremny<br>
&gt;&gt; &lt;<a href="mailto:alexanderforemny@gmail.com">alexanderforemny@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt; Hello list,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am currently thinking that a problem of mine would best be solved if<br>
&gt;&gt;&gt; there was a Map-like data structure in which the value returned is<br>
&gt;&gt;&gt; parametrized over the lookup type.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I wonder is this makes sense and if such a data structure exists or if<br>
&gt;&gt;&gt; it could be created while still being well typed. I essentially want<br>
&gt;&gt;&gt; to statically define a scope of Key values and dynamically define a<br>
&gt;&gt;&gt; list of keys.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; -- Scope of possible keys.<br>
&gt;&gt;&gt;&gt; type Label = String<br>
&gt;&gt;&gt;&gt; data Key a where<br>
&gt;&gt;&gt;&gt;     KeyStr :: Label -&gt; Key String<br>
&gt;&gt;&gt;&gt;     KeyInt :: Label -&gt; Key Int<br>
&gt;&gt;&gt;&gt;     KeyChoice :: Label -&gt; [a] -&gt; Key a<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; -- Some key values, to be extended at runtime.<br>
&gt;&gt;&gt;&gt; strKey &quot;Some String&quot;<br>
&gt;&gt;&gt;&gt; strKey&#39; &quot;Another String&quot;<br>
&gt;&gt;&gt;&gt; intKey &quot;Some integer&quot;<br>
&gt;&gt;&gt;&gt; choiceKey &quot;Chose one&quot; [ &quot;a&quot;, &quot;b&quot;, &quot;c&quot; ] :: KeyChoice String<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Now I need a data structure to possibly associate a value to the key.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; data MapG = ...<br>
&gt;&gt;&gt;&gt; type Value a = a<br>
&gt;&gt;&gt;&gt; insert :: Key a -&gt; Value a -&gt; MapG Key Value -&gt; MapG Key Value<br>
&gt;&gt;&gt;&gt; lookup :: Key a -&gt; MapG Key Value -&gt; Maybe (Value a)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I tried implementing this with multiple Map k a&#39;s. I tried adding a<br>
&gt;&gt;&gt; phantom type on some storage type of to implement KeyChoice as of type<br>
&gt;&gt;&gt; Key Int, but I ran into troubles with this approach. I wonder if<br>
&gt;&gt;&gt; Dynamic or Type Families could achieve this, but I am quite at a loss<br>
&gt;&gt;&gt; and would like to hear your opinion.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I did try to search for this a bit, but I don&#39;t quite know how to<br>
&gt;&gt;&gt; phrase my problem. I&#39;d like to apologize in advance if this question<br>
&gt;&gt;&gt; has been asked already.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt; Alexander Foremny<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt;<br>
&gt;&gt; I think you might be looking for something like vault[1].<br>
&gt;&gt;<br>
&gt;&gt; HTH,<br>
&gt;&gt; Michael<br>
&gt;&gt;<br>
&gt;&gt; [1] <a href="http://hackage.haskell.org/package/vault" target="_blank">http://hackage.haskell.org/package/vault</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Alp Mestanogullari<br>
</div>