[Haskell-beginners] Struct-like syntax issues

Brent Yorgey byorgey at seas.upenn.edu
Sun Mar 14 10:22:13 EDT 2010


On Sun, Mar 14, 2010 at 04:54:05PM +0300, Sergey Mironov wrote:
> Hi. I have definitions like
> 
> data MyData = MyData {
>   a :: A,
>   b :: B,
>   c :: C,
>   d :: D,
>   ...
>   z :: Z
>   }
> 
> ...
>
> will form that boilerplate.  Is there any _right_ way of doing it?

Unfortunately there is no better way of doing it.  _However_, there
are several packages which can generate all this boilerplate code for
you!  Check out fclabels [1] or data-accessor [2].

-Brent

[1] http://hackage.haskell.org/package/fclabels
[2] http://hackage.haskell.org/package/data%2Daccessor


More information about the Beginners mailing list