Manuel Chakravarty

Share

Lambda Scientist
haskellformac.com
@TacticalGrace

Manuel M T Chakravarty is an Associate Professor at UNSW Australia and the indie developer behind the interactive development environment Haskell for Mac. His core research interests are functional programming, novel compiler technology, and high-performance computing. He contributed to both the design and implementation of the Haskell programming language as well as several Haskell tools and open source libraries, including multiple systems for data parallel programming of multicore CPUs and GPUs. Over the last two years, he has focused on making functional programming more broadly accessible and on exploring its role in app development in Swift. Most importantly, he believes in the fruitful combination of theory and practice.

YOW! Lambda Jam 2014 Brisbane

Foreign Inline Code in Haskell

TALK –  VIEW SLIDES WATCH VIDEO

Template Haskell is a meta programming framework for Haskell implemented by the Glasgow Haskell Compiler (GHC), which is widely used as a template meta-programming system for Haskell, to define macros, code generators, or even code transformation engines. Subsequent support for the quasiquoting of arbitrary programming languages greatly simplified writing code generators in Haskell that produce complex C, CUDA, OpenCL, or Objective-C code by writing code templates in the syntax of the generated language.

Additionally, quasiquoting of C-like languages enables a purely library-based system for inline C code in Haskell. This dramatically simplifies language interoperability, and especially, the use of frameworks and libraries written in C-like languages from Haskell. It is, for example, helpful in applications based on native GUI libraries and projects integrating code written in multiple languages.

In this talk, I will explain the concepts of template meta-programming and quasiquoting and how they are used in Template Haskell. I will demonstrate quasiquoting by way of a few simple and intuitive examples. Finally, I will demonstrate the use of inline C code in Haskell and compare it to other forms of language interoperability as provided by Haskell and other functional languages.

This talk will explore the use, but not the implementation of quasiquoting and inline C & Objective-C code. Hence, the material should be accessible to anybody with an intermediate-level working knowledge of Haskell and C.


Foreign Inline Code in Haskell

WORKSHOP/JAM

Template Haskell is a meta programming framework for Haskell implemented by the Glasgow Haskell Compiler (GHC), which is widely used as a template meta-programming system for Haskell, to define macros, code generators, or even code transformation engines. Subsequent support for the quasiquoting of arbitrary programming languages greatly simplified writing code generators in Haskell that produce complex C, CUDA, OpenCL, or Objective-C code by writing code templates in the syntax of the generated language.

Additionally, quasiquoting of C-like languages enables a purely library-based system for inline C code in Haskell. This dramatically simplifies language interoperability, and especially, the use of frameworks and libraries written in C-like languages from Haskell. It is, for example, helpful in applications based on native GUI libraries and projects integrating code written in multiple languages.

In this workshop, we will write a simple mixed language GUI application in Haskell with inline Objective-C. We will use the library language-c-inline http://hackage.haskell.org/package/language-c-inline and work through three increasingly complex examples.

Due to the use of Objective-C and Cocoa, active participation will require the use of a computer running OS X. Unfortunately, to effectively demonstrate the power gained by being able to use native frameworks in inline code, we need to pick a concrete native framework. I suggest that attendees who lack the required system team up with somebody else for some pair programming.

This workshop will explore the use, but not the implementation of quasiquoting and inline C & Objective-C code. Hence, the material should be accessible to anybody with an intermediate-level working knowledge of Haskell and C. A knowledge of the basics of Objective-C will be helpful, but it is not required.

Software needed to join into the fun: https://gist.github.com/mchakravarty/fb8ecc1be86df1a23b33