MuniHac 2020

Virtual MuniHac 2020

MuniHac is a Haskell hackathon in the tradition of other Haskell Hackathons such as the ZuriHac, HacBerlin, UHac and many others. MuniHac is hosted and sponsored by TNG Technology Consulting GmbH and co-organized by Well-Typed LLP, and usually takes place in the beautiful city of Munich.

Thank you all for joining MuniHac 2020 remotely! In case you missed the event, all talks and most of the workshops were streamed live, and are available on YouTube. Check out the list of speakers below!

picture of participants

MuniHac 2020 Speakers

Miso: Haskell in the front-end (workshop)

Alejandro Serrano

Haskell has no shortage of good libraries to develop back-end services: Servant, Yesod, Persistent, you name it. But how about the front-end? Enter Miso, a modern framework, in the trail of the well-known React. As opposed to Elm or PureScript, Miso uses the same GHC compiler we know and love, so sharing code between client and server is as easier as it can get!

Prerequisites

No need of advanced knowledge, apart from basic Haskell (algebraic data types, functions, IO monad).

Workshop Preparation

In order to take the workshop, you need to install Nix and follow the instructions in the "Begin" section of the Miso manual.

Liquid Haskell (workshop)

Andres Löh

Liquid Haskell is an extension to Haskell that adds refinement types to the language, which are then checked via an external theorem prover such as z3. With refinement types, one can express many interesting properties of programs that are normally out of reach of Haskell's type system or only achievable via quite substantial encoding efforts and advanced type system constructs. On the other hand, the overhead for checking refinement types is often rather small, because the external solver is quite powerful.

Liquid Haskell used to be an external, standalone executable, but is now available as a GHC plugin, making it much more convenient to use.

In this tutorial, we'll discuss how refinement types work, give many examples of their use and learn how to work with Liquid Haskell productively.

Prerequisites

Good familiarity with Haskell basics is useful. However, no knowledge of type system language extensions or type-level programming is required.

Workshop Preparation

If you want to follow along with the development, please have a look at the README of the github repo at https://github.com/kosmikus/lh-munihac2020. It contains instructions on how to set up Liquid Haskell on your machine.

Polynomials in Haskell

Andrew Lelechenko

An experience report and a guided tour of the `poly` package (https://github.com/Bodigrim/poly), which is the fastest Haskell implementation of polynomial arithmetic. A short intro to the relevant parts of abstract algebra is included.

Hasktorch: A Haskell library for tensor math and differentiable functional programming

Austin Huang

Optimization over function composition is the unifying feature of machine learning using neural networks. Training neural networks utilizes differentiable layers, where layers implement pure functions. Higher order functions such as differentiation, jit optimization, distillation, hyperparameter optimization, are used in the process of building neural networks. Thus, neural networks can be considered to be "differentiable functional programming".

Despite this, popular neural networks frameworks today are implemented in an imperative programming language context. The goal of Hasktorch is to advance the use of typed functional programming for machine learning. Hasktorch is a library for tensor math and differentiable programming in Haskell. It shares the backend C++ libtorch library used by PyTorch and serves three primary objectives:

  1. Research on new functional programming methodology for developing and representing models that are more productive or lead to algorithm innovations.
  2. Building machine learning systems that are more reliable for the model and its integration with the software in which the model is embedded.
  3. Dissemination of new ideas from typed pure functional programming for machine learning to other languages and machine learning ecosystems.

Prerequisites

This is an intro talk, so relatively little background knowledge is assumed.

Building a RISC-V SoC with Haskell and Python (workshop)

Christiaan Baaij

Haskell and Python, languages that probably do not spring to mind when you think of languages that let you get down to the “Bare Metal” of your computer… But they can be used to (and are used to!) create that Bare Metal!

During this workshop you will learn how to create digital circuits using Haskell and Python, and about the tools needed to put those circuits on an FPGA, specialized chips that can be reconfigured into any digital logic circuit. Specifically, you are going to specify a RISC-V CPU in Haskell, and then run some small assembly programs on your RISC-V CPU inside of GHCi. Afterward, you will use “Clash”, a Haskell-to-Verilog compiler, to create Verilog from the Haskell description, a hardware description language which is understood by the FPGA tools. You will then package up the generated Verilog into a Python package to move to the next steps: Migen and LiteX.

LiteX is a System-on-Chip (SoC) builder made with the Python-based eDSL for circuit design called Migen. Using LiteX, you will connect the RISC-V CPU that you made in Haskell, to memories from which it will fetch its programs, and a UART to allow it to communicate with the outside world. You will then use Migen to transform the entire SoC to Verilog. You will then use the high-speed Verilog simulator (actually Verilog-to-C++ compiler) called Verilator to run some C-programs on your SoC and interact with it over a virtual UART.

Finally, the workshop mentor will demonstrate the use of the FPGA tools to create a bitstream, the configuration file the FPGA uses to reconfigure itself into the desired digital logic circuit. He will then upload the configuration to a FPGA development board and demonstrate you can interact with the SoC in the same way as you did in the Verilator simulation.

Prerequisites

You will need an intermediary knowledge of Haskell for this workshop.

Workshop Preparation

To follow along, you will need to have the following tools installed:

  • GHC 8.6.5 or higher (if you're using Windows 10 2004, you will need GHC 8.10.2)
  • cabal-install-3.2.0.0 or stack
  • Working python3 environment together with pip and virtualenv
  • verilator

Windows users are recommended to use WSL2 for the above: https://docs.microsoft.com/en-us/windows/wsl/install-win10

Haskell Beginners Workshop

David Luposchainsky

Goal of the workshop is tackling the very basics of Haskell development. After setting up the compiler, we’ll be going over the basic language features, with frequent small exercises to get hands-on experience. In the end, we’ll have seen many concepts core to Haskell development, reaching a certain degree of familiarity with the language to serve as a good basis for further projects.

Contravariant logging: How to add logging without getting grumpy

Duncan Coutts

Logging usually makes me grumpy. It tends to clutter code and adds unnecessary dependencies. It's just not beautiful.

I want to share the good news that there is an approach to logging that does not make me grumpy, and I have used it in a large project where it has worked out well. It is a a relatively new approach based on contravariant functors, that avoids cluttering the code, has a simple general interface that minimises concrete dependencies and still allows a choice of logging backend.

This talk will cover the problems with logging libraries, how contravariant logging improves things and how to apply contravariant logging in your project, with your choice of logging backend.

Being lazy without being bloated

Edsko de Vries

Laziness is one of Haskell's most distinctive features. It is one of the two features of functional programming that "Why Functional Programming Matters" identifies as key to modularity, but it is also one of the most frequently cited features of Haskell that programmers would perhaps like to change. One reason for this ambivalence is that laziness can give rise to space leaks, which can sometimes be fiendishly difficult to debug. In this talk we will present a new library called nothunks which can be used to test for the absence of unexpected thunks in long-lived data; when an unexpected thunk is found, a "stack trace" is returned identifying precisely where the thunk is ("the second coordinate of a pair in a map in a list in type T"). In combination with QuickCheck, this can be used to test that an API does not create any thunks when it shouldn't and thunks that are created are easily identified and fixed. Whilst it doesn't of course fix all space leaks, it can help avoid a significant proportion of space leaks due to excessive laziness.

Exploring Parsley: Working with Staged Selective Parsers

Jamie Willis

Parser combinator libraries are a popular approach to writing parsers in the functional world. In particular, monadic parser combinators take centre stage. But when performance of these parser combinators become a concern, then monads prevent us from analysing and optimising our parsers effectively. Selective functors give a ray of hope to the combinator world by generating a purely static structure eligable for analysis and staging, yielding high-performance parsers. This talk will focus on how working with Parsley is different to working with a normal monadic parser combinator library as well as touching on what makes it tick.

Prerequisites

Knowledge about Functors, Applicatives, Alternatives and their associated combinators is assumed. Knowledge about ST will be useful, but not required. It is furthermore useful to generally know what a parser is doing, but no knowledge about Haskell parser combinators is required. Neither does the talk assume knowledge about Template Haskell or staging.

An Introduction to Applied Category Theory

Johannes Drever

Originating in abstract mathematics, category theory bridges different mathematical areas. However, it recently also showed potential for a wide range of practical applications. In the functional programming community applications of functors, monads and monoids have been well known for a long time.

In this talk Johannes will present recent developments in applied category theory. He will give a detailed example of the categorical view on databases. Specifically, how database mappings may be expressed as functors and how data migration functors follow naturally from the categorical framework. A demonstration of the categorical query language CQL will illustrate functorial data migrations on a concrete example.

This ain't your Daddy's Probability Monad

Lars Brünjes

It is well known that (discrete) probability distributions can be implemented as monads in Haskell in various more or less sophisticated ways.

Things become more complicated when you consider processes that can take a probabilistic amount of time or even fail with a certain probability. How do such processes compose sequentially or in parallel?

An example of this is sending a message in a network. Transmission time follows a (continuous) probability distribution, and it is even possible that the message will never reach its receiver.

In this presentation, Lars will extend the standard notion of probability monad to include a notion of probabilistic duration, which will enable you to model things like communication in a network of nodes. Lars will answer questions like: "How long will it take a signal to reach each node in the network?" and "How does the answer depend on network topology?"

Prerequisites

This talk assumes some familiarity with Haskell fundamentals, and the Applicative and Monad classes.

Theorems for Free

Lars Hupel

In the typed functional programming communities, there is much talk about "reasoning with types". But rarely is this elaborated into something concrete. Just how can we extract tangible information from types beyond playing mere type tetris? The secret sauce is called parametricity, first described by John C. Reynolds, and later applied to Haskell by Philip Wadler in his seminal paper "Theorems for free!".

Prerequisites

This talk expects basic understanding of type variables. Everything else – including the mathematics – will be introduced.

Video & game live coding in Haskell (workshop)

Manuel Bärenz

Learn how to program a small arcade game while you're running and playing it. We use functional reactive programming for this, but no previous knowledge of FRP is necessary.

Prerequisites

Required background
  • Basic Haskell knowledge (Monads, data types, records, type classes, simple transformers like StateT and ReaderT
  • Basic Arrow notation (combinators such as >>>, *** and &&&, proc -> do notation
Optional, helpful background
  • Grasp of basic concept in Functional Reactive Programming (FRP) such as signals/behaviours, streams, events.
  • Basic physics simulation (position, speed, simple collision detection).
  • The gloss vector graphics library.

Workshop Preparation

We will begin development from a scaffolding project. You will need to clone it and install certain software in order to participate.

The scaffolding project is found here: https://github.com/turion/essence-of-live-coding-tutorial/

If you are planning on attending and hacking on a project yourself, then please complete the installation steps before attending the tutorial. If any of the steps fails, please leave an issue at https://github.com/turion/essence-of-live-coding-tutorial/issues so we can solve the problem before the tutorial starts.

You have successfully set up your environment once you see an interactive window with a ball that starts to move and bounce once you click in it. Please make sure that you complete all the steps until there.

Optional reading material

Control your effects (workshop)

Michael Sperber

Functional programming is all about not using effects. Particularly in Haskell. Well, it turns out we sometimes do want to program with effects. When that happens, we keep them under control. With monads. Right? Unfortunately, monads compose quite poorly in Haskell, and when they do, using them is often awkward. The result is that much Haskell code takes a dive into the IO monad when really it should not. This tutorial is if you're still willing to fight this disturbing trend.

Strangely enough, with monads in Haskell past their 25th anniversary, this problem is only lately getting the attention it deserves. As a result, we have a handful of patterns and a quickly growing collection of effects libraries. Should you jump on one of those bandwagons or plod on with trusty old monad transformers? This workshop will help you out!

Prerequisites

To get value from the workshop, you should have rudimentary knowledge of monads.

Workshop Preparation

If you want to play with the code, you should have a working installation of GHC 8.8. (GHC 8.10 might be problematic.)

Migrating HLint to the GHC API

Neil Mitchell

HLint is over 14 years old. Over the last 14 years we've changed license, project name, source control, configuration and much more besides. But until recently, HLint had always used the haskell-src-exts library for parsing Haskell. That parser was forked from the GHC parser 16 years ago, and as GHC has accumulated 16 years worth of bug fixes and features, the amount of Haskell code that could be parsed by GHC but not HLint increased. The obvious solution was to use the GHC API for parsing. In this talk I'll describe why we were so reluctant to move to the GHC API, how we decoupled HLint from GHC versions with ghc-lib, and how to change almost every line in a large project, without breaking anything or stopping ongoing development.

Persistence makes a Difference

Nicolas Wu

This talk is aimed at beginners who would like to understand the efficiency of some basic data structures in Haskell. We will explore the implementation of commonly used data structures such as lists and trees, and show how using techniques such as difference lists helps produce efficient structures.

A data structure is persistent if all of its previous incarnations remain available after a series of updates. In Haskell, all data structures are automatically persistent by default since an update corresponds to producing a new value based on the old one.

Using persistent data structures can lead to performance problems. For instance, appending two lists together has a linear cost in the first argument, and this can lead to an expensive overhead when several lists are appended together. This talk will demonstrate how difference lists can be used to overcome this efficiency problem, and others like it.

Let's write a Haskell Language Server plugin (workshop)

Pepe Iborra

In this workshop we will add a code lens over every implicit import statement, showing the names actually imported from the module. Along the way we will learn about the HLS plugin model, how it relates to ghcide, and how to build and test our plugin.

Workshop Preparation

  • Please follow the setup instructions in https://github.com/pepeiborra/hls-tutorial" to get a working development environment for Haskell-language-server. Importantly, please make sure to run cabal build in advance of the workshop as it can take a long time.
  • If possible read the full tutorial, in order to become acquainted with the basics of HLS plugin development.
  • A VSCode Live Share will be available for those participants who wish to join, but will not be a requirement.

Partial Type Constructors

Richard Eisenberg

When we describe the type Set a, we say that this type makes sense for any a. But this is a small lie: it really only makes sense for types a that have an ordering – that is, types for which Ord a holds. This small lie has far-reaching consequences. It means that we cannot write a Functor instance for Set, it means we might accidentally write uncallable functions that take a Set (Int -> Int), and it means we must repetitively write Ord a => ... constraints on every function working with Sets.

This talk will explore the possibility of explicitly partial type constructors, where we can declare loudly that types like Set work only with some type arguments, but not others. The design proposed improves error messages, simplifies type signatures, and allows instances like Functor over Sets.

The new Windows I/O manager (WinIO) in GHC

Tamar Christina

GHC has a new Windows I/O manager that allows for native support for I/O on Windows. The new I/O manager covers everything from Files to Pipes and Sockets in a completely asynchronous manner while providing as much information to the Haskell runtime such that useful work can still be done while blocked on I/O. The new I/O manager allows for significantly better Windows support and gives a path forward to a more stable and faster compiler.

Introduction to Opaleye (workshop)

Tom Ellis

This workshop will introduce Opaleye, a Haskell embedded domain specific language for writing PostgreSQL queries. In the workshop you will learn how to write type safe and composable code for querying and modifying a Postgres database. It will require basic familiarity with writing Haskell code but will otherwise be suitable for beginners.

Prerequisites

To get the most out of this workshop you should be familiar with at least intermediate-level Haskell, including "do" notation. Familiarity with SQL will also be useful.

Workshop Preparation

If you want to follow along by writing your own code examples you should know how to clone a Haskell git repository and build it with Cabal (or other build tool of your choice). Familiarity with the list monad would be particularly helpful for understanding Opaleye's semantics.

Other years

Contact

You can reach the organizers via email: munihac@tngtech.com.

Legal Notice / Impressum