[Haskell-cafe] Re: classes with types which are wrapped in

Andrew U. Frank frank at geoinfo.tuwien.ac.at
Wed Jan 27 03:23:45 EST 2010


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)?


More information about the Haskell-Cafe mailing list