Anmol will be presenting the following session
filter_list help_outline
  • Anmol Sahoo
    keyboard_arrow_down

    Anmol Sahoo - GADTs in OCaml

    Anmol Sahoo
    Anmol Sahoo
    Research Associate
    IIT Madras
    schedule 1 year ago
    Sold Out!
    90 Mins
    Tutorial
    Intermediate

    OCaml is a multi-paradigm programming language with a pragmatic mix of functional and imperative programming features. OCaml, which has been around since 1996, has grown to be a battle tested language, widely deployed and used in production systems. In this talk, we will look at the support for Generalized Algebraic Data Types (GADTs), a powerful generalization of the more mundane Algebraic Data Types (ADTs). We will start with an example of building an interpreter for a small language and add type safety through GADTs. We will then look at a few powerful type-safe design patterns that GADTs enable.

1. What got you into Functional Programming (FP)?

I got into functional programming merely out of curiosity. Around 2012, I learnt about the programming language called Haskell on online forums. People were talking really highly of the language and its focus on purity and referential transparency. Thus I decided I had to see for myself what made functional programming so great.

Thus I picked up a copy of Programming in Haskell by Graham Hutton and there was no looking back.

2. What has been your best moment or highlight working with FP?

I think working on the OCaml compiler has been my highlight with FP. Given how stable and mature a compiler OCaml is, the fact that I was able to start hacking into it without a degree in Compilers, was frankly quite surprising. Being able to make modular changes to the compiler, testing the compiler and then iterating was a joy, because so much of the code was written in a functional style.

3. What are some of the greatest challenges of working with FP?

Of course, the main challenge I personally find with FP, is the lack of an understanding of functional algorithms and their space and time complexity bounds. It is natural, since computers have been optimized for a side-effect style of programming, we have developed quite an extensive theory of algorithms and have a great understanding of their algorithmic bounds.

Though there is work by Chris Okasaki on functional algorithms, there is still a long way to go before these ideas become mainstream and people can reason about it as effectively as they reason about performance of mergesort or shellsort.

4. All the mainstream programming languages are adding functional programming features. Most new languages and frameworks are strongly influenced by FP. What is your advice to object-oriented programmers?

While advising people to migrate to a pure function style of programming, it should be important to keep in mind that for certain applications this might not be possible. But we have seen that enterprise application development can greatly benefit from a functional style of programming and eliminating as much code that relies on side-effects can be very useful.

When it comes to abstraction and inheritance, which is what enables a lot of the current practices in the industry, I think a thorough evaluation is needed if systems like Haskell typeclasses and OCaml modules can provide the same flexibility and power as OOP enjoys. If so, then OOP users can start to migrating to these, as they have much more solid fundamentals in place and can enable some clean design patterns. 

5. What will be some of the key takeaways from your sessions at the conference?

I will mainly be interested in networking with the people using functional programming languages and figuring out the pain points that they face and how we as a community can move to address them.

6. The conference has more than 50 sessions. Which ones are you most looking forward to attending and why?

I am mainly looking forward to the Prolog and APL sessions!

help