Generalized attribute API
After a brief discussion on the gtk2hs-devel mailing list we’ve now a more general attribute API. Here’s a summary of the hackings:
- New
GeneralAttrdatatype introduced, it is parametrized over the monad to be used:data GeneralAttr m o a b = Attr !(o -> m a) !(o -> b -> m ()) - Generalization of data constructors: e.g.
newAttr :: Monad m => (o -> m a) -> (o -> b -> m ()) -> GeneralAttr m o a b - Generalization of
set/getto handleGeneralAttrs - Introduction of
set_andget_to work with global attributes (the trick is using()as object, similarly to what is done for {read,write}-only attributes)