Skip to content

API change for functions that take some "specification" as argument. #11

Description

@Noeda

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions