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 GeneralAttr datatype 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/get to handle GeneralAttrs
  • Introduction of set_ and get_ to work with global attributes (the trick is using () as object, similarly to what is done for {read,write}-only attributes)

Comments are closed.