JetBrains Research unites scientists working in challenging new disciplines

Seminar on code generation from data types using the "visitors" library

In practical programming it's usually helpful to have for user-defined data types some convenience functions like: conversion to string, `fmap` implementation for functor-like data types, etc. Writing this code manually is not a hard task but sometimes is boring and error-prone. In practice, we use tools that are designed to generate these functions from data type definition. They do very well the tasks that they are designed for. But in cases when we need to change the generated code a little bit they can't help us too much and we write required code manually. At them same time there are libraries that allow to change some parts of generated code _after_ actual generation. One of them is a library called `visitors` by Francois Pottier. One of the reasons why this library looks quite interesting is that we have a project called GT developed in out Lab which was created independently and aimed to solve similar issues with similar methods.

In the talk we will discuss

- the features, which a well-designed code generator should have;

- an intermediate approach for code generation, used in OCaml compiler, which lies in between the naive one and that used in the "visitors" library;

- implementation details of the "visitors" library.

Supplementary materials:

1. Manual

2. ICFP-2017 talk (from 22-th minute)

3. Francois Pottier. Visitors Unchained. ICFP 2017

4. The repository

Presenter --- Dmitry Kosarev.

Date: November 13, 2017

Time: 17:15

Venue: room 3248, Faculty of Mathematics and Mechanics, Saint Petersburg State University, Stary Peterhof, Universitetski pr., 28