
27 Jan
2010
27 Jan
'10
8:23 a.m.
i thank for the two suggestions (newtype as a wrapper and type families) and i have explored them. haskell-cafe was very helpful! i use often a piece of code to update a part of a record with field names which codes as follows: data X a b c = X {afield :: a, bfield :: b, cfield :: c} dotoBfield :: (b -> b) -> X a b c -> X a b c dotoBfield op x = x { bfield = op (bfield x)} and similar for A and C. is there a better idiom to achieve the same effect? can this be automated (for example, using generics)?