PureConf

PureConf

On theory and practice of PureScript

Mike Solomon

@mikesol

The Hills Are Alive With the Sound of Comonads

Submitted Jan 23, 2022

Comonads famously project computations into future contexts. But what if the future is uncertain? What if, like in Demolition Man, the computation wakes up in a hostile, dystopian 2032? Instead, we’d like the computation to wake up in a place more like Encino Man, or at least An American Pickle.

This was the starting point for purescript-wags, a web audio engine that projects future audio states onto the mutable and referentially opaque Web Audio API. In this talk, I’ll show how existential types can be used inside of cofree comonads to add a modicum of type safety to a mutable-state model, and I’ll also show how linear types can be grafted onto comonads as a zero-cost abstraction to tame the volatile Web Audio API.

At the end, I’ll show how this facilitates the rendering of complex audio graphs in a sub-fifteen-millisecond deadline, allowing for low-latency MIDI and audio applications in the browser like https://wags.fm/, https://whatis.wags.fm/ and https://yap.wags.fm/.

Comments

{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

FP-Juspay is a forum to dive deep and contribute to the world of Functional Programming - Frameworks, Applications and People. more

Supported by

Community sponsor

Welcome to the MLabs page! We are a Haskell consultancy and a collection of real FP geeks. We are hiring Haskellers, Purescripters and other FP enthusiasts all year round. If you love Haskell and are looking for a job or internship, you apply here: https://apply.workable.com/mlabs/j/63DAAA4AEF/ more

Promoted

nilenso is a boutique technology consultancy based in Bangalore. Over the past 9 years, we have worked on projects in e-commerce, logistics, machine learning, data science, healthcare, payments and education. You can read about some our recent projects here: https://nilenso.com/recent-tech.html. Ou… more

Promoted