[Haskell-beginners] type hierarchies / records

Răzvan Rotaru razvan.rotaru at gmail.com
Thu Mar 14 16:58:52 CET 2013


Dear Haskelleers,

I suspect my problem has been discussed many times and under many forms, so
please don't shoot me for asking. I could not find an acceptable solution
yet, and beeing as stubborn as i am, I still hope the solution is eluding
me because of my poor haskell knowlegde. So here I am posting my question
on this mailing list.

Basically I am trying to GUI Widgets using haskell types (Buttons,
Textfields, etc.).
1/ Using Records is not acceptable because of the name clashes between
attribute names. I could use prefixes and write functions in typeclasses
for accessor, but it's ugly and a lot of work.

2/ I decided to keep the attributes in Maps, so basically a textfield would
be

data Textfield = Textfield (Map.Map TextfieldProps String)

The problem is: how to define TextfieldProps? It should be something like:

data TextfieldProps = Id | Label | Value

But then, buttons also have Id's and labels. So following is not accepted
anymore:

data ButtonProps = Id | Label | OnClick

Ideas and suggestions are much appreciated. Thank You,
Răzvan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130314/e23ecbc0/attachment.htm>


More information about the Beginners mailing list