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"><<a href="mailto:alexanderforemny@gmail.com" target="_blank">alexanderforemny@gmail.com</a>></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'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'll try to investigate vault further.<br>
<br>
Regards,<br>
Alexander Foremny<br>
<br>
2012/7/31 Alexander Foremny <<a href="mailto:alexanderforemny@gmail.com">alexanderforemny@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Dear Michael,<br>
><br>
> thank you very much for your quick and interesting response. This<br>
> looks very much like what I want!<br>
><br>
> Regards,<br>
> Alexander Foremny<br>
><br>
> 2012/7/31 Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>>:<br>
>> On Tue, Jul 31, 2012 at 1:13 PM, Alexander Foremny<br>
>> <<a href="mailto:alexanderforemny@gmail.com">alexanderforemny@gmail.com</a>> wrote:<br>
>>> Hello list,<br>
>>><br>
>>> I am currently thinking that a problem of mine would best be solved if<br>
>>> there was a Map-like data structure in which the value returned is<br>
>>> parametrized over the lookup type.<br>
>>><br>
>>> I wonder is this makes sense and if such a data structure exists or if<br>
>>> it could be created while still being well typed. I essentially want<br>
>>> to statically define a scope of Key values and dynamically define a<br>
>>> list of keys.<br>
>>><br>
>>>> -- Scope of possible keys.<br>
>>>> type Label = String<br>
>>>> data Key a where<br>
>>>> KeyStr :: Label -> Key String<br>
>>>> KeyInt :: Label -> Key Int<br>
>>>> KeyChoice :: Label -> [a] -> Key a<br>
>>><br>
>>>> -- Some key values, to be extended at runtime.<br>
>>>> strKey "Some String"<br>
>>>> strKey' "Another String"<br>
>>>> intKey "Some integer"<br>
>>>> choiceKey "Chose one" [ "a", "b", "c" ] :: KeyChoice String<br>
>>><br>
>>> Now I need a data structure to possibly associate a value to the key.<br>
>>><br>
>>>> data MapG = ...<br>
>>>> type Value a = a<br>
>>>> insert :: Key a -> Value a -> MapG Key Value -> MapG Key Value<br>
>>>> lookup :: Key a -> MapG Key Value -> Maybe (Value a)<br>
>>><br>
>>> I tried implementing this with multiple Map k a's. I tried adding a<br>
>>> phantom type on some storage type of to implement KeyChoice as of type<br>
>>> Key Int, but I ran into troubles with this approach. I wonder if<br>
>>> Dynamic or Type Families could achieve this, but I am quite at a loss<br>
>>> and would like to hear your opinion.<br>
>>><br>
>>> I did try to search for this a bit, but I don't quite know how to<br>
>>> phrase my problem. I'd like to apologize in advance if this question<br>
>>> has been asked already.<br>
>>><br>
>>> Regards,<br>
>>> Alexander Foremny<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>
>><br>
>> I think you might be looking for something like vault[1].<br>
>><br>
>> HTH,<br>
>> Michael<br>
>><br>
>> [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>