Hello,
Sean Leather <leather@cs.uu.nl> writes:That seems to be GP problem, as your solution doesn't scale well when I
> I'm not sure the problem you're running into is strictly a generic
> programming (GP) one. Typically, GP takes code that is often written
> and generalizes it, so that it doesn't have to be written for multiple
> datatypes.
wan't to add/remove/change fields in the `Row` record. The perfect way
as I see it, would be just editing `Row` data declaration, nothing else.
Studying few papers about GP in Haskell, I reckon this could be
represented as generic traversal, using my `Row` declaration with
`Either`. I don't see really good way to write a generic producer from
`[String]` to version of `Row` without `Either`. But SYB doesn't
provide a way for passing type-class-parametric functions to gmapT, and
SYB-with-class has large overhead of its usage. I don't have enough
time to find out how this can be written in SYB-with-class, if it really can be
written. The restriction of EMGM was described in my initial message.
readRow l = gmapT (mkT (\(Left (Just ri) :: E Name) -> Right $ l `atMay` ri >>= readMay))