28.07.2013 Views

Making OpenCL? Simple with Haskell - AMD Developer Central

Making OpenCL? Simple with Haskell - AMD Developer Central

Making OpenCL? Simple with Haskell - AMD Developer Central

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

EMBEDDING MONADS<br />

In fact, the only way we expect to use a context/command queue/etc. is to<br />

populate a contextual/queued computation, so we provide a function that<br />

combines construction in the outer monad <strong>with</strong> computation in the inner<br />

monad:<br />

<strong>with</strong>New :: MonadIO m => m Context -> ContextM t -> m t<br />

This mechanism is extensible: the quasiquotation support uses a single<br />

data structure to contain context, queue, and device information; however,<br />

by adding it to the 'Contextual„, 'Queued', and 'Wraps' classes we can use<br />

the same code we would have <strong>with</strong> the more conventional initialization.<br />

39 | <strong>Making</strong> <strong>OpenCL</strong> <strong>Simple</strong> | January, 2011 | Public

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!