For example, newBuffer, newTexture, runDraws and draw all take a record value that have many fields, some are set, some or not. Now that we depend on lens, we could do something like this:
-- Old API:
-- newBuffer :: MonadIO m => BufferCreation -> m Buffer
newBuffer defaultBufferCreation { bufferSize = 123, initialData = Just some_ptr }
-- New API:
-- newBuffer2 :: MonadIO m => (BufferCreation -> BufferCreation) -> m Buffer
newBuffer2 $ (bufferSizeL .~ 123) . (initialDataL .~ Just some_ptr)
Some of the new convenience functions I wrote for Graphics.Caramia.Buffer already use this. The default value is supplied by the function itself; user changes fields they want. And lens is excellent at this kind of use.
TODO: Add lenses for all the specification records and export them. Add new API functions.
For example,
newBuffer,newTexture,runDrawsanddrawall take a record value that have many fields, some are set, some or not. Now that we depend onlens, we could do something like this:Some of the new convenience functions I wrote for
Graphics.Caramia.Bufferalready use this. The default value is supplied by the function itself; user changes fields they want. Andlensis excellent at this kind of use.TODO: Add lenses for all the specification records and export them. Add new API functions.