[Haskell-cafe] Key-Parametrized Lookup Table

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Aug 1 14:43:38 CEST 2012


Alexander Foremny wrote:
> At first glance I noticed some problems with the vault library for my
> particular approach.
> 
> Despite from being unique, Key values don't appear to carry any
> information like the Label I need. However, it might be possible to
> work around that.
> 
> The more grave problem seems to be that a Key cannot be
> (de-)serialized. This might be impossible due to the type parameter a
> in Key a.

Vault is intended to be a store for values of any type, so it doesn't 
include any restriction on the type  a  in  Key a . For reasons of type 
safety, this means that keys have to be abstract. You can't create a 
typed key from an untyped label alone, because this would allow you to 
coerce a value to a different type (just create two keys of different 
types from the same label).

> However, it is no problem to fix the types of values to some finite collection.

That should work. You have to reify the type  a  in  Key a  in the value 
of the key. I think it's possible to use a data type family for the map 
type.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




More information about the Haskell-Cafe mailing list