Tomas Petricek's Publications

Searching for new ways of thinking in programming & working with data

I'm a visiting researcher at the Alan Turing Institute working on tools for data-driven storytelling. I also work closely with the F# team in Microsoft Research and I recently submitted my PhD thesis at University of Cambridge. If you read 3 of my papers, consider the following ones!

Type Providers

F# Data infers types from sample XML and JSON documents and safely embed them into F#. Our PLDI 2016 paper is an ACM SIGPLAN Research Highligt.

Coeffects

Coeffects are theory of context-aware programming languages developed in my PhD thesis. Check out our ICFP 2014 paper or my interactive essay.

Philosophy

How different communities approach errors? My paper on history and philosophy of errors published in ‹Programming› 2017 was selected as reviewers choice.

Tomas Petricek
  • Tomas Petricek
  • Home
  • F# Trainings
  • Talks and books
  • The Gamma
  • Academic

Extending monads with pattern matching

Tomas Petricek, Alan Mycroft and Don Syme

In Proceedings of Haskell Symposium 2011

Sequencing of effectful computations can be neatly captured using monads and elegantly written using do notation. In practice such monads often allow additional ways of composing computations, which have to be written explicitly using combinators.

We identify joinads, an abstract notion of computation that is stronger than monads and captures many such ad-hoc extensions. In particular, joinads are monads with three additional operations: one of type m a -> m b -> m (a, b) captures various forms of parallel composition, one of type m a -> m a -> m a that is inspired by choice and one of type m a -> m (m a) that captures aliasing of computations. Algebraically, the first two operations form a near-semiring with commutative multiplication.

We introduce docase notation that can be viewed as a monadic version of case. Joinad laws make it possible to prove various syntactic equivalences of programs written using docase that are analogous to equivalences about case. Examples of joinads that benefit from the notation include speculative parallelism, waiting for a combination of user interface events, but also encoding of validation rules using the intersection of parsers.

Paper and more information

  • Download the paper (PDF)
  • Download COQ script with some proofs
  • See the original implementation (pre-processor and samples) at Github
  • See GHC fork and GHC base fork for a proper implementation
  • View talk slides from Haskell Symposium

Try Joinads

Try Joinads is a web site, using the open-source release of F#, that implements the joinads extension for F#. It comes with an browser-based F# console where you can experiment with joinads and numerous tutorials that demonstrate the usfulness of joinads. Tutorials include asynchronous, parallel and concurrent programming as well as parsing.

  • Visit the Try Joinads web site!

Bibtex

If you want to cite the paper, you can use the following BibTeX information, or get full details from the paper page on ACM.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
@inproceedings{joinads-haskell11,
  author    = {Petricek, Tomas and Mycroft, Alan and Syme, Don},
  title     = {Extending {M}onads with {P}attern {M}atching},
  booktitle = {Proceedings of Haskell Symposium},
  series    = {Haskell 2011},
  location  = {Tokyo, Japan},
} 

If you have any comments, suggestions or related ideas, I'll be happy to hear from you! Send me an email at tomas@tomasp.net or get in touch via Twitter at @tomaspetricek.

Published: Monday, 5 September 2011, 12:00 AM
Author: Tomas Petricek
Typos: Send me pull request!

Contact & about

This site is hosted on GitHub and is generated using F# Formatting and DotLiquid. For more info, see the website source on GitHub.

Please submit issues & corrections on GitHub. Use pull requests for minor corrections only.

  • Twitter: @tomaspetricek
  • GitHub: @tpetricek
  • Email me: tomas@tomasp.net

Blog archives

November 2018 (1),  October 2018 (1),  May 2018 (1),  September 2017 (1),  June 2017 (1),  April 2017 (1),  March 2017 (2),  January 2017 (1),  October 2016 (1),  September 2016 (2),  August 2016 (1),  July 2016 (1),  May 2016 (2),  April 2016 (1),  December 2015 (2),  November 2015 (1),  September 2015 (3),  July 2015 (1),  June 2015 (1),  May 2015 (2),  April 2015 (3),  March 2015 (2),  February 2015 (1),  January 2015 (2),  December 2014 (1),  May 2014 (3),  April 2014 (2),  March 2014 (1),  January 2014 (2),  December 2013 (1),  November 2013 (1),  October 2013 (1),  September 2013 (1),  August 2013 (2),  May 2013 (1),  April 2013 (1),  March 2013 (1),  February 2013 (1),  January 2013 (1),  December 2012 (2),  October 2012 (1),  August 2012 (3),  June 2012 (2),  April 2012 (1),  March 2012 (4),  February 2012 (5),  January 2012 (2),  November 2011 (5),  August 2011 (3),  July 2011 (2),  June 2011 (2),  May 2011 (2),  March 2011 (4),  December 2010 (1),  November 2010 (6),  October 2010 (6),  September 2010 (4),  July 2010 (3),  June 2010 (2),  May 2010 (1),  February 2010 (2),  January 2010 (3),  December 2009 (3),  July 2009 (1),  June 2009 (3),  May 2009 (2),  April 2009 (1),  March 2009 (2),  February 2009 (1),  December 2008 (1),  November 2008 (5),  October 2008 (1),  September 2008 (1),  June 2008 (1),  March 2008 (3),  February 2008 (1),  December 2007 (2),  November 2007 (6),  October 2007 (1),  September 2007 (1),  August 2007 (1),  July 2007 (2),  April 2007 (2),  March 2007 (2),  February 2007 (3),  January 2007 (2),  November 2006 (1),  October 2006 (3),  August 2006 (2),  July 2006 (1),  June 2006 (3),  May 2006 (2),  April 2006 (2),  December 2005 (1),  July 2005 (4),  June 2005 (5),  May 2005 (1),  April 2005 (3),  March 2005 (3),  January 2005 (1),  December 2004 (3),  November 2004 (2), 

License

Unless explicitly mentioned, all articles on this site are licensed under Creative Commons Attribution Share Alike. All source code samples are licensed under the MIT License.

CC License logo