
6 Sep
2011
6 Sep
'11
3:47 p.m.
Hi all, i have a record with a lot of items used in a state monad. data BigData = BigData { data1 :: X , data2 :: X -- and so on } type MonadicEnv a = State BigData a I updates the fields in the computation with such functions: updateData1 :: X -> MonadicEnv() updateData1 d = do; env <- get; put env {data1 = d} updateData2 :: X -> MonadicEnv() updateData2 d = do; env <- get; put env {data2 = d} But it's ugly. Always the same, only the record selector has another name. Is it possible to generalize it? Thanks, Árpád