[Haskell-cafe] Sparse records/ADTs

Daniel Trstenjak daniel.trstenjak at gmail.com
Wed Oct 24 13:02:15 CEST 2012


Hi Jon

On Wed, Oct 24, 2012 at 11:08:29AM +0100, Jon Fairbairn wrote:
> for each field, which is tedious (and O(n)). Obviously Templates
> would help, but is there an alternative I’ve missed?

perhaps something like:

data Type = Ta | Tb | Tc ...

data E    = Ea A | Eb B | Ec C | ...

type D    = HashMap Type E

get :: Type -> D -> Maybe E
get = lookup


Greetings,
Daniel



More information about the Haskell-Cafe mailing list