[Haskell-cafe] Natural keys in Haskell data structures

Lian Hung Hon hon.lianhung at gmail.com
Fri Jul 8 13:35:53 UTC 2016

Dear cafe,

What is the idiomatic way to "split" records into their natural keys and
content in a data structure? For example, given a user:

data User = { username :: ByteString, hash :: ByteString, address :: Text,
... }

Using map, a first choice would be Map ByteString User, but this leads to
duplication of the username. And it is possible to make mistakes, such as

insert "John" (User "Jane" ...

What does cafe think? Is there any pattern for this? This is probably just
a small nit in the overall architecture, but I'm curious to know the clean
way to do it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160708/71d649b5/attachment.html>

More information about the Haskell-Cafe mailing list