Markus Läll
2018-10-29 18:56:02 UTC
Dear list,
Is it possible te get the number of fields for data constructors for a
plain ADT, i.e something with no record fields? E.g for
data T = A Int Double | B String (Maybe String)
it would give 2 for both `A` and `B`.
For a record it's possible using the `constrFields` function from Data.Data.
I was trying to follow this tutorial by Christopher Done
https://chrisdone.com/posts/data-typeable, and I feel that it must be
possible somehow to get these numbers with the gmap*/gfold* functions, but
the use of them is over my head at the moment.
Best,
Is it possible te get the number of fields for data constructors for a
plain ADT, i.e something with no record fields? E.g for
data T = A Int Double | B String (Maybe String)
it would give 2 for both `A` and `B`.
For a record it's possible using the `constrFields` function from Data.Data.
I was trying to follow this tutorial by Christopher Done
https://chrisdone.com/posts/data-typeable, and I feel that it must be
possible somehow to get these numbers with the gmap*/gfold* functions, but
the use of them is over my head at the moment.
Best,
--
Markus LÀll
Markus LÀll