Index

Haskell Communities and Activities Report

Thirty Fourth Edition – May 2018

Mihai Maruseac (ed.)

Chris Allen

Christopher Anand

Moritz Angermann

Francesco Ariis

Heinrich Apfelmus

Gershom Bazerman

Doug Beardsley

Jost Berthold

Ingo Blechschmidt

Sasa Bogicevic

Emanuel Borsboom

Jan Bracker

Jeroen Bransen

Joachim Breitner

Rudy Braquehais

Björn Buckwalter

Erik de Castro Lopo

Manuel M. T. Chakravarty

Eitan Chatav

Olaf Chitil

Alberto Gomez Corona

Nils Dallmeyer

Tobias Dammers

Kei Davis

Dimitri DeFigueiredo

Richard Eisenberg

Maarten Faddegon

Dennis Felsing

Olle Fredriksson

Phil Freeman

Marc Fontaine

PALI Gabor Janos

Micha J. Gajda

Ben Gamari

Michael Georgoulopoulos

Andrew Gill

Mikhail Glushenkov

Mark Grebe

Gabor Greif

Adam Gundry

Jennifer Hackett

Jurriaan Hage

Martin Handley

Bastiaan Heeren

Sylvain Henry

Joey Hess

Kei Hibino

Guillaume Hoffmann

Graham Hutton

Nicu Ionita

Judah Jacobson

Patrik Jansson

Wanqiang Jiang

Dzianis Kabanau

Nikos Karagiannidis

Anton Kholomiov

Oleg Kiselyov

Ivan Kristo

Yasuaki Kudo

Harendra Kumar

Rob Leslie

David Lettier

Ben Lippmeier

Andres Löh

Rita Loogen

Tim Matthews

Simon Michael

Andrey Mokhov

Dino Morelli

Damian Nadales

Henrik Nilsson

Wisnu Adi Nurcahyo

Ulf Norell

Ivan Perez

Jens Petersen

Sibi Prabakaran

Bryan Richter

Herbert Valerio Riedel

Alexey Radkov

Vaibhav Sagar

Kareem Salah

Michael Schröder

Christian Höner zu Siederdissen

Ben Sima

Jeremy Singer

Gideon Sireling

Erik Sjöström

Chris Smith

Michael Snoyman

David Sorokin

Lennart Spitzner

Yuriy Syrovetskiy

Jonathan Thaler

Henk-Jan van Tuyl

Tillmann Vogt

Michael Walker

Li-yao Xia

Kazu Yamamoto

Yuji Yamamoto

Brent Yorgey

Christina Zeller

Marco Zocca

Preface

This is the 34th edition of the Haskell Communities and Activities Report. This report has 148 entries, 5 more than in the previous edition. Of these, 39 projects have received substantial updates and 18 entries are completely new. As usual, fresh entries – either completely new or old entries which have been revived after a short temporarily disappearance – are formatted using a blue background, while updated entries have a header with a blue background.

Since my goal is to keep only entries which are under active development (defined as receiving an update in a 3-editions sliding window), contributions from May 2015 and before have been completely removed, excepting those related to user groups and communities. However, they can be resurfaced in the next edition, should a new update be sent for them. For the 30th edition, for example, we had around 20 new entries which resurfaced.

A call for new HCAR entries and updates to existing ones will be issued on the Haskell mailing lists in late September/early October.

Now enjoy the current report and see what other Haskellers have been up to lately. Any feedback is very welcome, as always.

Mihai Maruseac, LeapYear Technologies Inc., US

<hcar at haskell.org>

PS: For this edition, I would like to thank Robin Bate Boerop for mentioning HCAR in his talk at BayHac. A few of the new entries are the result of his announcement.

1 Community

1.1 Haskell’ — Haskell 2020 Report by: Herbert Valerio Riedel Participants: Andres Löh, Antonio Nikishaev, Austin Seipp, Carlos Camarao de Figueiredo, Carter Schonwald, David Luposchainsky, Henk-Jan van Tuyl, Henrik Nilsson, Herbert Valerio Riedel, Iavor Diatchki, John Wiegley, JoséManuel Calderon Trilla, Jurriaan Hage, Lennart Augustsson, M Farkas-Dyck, Mario Blazevic, Nicolas Wu, Richard Eisenberg, Vitaly Bragilevsky, Wren Romano Haskell’ is an ongoing process to produce revisions to the Haskell standard, incorporating mature language extensions and well-understood modifications to the language. New revisions of the language are expected once per year. The goal of the Haskell Language committee together with the Core Libraries Committee is to work towards a new Haskell 2020 Language Report. The Haskell Prime Process relies on everyone in the community to help by contributing proposals which the committee will then evaluate and, if suitable, help formalise for inclusion. Everyone interested in participating is also invited to join the haskell-prime mailing list. Four years (or rather ~3.5 years) from now may seem like a long time. However, given the magnitude of the task at hand, to discuss, formalise, and implement proposed extensions (taking into account the recently enacted three-release-policy) to the Haskell Report, the process shouldn’t be rushed. Consequently, this may even turn out to be a tight schedule after all. However, it’s not excluded there may be an interim revision of the Haskell Report before 2020. Based on this schedule, GHC 8.8 (likely to be released early 2020) would be the first GHC release to feature Haskell 2020 compliance. Prior GHC releases may be able to provide varying degree of conformance to drafts of the upcoming Haskell 2020 Report. The Haskell Language 2020 committee starts out with 20 members which contribute a diversified skill-set. These initial members also represent the Haskell community from the perspective of practitioners, implementers, educators, and researchers. The Haskell 2020 committee is a language committee; it will focus its efforts on specifying the Haskell language itself. Responsibility for the libraries laid out in the Report is left to the Core Libraries Committee (CLC). Incidentally, the CLC still has an available seat; if you would like to contribute to the Haskell 2020 Core Libraries you are encouraged to apply for this opening.

1.2 Haskellers Report by: Michael Snoyman Status: experimental Haskellers is a site designed to promote Haskell as a language for use in the real world by being a central meeting place for the myriad talented Haskell developers out there. It allows users to create profiles complete with skill sets and packages authored and gives employers a central place to find Haskell professionals. Haskellers is a web site in maintenance mode. No new features are being added, though the site remains active with many new accounts and job postings continuing. If you have specific feature requests, feel free to send them in (especially with pull requests!). Haskellers remains a site intended for all members of the Haskell community, from professionals with 15 years experience to people just getting into the language. Further reading http://www.haskellers.com/

2 Books, Articles, Tutorials

2.1 Oleg’s Mini Tutorials and Assorted Small Projects Report by: Oleg Kiselyov The collection of various Haskell mini tutorials and assorted small projects (http://okmij.org/ftp/Haskell/) has received a manifold addition centered on Type Equality and Overlapping Instances. Type Equality Predicates and Assertions We describe several forms of testing two types for equality, and asserting that two types are equal or not equal. The predicates differ in how they compare type variables, whether they allow wildcards, etc. Described predicates: |TypeEq t1 t2|: simplifies to |HTrue| if the type checker regards |t1| and |t2| as the same. The result is |HFalse| if the type checker can see the two types as different. The decision is postponed if |t1| and |t2| are not instantiated enough;

|TypeEqTotal t1 t2|: immediately yields either |HFalse| or |HTrue|, regardless of how |t1| and |t2| are instantiated. A type variable is |TypeEqTotal| only to itself;

|t1 t2|: asserts that |t1| and |t2| are the same, and, as a side effect , instantiates type variables in |t1| and |t2| to make the type the same. If the types cannot be made the same, a type error is raised;

, instantiates type variables in |t1| and |t2| to make the type the same. If the types cannot be made the same, a type error is raised; A predicate version of |t1 t2| – that is, |TypeEq| with the side-effect of instantiation of type variables – is incoherent; Read the tutorial online. How to implement type equality. For and Against Overlapping Instances Overlapping instances are so practically appealing because they express the common pattern of adding a special case to an existing set of overloaded functions. We illustrate the pattern on a real-life example of optimizing a generic library. The example demonstrates the conflict between two practically useful features, overlapping instances and associated data types. Overlapping instances are controversial because they straddle a contradiction. They embody “negation as failure”: the general type class instance is chosen for the given type only when all more specific instances failed to match the type. Negation-as-failure presupposes closed world, or a fixed set of instances. However, type classes are open: the user may add more instances at any time, in the same or different modules. Read the tutorial online. Another use case: Comparing types by their shape. Objections to overlapping instances. Type-level type introspection, equality and matching We describe type-level representation of types: essentially type-level Typeable. The library lets us check if two types are equal or dis-equal, and compare them by shape. We may use wildcards in type comparisons. The library exhibits type-level conditional and higher-order type families such as |Member| (which takes a type-level equality predicate as an argument). Read the tutorial online. Using TTypeable to avoid OverlappingInstances.

2.2 School of Haskell Report by: Michael Snoyman Participants: Edward Kmett, Simon Peyton Jones and others Status: active The School of Haskell has been available since early 2013. It’s main two functions are to be an education resource for anyone looking to learn Haskell and as a sharing resources for anyone who has built a valuable tutorial. The School of Haskell contains tutorials, courses, and articles created by both the Haskell community and the developers at FP Complete. Courses are available for all levels of developers. School of Haskell has been open sourced, and is available from its own domain name (schoolofhaskell.com). In addition, the underlying engine powering interactive code snippets, ide-backend , has also been released as open source. Currently 3150 tutorials have been created and 441 have been officially published. Some of the most visited tutorials are Text Manipulation, Attoparsec, Learning Haskell at the SOH, Introduction to Haskell - Haskell Basics, and A Little Lens Starter Tutorial. Over the past year the School of Haskell has averaged about 16k visitors a month. All Haskell programmers are encouraged to visit the School of Haskell and to contribute their ideas and projects. This is another opportunity to showcase the virtues of Haskell and the sophistication and high level thinking of the Haskell community. Further reading https://www.schoolofhaskell.com/

2.3 Learning Haskell Report by: Manuel M. T. Chakravarty Participants: Gabriele Keller Status: Work in progress with eight published chapters Learning Haskell is a new Haskell tutorial that integrates text and screencasts to combine in-depth explanations with the hands-on experience of live coding. It is aimed at people who are new to Haskell and functional programming. Learning Haskell does not assume previous programming expertise, but it is structured such that an experienced programmer who is new to functional programming will also find it engaging. Learning Haskell combines perfectly with the Haskell for Mac programming environment, but it also includes instructions on working with a conventional command-line Haskell installation. It is a free resource that should benefit anyone who wants to learn Haskell. Learning Haskell is still work in progress with eight chapters already available. The current material covers all the basics, including higher-order functions and algebraic data types. Learning Haskell is approachable and fun – it includes topics such as illustrating various recursive structures using fractal graphics, such as this fractal tree. Further chapters will be made available as we complete them. Further reading Learning Haskell is free at http://learn.hfm.io

is free at http://learn.hfm.io Blog post with some background: http://blog.haskellformac.com/blog/learning-haskell

2.4 Programming in Haskell - 2nd Edition Report by: Graham Hutton Status: published September 2016 Overview Haskell is a purely functional language that allows programmers to rapidly develop software that is clear, concise and correct. This book is aimed at a broad spectrum of readers who are interested in learning the language, including professional programmers, university students and high-school students. However, no programming experience is required or assumed, and all concepts are explained from first principles with the aid of carefully chosen examples and exercises. Most of the material in the book should be accessible to anyone over the age of around sixteen with a reasonable aptitude for scientific ideas. Haskell is a purely functional language that allows programmers to rapidly develop software that is clear, concise and correct. This book is aimed at a broad spectrum of readers who are interested in learning the language, including professional programmers, university students and high-school students. However, no programming experience is required or assumed, and all concepts are explained from first principles with the aid of carefully chosen examples and exercises. Most of the material in the book should be accessible to anyone over the age of around sixteen with a reasonable aptitude for scientific ideas. Structure The book is divided into two parts. Part I introduces the basic concepts of pure programming in Haskell and is structured around the core features of the language, such as types, functions, list comprehensions, recursion and higher-order functions. Part II covers impure programming and a range of more advanced topics, such as monads, parsing, foldable types, lazy evaluation and reasoning about programs. The book contains many extended programming examples, and each chapter includes suggestions for further reading and a series of exercises. The appendices provide solutions to selected exercises, and a summary of some of the most commonly used definitions from the Haskell standard prelude. What’s New The book is an extensively revised and expanded version of the first edition. It has been extended with new chapters that cover more advanced aspects of Haskell, new examples and exercises to further reinforce the concepts being introduced, and solutions to selected exercises. The remaining material has been completely reworked in response to changes in the language and feedback from readers. The new edition uses the Glasgow Haskell Compiler (GHC), and is fully compatible with the latest version of the language, including recent changes concerning applicative, monadic, foldable and traversable types. Further reading http://www.cs.nott.ac.uk/~pszgmh/pih.html

2.5 Haskell Programming from first principles, a book for all Report by: Chris Allen Participants: Julie Moronuki Status: Content complete, in final editing Haskell Programming is a book that aims to get people from the barest basics to being well-grounded in enough intermediate Haskell concepts that they can self-learn what would be typically required to use Haskell in production or to begin investigating the theory and design of Haskell independently. We’re writing this book because many have found learning Haskell to be difficult, but it doesn’t have to be. What particularly contributes to the good results we’ve been getting has been an aggressive focus on effective pedagogy and extensive testing with reviewers as well as feedback from readers. My coauthor Julie Moronuki is a linguist who’d never programmed before learning Haskell and authoring the book with me. Haskell Programming is currently content complete and is approximately 1,200 pages long in the v0.12.0 release. The book is available for sale during the early access, which includes the 1.0 release of the book in PDF. We’re still editing the material. We expect to release the final version of the book this winter. Further reading http://haskellbook.com

https://superginbaby.wordpress.com/2015/05/30/learning-haskell-the-hard-way/

http://bitemyapp.com/posts/2015-08-23-why-we-dont-chuck-readers-into-web-apps.html

The School of Computing Science at the University of Glasgow has partnered with the FutureLearn platform to deliver a six week massive open online course (MOOC) entitled Functional Programming in Haskell. The course goes through the basics of the Haskell language, using short videos, an online REPL, multiple choice quizzes and articles. The third run of the course began on 1 Apr 2018. Around 1500 people signed up for the course, 70%of whom actively engaged with the materials. The most engaging aspect of the activity is the comradely atmosphere in the discussion forums. The course is in a steady state, running two times per year in April and September. Visit our site to register your interest. We are continuously refining the learning materials, based on learner feedback from the course. We presented some initial experiences at the Trends in Functional Programming in Education 2017 conference. Further reading https://www.futurelearn.com/courses/functional-programming-haskell

https://www.cs.kent.ac.uk/people/staff/sjt/TFPIE2017/TFPIE_2017/Papers/TFPIE_2017_paper_5.pdf

3 Implementations

2018 saw GHC’s first release under its new accelerated release schedule. GHC 8.4.1 contained improvements in GHC’s standard libraries, code generation, and hundreds of bug fixes. Our focus is now turned to the next major release of the 8.0 series, GHC 8.6.1. Major changes in GHC 8.6 3.1.1 Libraries, source language, and type system The new -XNumericUnderscores extension allows underscores to be used in numeric literals, improving legibility of longer literals.

extension allows underscores to be used in numeric literals, improving legibility of longer literals. The long-awaited -XBlockArguments extensions allows do and lambda expressions to be used directly as a function argument, eliminating the need for parentheses or an application operator.

extensions allows and lambda expressions to be used directly as a function argument, eliminating the need for parentheses or an application operator. Possibly: The -XDerivingVia extension, a proposed relative of -XGeneralizedNewtypeDeriving which allows users to derive typeclasses using a generalized form of newtype deriving.

extension, a proposed relative of which allows users to derive typeclasses using a generalized form of deriving. The Data.Functor.Contravariant module from the contravariant package has been moved into base . 3.1.1.1 Compiler The compiler’s core simplifier now performs significantly more varieties of numeric constant folding.

Incomplete pattern match warnings are now offered for guards in pattern bindings and MultiWayIf alternatives.

alternatives. A new syntax tree representation based on Trees That Grow. This will make it easier for external users to add their own annotations to the HsSyn AST. In future this should allow Shayan Najd to harmonise the GHC and Template Haskell ASTs, and for the ghc-exactprint annotations to move into the GHC parsed AST (Shayan Najd and Alan Zimmerman).

AST. In future this should allow Shayan Najd to harmonise the GHC and Template Haskell ASTs, and for the annotations to move into the GHC parsed AST (Shayan Najd and Alan Zimmerman). Further improvements in support for cross-compilation (Moritz Angerman)

Replacement of the make -based build system with Hadrian. Hadrian, while being usable in GHC 8.4, should be able to replace make in nearly all uses. Moreover, it will have significantly better documentation and support relocatable installation trees, a feature unavailable in the current build system (Andrey Mokhov, Zhen Zhang, Moritz Angerman, Alp Mestanogullari)

-based build system with Hadrian. Hadrian, while being usable in GHC 8.4, should be able to replace in nearly all uses. Moreover, it will have significantly better documentation and support relocatable installation trees, a feature unavailable in the current build system (Andrey Mokhov, Zhen Zhang, Moritz Angerman, Alp Mestanogullari) Many, many bug fixes. 3.1.1.2 Runtime system Significantly improved Windows support with a new I/O manager, long file path compatibility and dynamic linking support (Tamar Christina). GHC proposals Since the launch of the GHC proposals process (https://github.com/ghc-proposals/ghc-proposals), over 128 proposals have been created, 41 have been submitted to the committee and 19 have been accepted. These are: OverloadedRecordFields (PR #6)

Update levity polymorphism (PR #29)

Make Constraint not apart from Type (PR #32)

Hex floats (PR #37)

Allow signatures on pattern synonym constructors (PR #42)

Explicit foralls proposal (PR #55)

Overhaul deriving instances for empty data types proposal (PR #63)

Require namespacing fixity declarations for type names (PR #65)

Extend -Wall with incomplete-uni-pattern s and incomplete-record-updates (PR #71)

with s and (PR #71) Add small primitive types, like Int8# / Word8# (PR #74)

/ (PR #74) Propose underscores in numeric literals (PR #76)

Deprecate STM invariant mechanism (PR #77)

Type-level type applications (PR #80)

Embrace ( Type :: Type ) (PR #83)

) (PR #83) Allow do etc. to be used as function arguments without a $(PR #90)

etc. to be used as function arguments without a $(PR #90) As-pattern synonyms (PR #94)

Unlifted Newtypes (PR #98)

Proposal for Source Plugins (PR #107)

Quantified constraints (PR #109) At the time of writing, 15 proposals are under active discussion by the community and 13 proposals are under review by the committee. Looking forward: What’s hot GHC is lucky to have a large number of volunteer contributors. Matthias Pall Gissurarson has been adding support for significantly improved diagnostics messages for typed holes.

Ryan Scott has been busily triaging and fixing bugs on a daily basis, and generally helps to keep things running smoothly.

Mark Karpov of Tweag I/O has been pushing forward GHC’s continuous integration reboot. Using computational resources generously provided by Google X, GHC will be moving its continuous integration infrastructure to CircleCI and Appveyor. This will allow us to more easily produce binary distributions

Boldizsar Németh has been working on improving GHC’s plugin story. GHC currently disables to its recompilation checking when compiling with plugin, dramatically increasing build times in common situations.

Joachim Breitner has been continuing his work on improving GHC’s treatment of “join points”.

Michal Terepeta has been performing a variety of refactoring and optimization in the backend as well as introducing support for sub-word-sized fields.

Andreas Klebinger has been working on improving various facets of GHC’s backend code generator. In the past few weeks alone he has contributed performance optimisations for GHC’s C-- pass, improved common subexpression elimination, and added infrastructure for taking advantage of branch likelihoods.

Tamar Christina has continued his work on making GHC run great on Windows. Recently he has been working to finish up a patchset enabling dynamic linking support on Windows. Tamar is also working on a rework of GHC’s Windows IO manager implementation. The new implementation will take full advantage of Windows’ asynchronous I/O interfaces and should solve dozens of long-standing tickets.

In addition to contributing valuable code review and bug triaging, Sebastian Graf has contributed fixes to a variety of issues throughout the compiler, including fixes to demand analysis and improvements to common Enum instances.

instances. Recently Patrick Dougherty dusted off a long-dormant patch making the ghc-heapview package a first-class citizen. This package allows Haskell programs to introspect the heap

package a first-class citizen. This package allows Haskell programs to introspect the heap Andrey Mokhov, Zhen Zhang, Moritz Angermann, Alp Mestanogullari, Tamar Christina, Patrick Dougherty and Tao He have all been working on the finishing the last mile of the switch to GHC’s new Shake-based build system, Hadrian.

One of the larger projects in the pipeline for 8.6 is Alan Zimmerman and Shayan Najd’s refactoring of GHC to use the extensible Trees That Grow AST structure.

Alan Zimmerman has also been looking to teach GHC’s parser to parse incrementally, allowing lower latency reparsing during IDE usage.

Simon Peyton Jones implemented so-called quantified constraints, which have been on the to-do list for over a decade, and were described in a 2017 Haskell Symposium paper. (http://i.cs.hku.hk/~bruno//papers/hs2017.pdf) A GHC proposal (https://github.com/Gertjan423/ghc-proposals/blob/quantified-constraints/proposals/0000-quantified-constraints.rst) to adopt quantified constraints was agreed, so they will appear in GHC 8.6. As always, if you are interested in contributing to any facet of GHC, be it the runtime system, type-checker, documentation, simplifier, or anything in between, please come speak to us either on IRC ( #ghc on irc.freeenode.net ) or ghc-devs@haskell.org . Happy Haskelling! Further reading GHC website: https://haskell.org/ghc/

GHC users guide: https://downloads.haskell.org/~ghc/master/users_guide/

ghc-devs mailing list: https://mail.haskell.org/mailman/listinfo/ghc-devs

3.2 The Helium Compiler Report by: Jurriaan Hage Participants: Bastiaan Heeren Helium is a compiler that supports a substantial subset of Haskell 98 (but, e.g., n+k patterns are missing). Type classes are restricted to a number of built-in type classes and all instances are derived. The advantage of Helium is that it generates novice friendly error feedback, including domain specific type error diagnosis by means of specialized type rules. Helium and its associated packages are available from Hackage. Install it by running cabal install helium . You should also cabal install lvmrun on which it dynamically depends for running the compiled code. Currently Helium is at version 1.8.1. The major change with respect to 1.8 is that Helium is again well-integrated with the Hint programming environment that Arie Middelkoop wrote in Java. The jar-file for Hint can be found on the Helium website, which is located at http://www.cs.uu.nl/wiki/Helium. This website also explains in detail what Helium is about, what it offers, and what we plan to do in the near and far future. A student has added parsing and static checking for type class and instance definitions to the language, but type inferencing and code generating still need to be added. Completing support for type classes is the second thing on our agenda, the first thing being making updates to the documentation of the workings of Helium on the website.

3.3 Specific Platforms

The Fedora Haskell SIG works to provide good Haskell support in the Fedora Project Linux distribution. For the Fedora 28 release on 1st May, ghc was updated to 8.2.2 and packages to Stackage LTS 10 versions. Also the shared dynamic libraries now live in system libdir. Over 30 new packages were added to Fedora 28. We use the cabal-rpm packaging tool to create and update Haskell packages, and fedora-haskell-tools to rebuild them. For the next release we plan to update to LTS 11, and also to do some packaging changes to subpackage haddock documentation for libraries. A Fedora Copr repo is available for ghc-8.4.2. If you are interested in Fedora Haskell packaging, please join our mailing-list and the Freenode #fedora-haskell channel. You can also follow @fedorahaskell for occasional updates. Further reading Homepage: http://fedoraproject.org/wiki/Haskell_SIG

Mailing-lists: https://lists.fedoraproject.org/archives/list/haskell@lists.fedoraproject.org/ and https://lists.fedoraproject.org/archives/list/haskell-devel@lists.fedoraproject.org/

Package list: https://admin.fedoraproject.org/pkgdb/packager/haskell-sig/

Copr repos: https://copr.fedorainfracloud.org/coprs/petersen/ghc-8.0.2 and https://copr.fedorainfracloud.org/coprs/petersen/stack

Fedora Haskell Tools: https://github.com/fedora-haskell/fedora-haskell-tools

The Debian Haskell Group aims to provide an optimal Haskell experience to users of the Debian GNU/Linux distribution and derived distributions such as Ubuntu. We try to follow the Haskell Platform versions for the core packages and package a wide range of other useful libraries and programs. At the time of writing, we maintain 1077 source packages. A system of virtual package names and dependencies, based on the ABI hashes, guarantees that a system upgrade will leave all installed libraries usable. Most libraries are also optionally available with profiling enabled and the documentation packages register with the system-wide index. The current stable Debian release (“strech”) provides GHC 8.0.1. In Debian unstable and testing (“buster”, the next release) we ship GHC 8.0.2. GHC 8.2 is staged in “experimental”. Debian users benefit from the Haskell ecosystem on 22 architecture/kernel combinations, including the non-Linux-ports KFreeBSD and Hurd. Further reading http://wiki.debian.org/Haskell

3.4 Related Languages and Language Design

3.4.1 hs-to-coq Report by: Joachim Breitner Participants: Antal Spector-Zabusky, Stephanie Weirich Status: working The hs-to-coq tool, written by Antal Spector-Zabusky, Joachim Breitner and Stephanie Weirich, translates a large subset of Haskell into Gallina, the programming langauge of the proof assistant Coq. The translation process is configurable and allows the user to stub out low-level features, to map Haskell types and functions to corresponding existing Coq types and functions and to declare termination arguments. It has been used to verify a large subset of Haskell’s containers library. Further reading https://github.com/antalsz/hs-to-coq/

https://arxiv.org/abs/1711.09286 paper introducing hs-to-coq

https://arxiv.org/abs/1803.06960 paper discussing the verification of containers

Agda is a dependently typed functional programming language (developed using Haskell). A central feature of Agda is inductive families, i.e., GADTs which can be indexed by values and not just types. The language also supports coinductive types, parameterized modules, and mixfix operators, and comes with an interactive interface—the type checker can assist you in the development of your code. A lot of work remains in order for Agda to become a full-fledged programming language (good libraries, mature compilers, documentation, etc.), but already in its current state it can provide lots of value as a platform for research and experiments in dependently typed programming. Release of Agda 2.5.4 is planned for early summer 2018 with a number of new features: do -notation

-notation Compile-time call-by-need evaluation

Builtin 64-bit words

Improved performance of compiled code Further reading The Agda Wiki: http://wiki.portal.chalmers.se/agda/

3.4.3 Disciple Report by: Ben Lippmeier Participants: Ben Lippmeier, Jacob Stanley Status: experimental, active development The Disciplined Disciple Compiler (DDC) is a research compiler used to investigate program transformation in the presence of computational effects. It compiles a family of strict functional core languages and supports region and effect typing. This extra information provides a handle on the operational behaviour of code that isn’t available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. What is new? DDC v0.5.1 was released in late October, and is in "working alpha" state. The main new features are: Copying garbage collection using the LLVM shadow stack.

Implicit parameters, which support Haskell-like ad-hoc overloading using dictionaries.

Floating point primitives.

Travis continuous integration for the GitHub site.

A new Sphinx based user guide and homepage. We are currently working on a new indexed binary format for interface files, as re-parsing interface files is currently a bottleneck. The file format is to be provided by the Shimmer project, which has been split out into a separate repo. Further reading http://disciple.ouroborus.net

https://github.com/DDCSF/shimmer

4 Libraries, Tools, Applications, Projects

4.1 Language Extensions and Related Projects

4.1.1 Dependent Haskell Report by: Richard Eisenberg Status: work in progress I am working on an ambitious update to GHC that will bring full dependent types to the language. In GHC 8, the Core language and type inference have already been updated according to the description in our ICFP’13 paper [1]. Accordingly, all type-level constructs are simultaneously kind-level constructs, as there is no distinction between types and kinds. Specifically, GADTs and type families are promotable to kinds. At this point, I conjecture that any construct writable in those other dependently-typed languages will be expressible in Haskell through the use of singletons. Building on this prior work, I have written my dissertation on incorporating proper dependent types in Haskell [2]. I have yet to have the time to start genuine work on the implementation, but I plan to do so starting summer 2017. Here is a sneak preview of what will be possible with dependent types, although much more is possible, too! data Vec :: * -> Integer -> * ^^ where

Nil :: Vec a 0

(:::) :: a -> Vec a n -> Vec a (1 !+ n)

replicate :: pi n. forall a. a -> Vec a n

replicate ^^ @0 _ = Nil

replicate x = x ::: replicate x



Of course, the design here (especially for the proper dependent types) is preliminary, and input is encouraged.

Further reading

[1]: System FC with Explicit Kind Equality , by Stephanie Weirich, Justin Hsu, and Richard A. Eisenberg. ICFP ’13.

http://www.cis.upenn.edu/~eir/papers/2013/fckinds/fckinds.pdf

, by Stephanie Weirich, Justin Hsu, and Richard A. Eisenberg. ICFP ’13. http://www.cis.upenn.edu/~eir/papers/2013/fckinds/fckinds.pdf [2]: Dependent Types in Haskell: Theory and Practice, by Richard A. Eisenberg. PhD Thesis, 2015.

https://github.com/goldfirere/thesis/tree/master/built

4.1.2 generics-sop Report by: Andres Löh Participants: Andres Löh, Edsko de Vries The generics-sop (“sop” is for “sum of products”) package is a library for datatype-generic programming in Haskell, in the spirit of GHC’s built-in DeriveGeneric construct and the generic-deriving package. Datatypes are represented using a structurally isomorphic representation that can be used to define functions that work automatically for a large class of datatypes (comparisons, traversals, translations, and more). In contrast with the previously existing libraries, generics-sop does not use the full power of current GHC type system extensions to model datatypes as an n-ary sum (choice) between the constructors, and the arguments of each constructor as an n-ary product (sequence, i.e., heterogeneous lists). The library comes with several powerful combinators that work on n-ary sums and products, allowing to define generic functions in a very concise and compositional style. The current release is 0.2.0.0. A new talk from ZuriHack 2016 is available on Youtube. The most interesting upcoming feature is probably type-level metadata, making use of the fact that GHC 8 now offers type-level metadata for the built-in generics. While the feature is in principle implemented, there are still a few open questions about what representation would be most convenient to work with in practice. Help or opinions are welcome! Further reading generics-sop package: https://hackage.haskell.org/package/generics-sop/

package: https://hackage.haskell.org/package/generics-sop/ Tutorial (summer school lecture notes): https://github.com/kosmikus/SSGEP/

ZuriHac 2016 talk: https://www.youtube.com/watch?v=sQxH349HOik

WGP 2014 talk: https://www.youtube.com/watch?v=jzgfM6NFE3Y

Paper: http://www.andres-loeh.de/TrueSumsOfProducts/

The supermonad package provides a unified way to represent different monadic and applicative notions. In other words, it provides a way to use standard and generalized monads and applicative functors (with additional indices or constraints) without having to manually disambiguate which notion is referred to in every context. This allows the reuse of code, such as standard library functions, across all of the notions. To achieve this, the library splits the monad and applicative type classes such that they are general enough to allow instances for all of the generalized notions and then aids constraint checking through a GHC plugin to ensure that everything type checks properly. Due to the plugin the library can only be used with GHC. If you are interested in using the library, we have a few examples of different size in the repository to show how it can be utilized. The generated Haddock documentation also has full coverage and can be seen on the libraries Hackage page. The project had its first release shortly before ICFP and the Haskell Symposium 2016. Since then we have added support for applicative functors in addition to monads. We are working on a comprehensive paper that covers all aspects of the project and its theoretical foundations. The paper is submitted to the Journal of Functional Programming. If you are interested in contributing, found a bug or have a suggestion to improve the project we are happy to hear from you in person, by email or over the projects bug tracker on GitHub. Further reading Hackage:

http://hackage.haskell.org/package/supermonad

http://hackage.haskell.org/package/supermonad Repository:

https://github.com/jbracker/supermonad

https://github.com/jbracker/supermonad Paper:

https://jbracker.de/publications/2016-BrackerNilsson-Supermonads.pdf

https://jbracker.de/publications/2016-BrackerNilsson-Supermonads.pdf Comprehensive JFP Paper:

https://jbracker.de/publications/2017-BrackerNilsson-SupermonadsAndSuperapplicatives-UnderConsideration.pdf

https://jbracker.de/publications/2017-BrackerNilsson-SupermonadsAndSuperapplicatives-UnderConsideration.pdf Bug-Tracker:

https://github.com/jbracker/supermonad/issues

https://github.com/jbracker/supermonad/issues Haskell Symposium presentation:

https://youtu.be/HRofw58sySw

4.1.4 Reifying type families Report by: Gabor Greif Status: experimental, comments welcome The outcome of the compile-time evaluation of type families is currently inscrutable to the running program. tyfam-witnesses is a new minimal library that utilises Template Haskell to obtain the necessary artifacts for running the clauses of closed type families at execution time. By pattern matching on the outcome all the type-level equalities can be recovered. For each closed type family in a series of declarations, witnesses adds a GADT mirroring its clauses, and a reification function that runs it given indexed TypeRep s. Here is a usage example: type family Elim v f where

Elim v (v -> c) = c

Elim v (d -> c) = d -> Elim v c

}

gets accompanied with data ElimRefl v f where

Elim0 :: Elim v (v -> d) ~ d

=> ElimRefl v (v -> d)

Elim1 :: Elim v (c -> d) ~ (c -> Elim a b)

=> ElimRefl v (c -> d)

and a runner (or reifier) reify_Elim :: TypeRep a -> TypeRep b

=> Maybe (ElimRefl a b)

Pattern matching on the result of the latter guides the GHC type checker and allows writing recursive functions that evaluate to an ElimRefl v f , which would otherwise get stuck. The library has been introduced at the Regensburg Haskell Meetup (→6.8) and other conferences in Oct. 2017. You can find it on hackage, grab it with cabal install tyfam-witnesses , be reminded however, that GHC v8.2 is a prerequisite for its usage. I am interested in possible further uses and am waiting for encouragement in resolving the two remaining restrictions. Further reading https://hackage.haskell.org/package/tyfam-witnesses

https://skillsmatter.com/skillscasts/10947-lightning-talk-engage-clutch-shift-gear-rofl

4.2 Build Tools and Related Projects

4.2.2 The Stack build tool Report by: Emanuel Borsboom Status: stable Stack is a modern, cross-platform build tool for Haskell code. It is intended for Haskellers both new and experienced. Stack handles the management of your toolchain (including GHC - the Glasgow Haskell Compiler - and, for Windows users, MSYS), building and registering libraries, building build tool dependencies, and more. While it can use existing tools on your system, Stack has the capacity to be your one-stop shop for all Haskell tooling you need. The primary design point is reproducible builds. If you run stack build today, you should get the same result running stack build tomorrow. There are some cases that can break that rule (changes in your operating system configuration, for example), but, overall, Stack follows this design philosophy closely. To make this a simple process, Stack uses curated package sets called snapshots. Stack has also been designed from the ground up to be user friendly, with an intuitive, discoverable command line interface. Since its first release in June 2015, many people are using it as their primary Haskell build tool, both commercially and as hobbyists. New features and refinements are continually being added, with regular new releases. Binaries and installers/packages are available for common operating systems to make it easy to get started. Download it at http://haskellstack.org/. Further reading http://haskellstack.org/

Stackage began in November 2012 with the mission of making it possible to build stable, vetted sets of packages. The overall goal was to make the Cabal experience better. Five years into the project, a lot of progress has been made and now it includes both Stackage and the Stackage Server. To date, there are over 1900 packages available in Stackage. The official site is https://www.stackage.org. The Stackage project consists of many different components, linked to from the Stackage Github repository https://github.com/fpco/stackage#readme. These include: Stackage Nightly, a daily build of the Stackage package set

LTS Haskell, which provides major-version compatibility for a package set over a longer period of time

Stackage Server, which runs on stackage.org and provides browsable docs, reverse dependencies, and other metadata on packages

Stackage Curator, a tool for running the various builds The Stackage package set has first-class support in the Stack build tool (→4.2.2). There is also support for cabal-install via cabal.config files, e.g. https://www.stackage.org/lts/cabal.config. There are dozens of individual maintainers for packages in Stackage. Overall Stackage curation is handled by the “Stackage curator” team, which consists of Michael Snoyman, Adam Bergmark, Dan Burton, Jens Petersen, Luke Murphy, Chris Dornan, and Mihai Maruseac. Stackage provides a well-tested set of packages for end users to develop on, a rigorous continuous-integration system for the package ecosystem, some basic guidelines to package authors on minimal package compatibility, and even a testing ground for new versions of GHC. Stackage has helped encourage package authors to keep compatibility with a wider range of dependencies as well, benefiting not just Stackage users, but Haskell developers in general. If you’ve written some code that you’re actively maintaining, don’t hesitate to get it in Stackage. You’ll be widening the potential audience of users for your code by getting your package into Stackage, and you’ll get some helpful feedback from the automated builds so that users can more reliably build your code. Since the last HCAR, we have moved Stackage Nightly to GHC 8.4.1, as well as released LTS 10 and 11 based on GHC 8.2.2.

4.2.4 Stackgo Report by: Sibi Prabakaran Status: active A browser plugin (currently supported for Firefox/Google Chrome) to automatically redirect Haddock documentation on Hackage to corresponding Stackage pages, when the request is via search engines like Google/Bing etc. For the case where the package hasn’t been added yet to Stackage, no redirect will be made and the Hackage documentation will be available. This plugin also tries to guess when the user would want to go to a Hackage page instead of the Stackage one and tries to do the right thing there. Further reading https://github.com/psibi/stackgo

https://addons.mozilla.org/en-US/firefox/addon/stackgo

https://chrome.google.com/webstore/detail/ojjalokgookadeklnffglgbnlbaiackn

4.2.5 pier Report by: Judah Jacobson Status: experimental Pier is a command-line tool for building Haskell projects. It is similar in purpose to Stack (→4.2.2); it uses *.cabal files to configure individual packages, a top-level YAML file to configure the whole project, and Stackage (→4.2.3) to get consistent sets of package dependencies. However, Pier attempts to address some of Stack’s limitations by exploring a different approach: Pier invokes tools such as ghc directly, implementing the fine-grained Haskell build logic from (nearly) scratch. In contrast, Stack relies on a separate framework to implement most of its build steps (i.e., Cabal-the-library’s Distribution.Simple ), giving it a more coarse control over the build.

directly, implementing the fine-grained Haskell build logic from (nearly) scratch. In contrast, Stack relies on a separate framework to implement most of its build steps (i.e., Cabal-the-library’s ), giving it a more coarse control over the build. Pier layers its Haskell-specific logic on top of a general-purpose library for hermetic, parallel builds and dependency tracking. That library is itself implemented using Shake, and motivated by tools such as Nix and Bazel. In contrast, Stack’s build and dependency logic is more specific to Haskell projects. Interestingly, Stack originally did depend on Shake, but stopped using it early on. For more information, see write-ups by authors of Stack and Shake.) Pier is still experimental, but is already able to build most the packages in Stackage (specifically, 90%of the more than 2600 packages in lts-10.3) as well as itself (i.e., pier build pier ). Notably, packages with custom Setup scripts are not yet supported. Future plans include: adding more commands such as pier repl ; improving the usability around the output file store (for example, garbage collection); and exposing the internal library that Pier uses for hermetic build steps and immutable outputs. Further reading https://github.com/judah/pier

https://hackage.haskell.org/package/pier

4.2.6 Packcheck: Universal CI testing for Haskell packages Report by: Harendra Kumar Status: Working packcheck uniformly, consistently builds and comprehensively sanity tests a Haskell package across build tools (stack/cabal) and across all platforms (Linux/MacOS/Windows). You do not need to be familiar with any of the build tools to use it. packcheck provides a universal CI/build script packcheck.sh and config files designed such that you can just copy over the .travis.yml and appveyor.yml files provided with packcheck to your package repository and your package is CI ready. You can replicate the same testing on your local machine, just copy packcheck.sh to your local machine, put it in your PATH, and run it from your package directory: $ packcheck.sh stack

$ packcheck.sh cabal

$ packcheck.sh cabal-new

Further reading https://github.com/harendra-kumar/packcheck

https://hackage.haskell.org/package/packcheck

4.2.7 hsinstall Report by: Dino Morelli Status: stable, actively developed This is a utility to install Haskell programs on a system using stack. Although stack does have an install command, it only copies binaries. Sometimes more is needed, other files and some directory structure. hsinstall tries to install the binaries, the LICENSE file and also the resources directory if it finds one. Installations can be performed in one of two directory structures. FHS, or the Filesystem Hierarchy Standard (most UNIX-like systems) and what I call “bundle” which is a portable directory for the app and all of its files. They look like this: bundle is sort-of a self-contained structure like this: $PREFIX/

$PROJECT-$VERSION/

bin/...

doc/LICENSE

resources/...



fhs is the more traditional UNIX structure like this: $PREFIX/

bin/...

share/

$PROJECT-$VERSION/

doc/LICENSE

resources/...

There are two parts to hsinstall that are intended to work together. The first part is a Haskell shell script, util/install.hs . Take a copy of this script and check it into a project you’re working on. This will be your installation script. Running the script with the –help switch will explain the options. Near the top of the script are default values for these options that should be tuned to what your project needs. The other part of hsinstall is a library. The install script will try to install a resources directory if it finds one. the HSInstall library can then be used in your code to locate the resources at runtime. Note that you only need the library if your software has data files it needs to locate at runtime in the installation directories. Many programs don’t have this requirement and can ignore the library altogether. Source code is available on darcshub, Hackage and Stackage Further reading hsinstall on darcshub http://hub.darcs.net/dino/hsinstall

hsinstall on Hackage https://hackage.haskell.org/package/hsinstall

hsinstall on Stackage https://www.stackage.org/package/hsinstall

4.2.8 yesod-rest Report by: Sibi Prabakaran Status: active A Yesod scaffolding site with Postgres backend. It provides a JSON API backend as a separate subsite. The primary purpose of this repository is to use Yesod as a API server backend and do the frontend development using a tool like React or Angular. The current code includes a basic example using React and Babel which is bundled finally by webpack and added in the handler getHomeR in a type safe manner. The future work is to make it compatible with yesod-1.6 and then integrate it as part of yesod-scaffold and make it as part of stack template . Further reading https://github.com/psibi/yesod-rest

https://github.com/yesodweb/yesod-scaffold/issues/136

4.2.9 Haskell Cloud Report by: Gideon Sireling Haskell Cloud is a Source-to-Image builder for building Haskell source into a runnable Docker image. It can be used directly with s2i, or deployed on OpenShift. Using the Haskell Cloud builder, existing Haskell projects can be uploaded, built, and run from the cloud with minimal changes. A choice of pre-installed frameworks is available - see the Wiki for details. Further reading https://bitbucket.org/accursoft/haskell-cloud

4.3 Repository Management

Darcs is a distributed revision control system written in Haskell. In Darcs, every copy of your source code is a full repository, which allows for full operation in a disconnected environment, and also allows anyone with read access to a Darcs repository to easily create their own branch and modify it with the full power of Darcs’ revision control. Darcs is based on an underlying theory of patches, which allows for safe reordering and merging of patches even in complex scenarios. For all its power, Darcs remains a very easy to use tool for every day use because it follows the principle of keeping simple things simple. Darcs 2.14.0 was released on April 2018. It features a better support of non-ASCII encodings by default, an improved display of patch dependencies, per-file conflict marking, a more efficient annotate command, and better shell completion. SFC and donationsDarcs is free software licensed under the GNU GPL (version 2 or greater). Darcs is a proud member of the Software Freedom Conservancy, a US tax-exempt 501(c)(3) organization. We accept donations at http://darcs.net/donations.html. Further reading http://darcs.net

http://darcs.net/Releases/2.14

http://hub.darcs.net

4.3.2 git-annex Report by: Joey Hess Status: stable, actively developed git-annex allows managing files with git, without checking the file contents into git. While that may seem paradoxical, it is useful when dealing with files larger than git can currently easily handle, whether due to limitations in memory, time, or disk space. As well as integrating with the git command-line tools, git-annex includes a graphical app which can be used to keep a folder synchronized between computers. This is implemented as a local webapp using yesod and warp. git-annex runs on Linux, OSX and other Unixes, and has been ported to Windows. There is also an incomplete but somewhat usable port to Android. Five years into its development, git-annex has a wide user community. It is being used by organizations for purposes as varied as keeping remote Brazilian communities in touch and managing Neurological imaging data. It is available in a number of Linux distributions, in OSX Homebrew, and is one of the most downloaded utilities on Hackage. It was my first Haskell program. At this point, my goals for git-annex are to continue to improve its foundations, while at the same time keeping up with the constant flood of suggestions from its user community, which range from adding support for storing files on more cloud storage platforms (around 20 are already supported), to improving its usability for new and non technically inclined users, to scaling better to support Big Data, to improving its support for creating metadata driven views of files in a git repository. At some point I’d also like to split off any one of a half-dozen general-purpose Haskell libraries that have grown up inside the git-annex source tree. Further reading http://git-annex.branchable.com/

4.4 Debugging and Profiling

Hoed is a tracer and debugger for the programming language Haskell. To locate a defect with Hoed you annotate suspected functions and compile as usual. Then you run your program, information about the annotated functions is collected. Finally you connect to a debugging session using a console. With Hoed you can list and search observed functions applied to argument values and the result values. Hoed also provides algorithmic debugging. An algorithmic debugger finds defects in programs by systematic search. The programmer directs the search by answering a series of yes/no questions about the correctness of specific function applications and their results. Hoed also allows the use of (QuickCheck-style) properties to answer automatically some of the questions arising during algorithmic debugging, and to replace others by simpler questions. 4.4.1.1 Using Hoed Let us consider the following program, a defective implementation of a parity function with a test property. isOdd :: Int -> Bool

isOdd n = isEven (plusOne n)

isEven :: Int -> Bool

isEven n = mod2 n == 0

plusOne :: Int -> Int

plusOne n = n + 1

mod2 :: Int -> Int

mod2 n = div n 2

prop_isOdd :: Int -> Bool

prop_isOdd x = isOdd (2*x+1)

main :: IO ()

main = printO (prop_isOdd 1)

main :: IO ()

main = quickcheck prop_isOdd

Using the property-based test tool QuickCheck we find the counter example 1 for our property. ./MyProgram

*** Failed! Falsifiable (after 1 test): 1

Hoed can help us determine which function is defective. We annotate the functions |isOdd|, |isEven|, |plusOne| and |mod2| as follows: import Debug.Hoed.Pure

isOdd :: Int -> Bool

isOdd = observe "isOdd" isOdd'

isOdd' n = isEven (plusOne n)

isEven :: Int -> Bool

isEven = observe "isEven" isEven'

isEven' n = mod2 n == 0

plusOne :: Int -> Int

plusOne = observe "plusOne" plusOne'

plusOne' n = n + 1

mod2 :: Int -> Int

mod2 = observe "mod2" mod2'

mod2' n = div n 2

prop_isOdd :: Int -> Bool

prop_isOdd x = isOdd (2*x+1)

main :: IO ()

main = printO (prop_isOdd 1)

After running the program a computation tree is constructed and the algorithmic debugger is launched in the console. False

=== program terminated ===

Please wait while the computation tree

is constructed...

=== Debug Session ===

hdb> adb

==================================== [0-0/4]

isOdd 3 = False

?

right Judge computation statements right

according to the intended

behaviour/specification

of the function.

wrong Judge computation statements wrong

according to the intended

behaviour/specification

of the function.

==================================== [0-0/4]

isOdd 3 = False

? wrong

==================================== [1-0/4]

isEven 4 = False

? wrong

==================================== [2-0/4]

mod2 4 = 2

? wrong

==================================== [3-0/4]

Fault located! In:

mod2 4 = 2

hdb>

After running the program a computation tree is constructed and the algorithmic debugger is launched in the console. To reduce the number of questions the programmer has to answer, we added a new mode Assisted Algorithmic Debugging. In this mode (QuickCheck) properties already present in program code for property-based testing can be used to automatically judge computation statements Further reading http://wiki.haskell.org/Hoed

http://hackage.haskell.org/package/Hoed

4.4.2 ghc-vis Report by: Joachim Breitner Status: active development The tool ghc-vis visualizes live Haskell data structures in GHCi. Since it does not force the evaluation of the values under inspection it is possible to see Haskell’s lazy evaluation and sharing in action while you interact with the data. Ghc-vis supports two styles: A linear rendering similar to GHCi’s :print , and a graph-based view where closures in memory are nodes and pointers between them are edges. In the following GHCi session a partially evaluated list of fibonacci numbers is visualized: > let f = 0 : 1 : zipWith (+) f (tail f)

> f !! 2

> :view f

At this point the visualization can be used interactively: To evaluate a thunk, simply click on it and immediately see the effects. You can even evaluate thunks which are normally not reachable by regular Haskell code. Ghc-vis can also be used as a library and in combination with GHCi’s debugger. Further reading http://felsin9.de/nnis/ghc-vis

The library ghc-heap-view provides means to inspect the GHC’s heap and analyze the actual layout of Haskell objects in memory. This allows you to investigate memory consumption, sharing and lazy evaluation. This means that the actual layout of Haskell objects in memory can be analyzed. You can investigate sharing as well as lazy evaluation using ghc-heap-view. The package also provides the GHCi command :printHeap , which is similar to the debuggers’ :print command but is able to show more closures and their sharing behaviour: > let x = cycle [True, False]

> :printHeap x

_bco

> head x

True

> :printHeap x

let x1 = True : _thunk x1 [False]

in x1

> take 3 x

[True,False,True]

> :printHeap x

let x1 = True : False : x1

in x1

The graphical tool ghc-vis (→4.4.2) builds on ghc-heap-view. Since version 0.5.10, ghc-heap-view supports GHC 8.2. There is ongoing work that might merge this functionality into GHC proper. Further reading http://www.joachim-breitner.de/blog/archives/548-ghc-heap-view-Complete-referential-opacity.html

http://www.joachim-breitner.de/blog/archives/580-GHCi-integration-for-GHC.HeapView.html

http://www.joachim-breitner.de/blog/archives/590-Evaluation-State-Assertions-in-Haskell.html

https://phabricator.haskell.org/D3055 Ongoing work to merge ghc-heap-view into GHC.

4.4.4 Hat — the Haskell Tracer Report by: Olaf Chitil Hat is a source-level tracer for Haskell. Hat gives access to detailed, otherwise invisible information about a computation. Hat helps locating errors in programs. Furthermore, it is useful for understanding how a (correct) program works, especially for teaching and program maintenance. Hat is not a time or space profiler. Hat can be used for programs that terminate normally, that terminate with an error message or that terminate when interrupted by the programmer. You trace a program with Hat by following these steps: With hat-trans translate all the source modules of your Haskell program into tracing versions. Compile and link (including the Hat library) these tracing versions with ghc as normal. Run the program. It does exactly the same as the original program except for additionally writing a trace to file. After the program has terminated, view the trace with a tool. Hat comes with several tools for selectively viewing fragments of the trace in different ways: hat-observe for Hood-like observations, hat-trail for exploring a computation backwards, hat-explore for freely stepping through a computation, hat-detect for algorithmic debugging, … Hat is distributed as a package on Hackage that contains all Hat tools and tracing versions of standard libraries. Hat 2.9.4 works with recent versions of the Glasgow Haskell compiler for Haskell programs that are written in Haskell 98 plus a few language extensions such as multi-parameter type classes and functional dependencies. Although Hat is distributed as a cabal package that can be installed with stack, it currently does not support working with stack projects; instead it provides an old-fashioned build tool hat-make. Note that all modules of a traced program have to be transformed, including trusted libraries (transformed in trusted mode). For portability all viewing tools have a textual interface; however, many tools require an ANSI terminal and thus run on Unix / Linux / OS X, but not on Windows. In the longer term we intend to transfer the lightweight tracing technology that we use in Hoed (→4.4.1) also to Hat. Further reading Initial website: http://projects.haskell.org/hat

Hackage package: http://hackage.haskell.org/package/hat

4.5 Testing

4.5.1 inspection-testing Report by: Joachim Breitner Status: working Carefully crafted Haskell libraries are often set up to trigger a specific cascade of optimization. Stream fusion as found in the text and vector libraries is a good example, as are generic programming libraries like generic-lens . The inspection-testing library allows developers to assert that certian transformations indeed happen at compile time, and check these assertions automatically. For example, the following test file ensures that GHC’s optimizer removes the call to fmap in lhs : {-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -O -fplugin

Test.Inspection.Plugin #-}

import Test.Inspection

import Data.Maybe

lhs, rhs :: (a -> b) -> Maybe a -> Bool

lhs f x = isNothing (fmap f x)

rhs f Nothing = True

rhs f (Just _) = False

inspect $ 'lhs === 'rhs

Further reading https://github.com/nomeata/inspection-testing

https://arxiv.org/abs/1803.07130 paper introducing inspection-testing

LeanCheck is an enumerative property-based testing library with a very small core of only 180 lines of code. Its enumeration is size-bounded so the number of tests is easier to control than with SmallCheck. It is used like so: > import Test.LeanCheck

> check $ \x y -> x + y == y + (x :: Int)

+++ OK, passed 200 tests.

> check $ \x y -> x - y == y - (x :: Int)

*** Failed! Falsifiable (after 2 tests):

0 1

LeanCheck has support for higher-order properties (those taking functions as arguments). For example: > check $ \f p xs -> map f (filter p xs)

> == filter p (map f xs

> :: [Bool])

*** Failed! Falsifiable (after 20 tests):

\x -> case x of False -> False; True -> False

\x -> case x of False -> False; True -> True

[True]

The function filter does not commute with map . The functiondoes not commute with LeanCheck works on properties whose argument types are instances of the Listable typeclass. It is very easy to define Listable instances for user-defined types. For example, take “Hutton’s Razor”: data Expr = Val Int | Add Expr Expr

deriving (Show, Eq)

Its Listable instance can be given by instance Listable Expr where

tiers = cons1 Val \/ cons2 Add

or automatically derived using Template Haskell by deriveListable ''Expr

Itsinstance can be given byor automatically derived using Template Haskell by LeanCheck is available on Hackage under a BSD3-style license. All you need to do to get it is: $ cabal install leancheck

The latest version (v0.7.0) includes functions to compute statistics of Listable instances. Further reading https://hackage.haskell.org/package/leancheck

https://github.com/rudymatela/leancheck

Chapter 3 of Rudy Braquehais’ 2017 PhD Thesis:

https://matela.com.br/paper/rudy-phd-thesis.pdf

Extrapolate is a property-based testing library capable of reporting generalized counter-examples to properties. Extrapolate works on top of LeanCheck (→4.5.2). Here is an example: > import Test.Extrapolate

> import Data.List (nub)

> check $ \xs -> nub xs == (xs :: [Int])

*** Failed! Falsifiable (after 3 tests):

[0,0]

Generalization:

x:x:_

Conditional Generalization:

x:xs when elem x xs

The above property about nub not only fails for the list [0,0] but also for any list that has repeated elements. The generalization of failing cases informs the programmer more fully and more immediately what characterizes failures. This information helps the programmer to locate more confidently and more rapidly the causes of failure in their program. Extrapolate’s generalization of counter-examples is similar to SmartCheck’s. However, when generalizing, Extrapolate allows for repeated variables and side-conditions. Extrapolate is available on Hackage under a BSD3-style license. All you need to do to get it is: $ cabal install extrapolate

The latest version (v0.3.1) uses Speculate (→4.5.4) to avoid testing equivalent conditions improving results and performance. Further reading https://hackage.haskell.org/package/extrapolate

https://github.com/rudymatela/extrapolate

IFL 2017 paper about Extrapolate: https://matela.com.br/paper/extrapolate.pdf

Chapter 6 of Rudy Braquehais’ 2017 PhD Thesis: https://matela.com.br/paper/rudy-phd-thesis.pdf

Speculate is a library that uses testing to automatically discover and conjecture properties about Haskell functions. Those properties can contribute to understanding, documentation, validation, design refinement and regression testing. The following example shows how to use Speculate to discover properties about addition and multiplication: > import Test.Speculate

> speculate args

> { constants = [ constant "+" (+)

> , constant "*" (*) ] }

x + y == y + x

x * y == y * x

(x + y) + z == x + (y + z)

(x * y) * z == x * (y * z)

(x + x) * y == x * (y + y)

x <= x * x

Speculate can even discover properties about higher-order functions. For example, it discovers the following properties about map , id and (.) (cf. eg/fun.hs ): id x == x

f (g x) == (f . g) x

map id xs == xs

map (f . g) xs == map f (map g xs)

f . id == f

id . f == f

(f . g) . h == f . (g . h)

Speculate is similar to QuickSpec, but uses a different algorithm to produce inequalities and conditional equations. See the documentation for further details and examples. The latest version (v0.3.2) includes significant performance improvements. It also includes improvements in documentation, examples and API. Speculate is available on Hackage under a BSD3-style license. All you need to do to get it is: $ cabal install speculate

Further reading https://hackage.haskell.org/package/speculate

https://github.com/rudymatela/speculate

The Haskell Symposium 2017 paper about Speculate: https://matela.com.br/paper/speculate.pdf

Chapter 5 of Rudy Braquehais’ 2017 PhD Thesis: https://matela.com.br/paper/rudy-phd-thesis.pdf

4.5.5 TorXakis Report by: Damian Nadales Status: active development More often than not, testing software consumes a large portion of the development budget, however we frequently see cases where unit and integration tests fail to uncover critical errors that appear once the software is deployed. Most testing techniques revolve around specifying a collection of execution sequences that check the expected against the actual behavior. A problem with this is that the number of possible execution sequences is huge, and therefore only a very small portion of these would be covered by test cases that are specified as a sequence of steps. The second problem is that, with the goal of increasing coverage and prevent regression bugs a large number of test cases is written, which eats up the development budget. Model-based testing is a technique for writing tests, where a model of the system behavior is made a a high-level of abstraction, and then the system-under test is tested against this the expected behavior as specified by the model. Model-based testing relies on different algorithms for generating test cases from models, which allows to achieve a much higher test coverage than standard testing techniques, while requiring only a fraction of the code. TorXakis is such a model-based testing tool, that has been used to verify large scale systems in well-know high tech companies. This tool is entirely written in Haskell, and its code is available on Github under a BSD3 license. Since July last year, a lot of effort was put into taking TorXakis from a prototype to an industrial grade tool. Some of the improvements made include: setup of continuous integration (Windows/Linux), including hlint quality metrics via code climate.

release of macOS and Windows installers.

addition of integration tests and benchmarks.

improvements in performance.

architectural simplifications. In addition, there is ongoing work in a new command line interface and a new compiler for the TorXakis language. A year is almost gone, and there are a lot of interesting challenges ahead to make TorXakis a tool that can be used in production, so we welcome the contributions of anybody interested in the topic. Further reading https://github.com/TorXakis/TorXakis/

4.6 Development Tools and Editors

4.6.1 Haskell for Mac Report by: Manuel M. T. Chakravarty Status: Available &actively developed Haskell for Mac is an easy-to-use, innovative programming environment and learning platform for Haskell on OS X. It includes its own Haskell distribution and requires no further set up. It features interactive Haskell playgrounds to explore and experiment with code. Playground code is not only type-checked, but also executed while you type, which leads to a fast turn around during debugging or experimenting with new code. Integrated environment. Haskell for Mac integrates everything needed to start writing Haskell code, including an editor with syntax highlighting and smart identifier completion. Haskell for Mac creates Haskell projects based on standard Cabal specifications for compatibility with the rest of the Haskell ecosystem. It includes the Glasgow Haskell Compiler (GHC) and over 200 of the most popular packages of LTS Haskell package sets. Matching command line tools and extra packages can be installed, too. Type directed development. Haskell for Mac uses GHC’s support for deferred type errors so that you can still execute playground code in the face of type errors. This is convenient during refactoring to test changes, while some code still hasn’t been adapted to new signatures. Moreover, you can use type holes to stub out missing pieces of code, while still being able to run code. The system will also report the types expected for holes and the types of the available bindings. Interactive HTML, graphics &games. Haskell for Mac comes with support for web programming, network programming, graphics programming, animations, and much more. Interactively generate web pages, charts, animations, or even games (with the OS X SpriteKit support). Graphics are also live and change as you modify the program code. The screenshot below is from the development of a Flappy Bird clone in Haskell. Watch the Haskell for Mac developer live code Flappy Bird in Haskell in 20min at the end of the Compose :: Melbourne 2016 keynote at https://speakerdeck.com/mchakravarty/playing-with-graphics-and-animations-in-haskell. You can find more information about writing games in Haskell in this blog post: http://blog.haskellformac.com/blog/writing-games-in-haskell-with-spritekit. Haskell for Mac has recently gained auto-completion of identifiers, taking into account the current module’s imports. It now also features a graphical package installer for LTS Haskell and support for GHC 8. Moreover, a new type class, @Presentable@, enables custom rendering of user-defined data types using images, HTML, and even animations. Haskell for Mac is available for purchase from the Mac App Store. Just search for "Haskell", or visit our website for a direct link. We are always available for questions or feedback at support@haskellformac.com. Further reading The Haskell for Mac website: http://haskellformac.com

4.6.2 haskell-ide-engine, a project for unifying IDE functionality Report by: Chris Allen Participants: Alan Zimmerman, Moritz Kiefer, Michael Sloan, Gracjan Polak, Daniel Gröber, others welcome Status: Open source, just beginning haskell-ide-engine is a backend for driving the sort of features programmers expect out of IDE environments. haskell-ide-engine is a project to unify tooling efforts into something different text editors, and indeed IDEs as well, could use to avoid duplication of effort. There is basic support for getting type information and refactoring, more features including type errors, linting and reformatting are planned. People who are familiar with a particular part of the chain can focus their efforts there, knowing that the other parts will be handled by other components of the backend. Integration for Emacs and Leksah is available and should support the current features of the backend. Work has started on a Language Server Protocol transport, for use in VS Code. haskell-ide-engine also has a REST API with Swagger UI. Inspiration is being taken from the work the Idris community has done toward an interactive editing environment as well. Help is very much needed and wanted so if this is a problem that interests you, please pitch in! This is not a project just for a small inner circle. Anyone who wants to will be added to the project on github, address your request to @alanz. Further reading https://github.com/haskell/haskell-ide-engine

https://github.com/Microsoft/language-server-protocol

https://mail.haskell.org/pipermail/haskell-cafe/2015-October/121875.html

https://www.fpcomplete.com/blog/2015/10/new-haskell-ide-repo

https://www.reddit.com/r/haskell/comments/3pt560/ann_haskellide_project/

https://www.reddit.com/r/haskell/comments/3qbgmo/fp_complete_the_new_haskellide_repo/

4.6.3 HyperHaskell – The strongly hyped Haskell interpreter Report by: Heinrich Apfelmus Status: available, active development HyperHaskell is a graphical Haskell interpreter, not unlike GHCi, but hopefully more awesome. You use worksheets to enter expressions and evaluate them. Results are displayed graphically using HTML. HyperHaskell is intended to be easy to install. It is cross-platform and should run on Linux, Mac and Windows. Internally, it uses the GHC API to interpret Haskell programs, and the graphical front-end is built on the Electron framework. HyperHaskell is open source. HyperHaskell’s main attraction is a Display class that supersedes the good old Show class. The result looks like this: Status HyperHaskell is currently Level alpha. The latest stable release is 0.1.0.2 . Compared to the previous report, no new release has been made, but basic features are working. It is now possible to interpret statements in the IO monad and to bind variables, greatly enhancing the usefulness of the interpreter. Support for the Nix package manager has been implemented by Rodney Lorrimar. I am looking for help in setting up binary releases on the Windows platform! Future development Programming a computer usually involves writing a program text in a particular language, a “verbal” activity. But computers can also be instructed by gestures, say, a mouse click, which is a “nonverbal” activity. The long term goal of HyperHaskell is to blur the lines between programming “verbally” and “nonverbally” in Haskell. This begins with an interpreter that has graphical representations for values, but also includes editing a program text while it’s running (“live coding”) and interactive representations of values (e.g. “tangible values”). This territory is still largely uncharted from a purely functional perspective, probably due to a lack of easily installed graphical facilities. It is my hope that HyperHaskell may provide a common ground for exploration and experimentation in this direction, in particular by offering the Display class which may, perhaps one day, replace our good old Show class. A simple form of live coding is planned for Level beta, and I am experimenting with interactive music programming. Further reading Project homepage and downloads: https://github.com/HeinrichApfelmus/hyper-haskell

4.6.4 CodeWorld Report by: Chris Smith Status: actively used CodeWorld is a web-based educational programming environment using Haskell, and appropriate for all ages. It provides a simple mathematical model for geometric figures, animations, and interactive and multi-player games. The language scales between a graphical block-based language for primary students, a simplified variant of Haskell, and the full-fledged Haskell language for older students and universities. In addition to the tools, CodeWorld also provides learning resources for teachers and independent learners. CodeWorld is actively used for Haskell programming classes and activities, by universities, primary and secondary schools, and non-profit organizations and programs. Features A cloud-based programming environment available from anywhere, to write and run code directly in the browser.

A full-featured Haskell editor with syntax highlighting, rainbow brackets, formatting, and auto-complete.

A simple graphics model for composable geometry and animations.

Integrated debugging tools that intelligently link program output to the lines of code responsible.

The world’s simplest framework for single and multi-player (networked) games. Recent changes In the summer of 2017, CodeWorld hosted four students through the Summer of Haskell program to work on improving debugging tools, error messages, collaborative coding experiences, and exporting projects to video and mobile applications. Some contributions are still being merged. Other recent changes include the addition of a model for simple multi-player networked games and QuickCheck support for the full Haskell mode. Simultaneously, we’ve been busy developing a packaged curriculum for early secondary students, ages 11-14, using functional programming as a framework for creative mathematics. Availability CodeWorld is freely available. The hosted web site at http://code.world is open to the public. Source code for the project is available under the Apache license. Teaching materials and resources are released as they are completed under a Creative Commons license. Further reading https://github.com/google/codeworld

4.6.5 Haskell Indexer Report by: Ivan Kristo Participants: Robin Palotai, Kristoffer Søholm Status: stable, actively developed Haskell Indexer is a Kythe extension for working with Haskell source code. Kythe is language-agnostic ecosystem for building tools that work with code. An example is code search with cross-reference support: https://cs.chromium.org/. Haskell Indexer makes it possible to use Kythe-based tools with Haskell. With Haskell Indexer it’s possible to list all use-sites of any given function (get reverse-references) and explore the code without any IDE setup. A portion of GHC and Stackage is indexed and available at http://stuff.codereview.me/. Haskell Indexer is in active use and development. As of today, it’s possible to get it from GitHub – the Hackage release is work in progress. The future plans include improving the cross-reference support, adding cross-language linking with C and better handling of Template Haskell. Further reading https://github.com/google/haskell-indexer

https://kythe.io/

Brittany is a Haskell source code formatting tool that tries to produce consistent, neat, and concise layouting while preserving comments and user-provided formatting (e.g. newlines). In particular brittany.. is highly configurable (powerful, alas sparsely documented);

retains newlines and comments unmodified (to the degree possible when code around them gets reformatted);

makes clever use of horizontal space without overflowing the column limit (80 or whatever);

supports horizontal alignment (e.g. different equations/pattern matches in the some function’s definition). The project is not finished in two important aspects: Brittany does not know how to format data, class, or instance declarations yet. So it currently only affects a) the module header (exports/imports) b) type signatures c) (function) equations.

Not all extensions are supported yet. E.g. TemplateHaskell/Quasiquoters are not fully supported, plus some other extensions. Brittany is based on ghc-exactprint and the ghc parser. It requires ghc-8.*, and is available on Hackage and on Stackage. The project welcomes contribution for any desired, yet missing features. The design/implementation of this project has been captured in several documents you can find in the project’s repository. Further reading https://github.com/lspitzner/brittany

4.6.7 IHaskell Report by: Vaibhav Sagar Status: available, actively maintained IHaskell is a Haskell kernel for the Jupyter project, and it is usable through various Jupyter frontends, such as the console and the notebook. It is an interactive shell similar to GHCi, and it provides features such as syntax highlighting, autocompletion, multi-line input cells, integrated documentation, rich output visualisation, and more. It integrates with HLint to provide style and formatting suggestions, and notebooks can be exported as Literate Haskell or Markdown. An example IHaskell notebook looks like this: IHaskell currently supports GHC 8.0, 8.2, and 8.4, and older releases have support back to GHC 7.6. It can be installed on Linux and macOS. Windows is currently not supported. Installation via Cabal, Stack, and Nix is supported, and the recently announced mybinder.org can also be used to host IHaskell notebooks. Further reading IHaskell is open source, and the project homepage is at https://github.com/gibiansky/IHaskell.

4.6.8 Doc Browser Report by: Wanqiang Jiang Status: under development Doc Browser is an API documentation browser written in Haskell and QML. It is a native desktop app, with offline supports for Hoogle, DevDocs’ docset and Dash’s docset. It is under development, but the GUI is suitable for daily use. Further reading https://github.com/qwfy/doc-browser#readme

4.7 Formal Systems and Reasoners

4.7.1 The Incredible Proof Machine Report by: Joachim Breitner Status: active development The Incredible Proof Machine is a visual interactive theorem prover: Create proofs of theorems in propositional, predicate or other, custom defined logics simply by placing blocks on a canvas and connecting them. You can think of it as Simulink mangled by the Curry-Howard isomorphism. It is also an addictive and puzzling game, I have been told. The Incredible Proof Machine runs completely in your browser. While the UI is (unfortunately) boring standard JavaScript code with a spaghetti flavor, all the logical heavy lifting is done with Haskell, and compiled using GHCJS. Further reading http://incredible.nomeata.de The Incredible Proof Machine

https://github.com/nomeata/incredible Source Code

http://www.joachim-breitner.de/blog/682-The_Incredible_Proof_Machine Announcement blog post

4.7.2 Exference Report by: Lennart Spitzner Status: experimental Exference is a tool aimed at supporting developers writing Haskell code by generating expressions from a type, e.g. Input: (Show b) => (a -> b) -> [a] -> [String]

Output: \ f1 -> fmap (show . f1)

Input: (Monad m, Monad n)

=> ([a] -> b -> c) -> m [n a] -> m (n b)

-> m (n c)

Output: \ f1 -> liftA2 (\ hs i ->

liftA2 (\ n os -> f1 os n) i (sequenceA hs))

Output:Input:Output: The algorithm does a proof search specialized to the Haskell type system. In contrast to Djinn, the well known tool with the same general purpose, Exference supports a larger subset of the Haskell type system - most prominently type classes. The cost of this feature is that Exference makes no promise regarding termination (because the problem becomes an undecidable one; a draft of a proof can be found in the pdf below). Of course the implementation applies a time-out. There are two primary use-cases for Exference: In combination with typed holes: The programmer can insert typed holes into the source code, retrieve the expected type from ghc and forward this type to Exference. If a solution, i.e. an expression, is found and if it has the right semantics, it can be used to fill the typed hole.

As a type-class-aware search engine. For example, Exference is able to answer queries such as |Int -> Float|, where the common search engines like hoogle or hayoo are not of much use. The current implementation is functional and works well. The most important aspect that still could use improvement is the performance, but it would probably take a slightly improved approach for the core algorithm (and thus a major rewrite of this project) to make significant gains. The project is actively maintained; apart from occasional bug-fixing and general maintenance/refactoring there are no major new features planned currently. Try it out by on IRC(freenode): exferenceBot is in #haskell and #exference. Further reading https://github.com/lspitzner/exference

https://github.com/lspitzner/exference/raw/master/exference.pdf

4.8 Education

4.8.1 Holmes, Plagiarism Detection for Haskell Report by: Jurriaan Hage Participants: Brian Vermeer, Gerben Verburg Holmes is a tool for detecting plagiarism in Haskell programs. A prototype implementation was made by Brian Vermeer under supervision of Jurriaan Hage, in order to determine which heuristics work well. This implementation could deal only with Helium programs. We found that a token stream based comparison and Moss style fingerprinting work well enough, if you remove template code and dead code before the comparison. Since we compute the control flow graphs anyway, we decided to also keep some form of similarity checking of control-flow graphs (particularly, to be able to deal with certain refactorings). In November 2010, Gerben Verburg started to reimplement Holmes keeping only the heuristics we figured were useful, basing that implementation on haskell-src-exts . A large scale empirical validation has been made, and the results are good. We have found quite a bit of plagiarism in a collection of about 2200 submissions, including a substantial number in which refactoring was used to mask the plagiarism. A paper has been written, which has been presented at CSERC’13, and should become available in the ACM Digital Library. The tool will be made available through Hackage at some point, but before that happens it can already be obtained on request from Jurriaan Hage. Contact <J.Hage at uu.nl>

4.8.3 Basic Haskell Cheat Sheet Report by: Rudy Braquehais Status: Actively maintained, v1.1 The Basic Haskell Cheat Sheet is a reference sheet with reminders of the most common Haskell features and functions condensed in two pages. It covers a subset of the standard prelude, including examples of: declarations &expressions;

operators &functions;

list comprehensions;

GHC invocation &GHCi commands. It does not aim to teach readers how to use the language, but simply remind readers of syntax, functions or caveats. It can be useful both to newcomers and oldtimers of the Haskell language. Contributions are welcome, just submit a “pull request” on GitHub. Note the hard limit of two pages: to add something, something else should be removed. Further reading Current version (v1.1): https://github.com/rudymatela/concise-cheat-sheets/releases/download/haskell-v1.1/haskell-cs-1.1.pdf

Future versions will be posted on: https://github.com/rudymatela/concise-cheat-sheets

“Domain Specific Languages of Mathematics” is a project at Chalmers and UGOT which lead to a new BSc level course of the same name, including accompanying material for learning and applying classical mathematics (mainly basics of real and complex analysis). The main idea is to encourage the students to approach mathematical domains from a functional programming perspective: to identify the main functions and types involved and, when necessary, to introduce new abstractions; to give calculational proofs; to pay attention to the syntax of the mathematical expressions; and, finally, to organize the resulting functions and types in domain-specific languages. The third instance of the course was carried out Jan–March 2018 in Gothenburg and the course material is available on github. The lecture notes have been collected in an informal “book” during the last six months; contributions and ideas are welcome! Just two example to give a feeling for the contents: Given the definition of “ h : A -> is a homomorphism from Op : A->A->A to op : B->B->B ”:



H2(h, Op, op) = ∀ x. ∀ y. h (Op x y) == op (h x) (h y)



Then H2(exp,(+),(·)) says that ex+y == ex·ey for all x and y. A somewhat longer example (two tweets):



import Prelude hiding (exp,sin,cos)

z=zipWith

c∫f = c:z (/) f [1..]

exp = 1∫exp

sin = 0∫cos

cos = 1∫(-sin)

instance Num a => Num [a] where

(+) = z (+)

(-) = z (-)

(*) = m

fromInteger i = fromInteger i : repeat 0

m (x:xs) q@(y:ys) = x*y : (map (x*) ys) + xs*q

one = 1 :: [Rational]

test = (sin^2+cos^2) =~ one

d cs = zipWith (*) [1..] (tail cs)

xs =~ ys = and (take 10 (z (==) xs ys))

test2 = exp =~ d exp





See also the HCAR entry “Learn you a Physics” (→4.8.5) by a group of BSc students.

Further reading

4.8.5 Learn You A Physics Report by: Erik Sjöström Participants: Oskar Lundström, Johan Johansson, Björn Werner Status: active development Learn You A Physics is the result of a BSc project at Chalmers (supervised by P. Jansson) where the goal is to create an introductory learning material for physics aimed at programmers with a basic understanding of Haskell. It does this by identifying key areas in physics with a well defined scope, for example dimensional analysis or single particle mechanics, and develops a domain specific language around each of these areas. The implementation of these DSL’s are the meat of the learning material with accompanying text to explain every step and how it relates to the physics of that specific area. The text is written in such a way as to be as non-frightening as possible, and to only require a beginner knowledge in Haskell. Inspiration is taken from Learn you a Haskell for Great Good and the project DSLsofMath (→4.8.4) at Chalmers and University of Gothenburg. The source code and learning material is freely available online. Further reading Learn You A Physics

4.9 Text and Markup

4.9.1 lhs2TeX Report by: Andres Löh Status: stable, maintained This tool by Ralf Hinze and Andres Löh is a preprocessor that transforms literate Haskell or Agda code into LaTeX documents. The output is highly customizable by means of formatting directives that are interpreted by lhs2TeX. Other directives allow the selective inclusion of program fragments, so that multiple versions of a program and/or document can be produced from a common source. The input is parsed using a liberal parser that can interpret many languages with a Haskell-like syntax. The program is stable and can take on large documents. The current version is 1.19 and has been released in April 2015. Development repository and bug tracker are on GitHub. The tool is mostly in plain maintenance mode, although there are still vague plans for a complete rewrite of lhs2TeX, hopefully cleaning up the internals and making the functionality of lhs2TeX available as a library. Further reading http://www.andres-loeh.de/lhs2tex

https://github.com/kosmikus/lhs2tex

4.9.2 Fast Unicode Normalization Report by: Harendra Kumar Status: Working Unicode strings need to be converted to a normalized form using the Unicode Character Database before they can be compared for equivalence. unicode-transforms is a pure Haskell implementation of Unicode normalization. The alternative is the text-icu package which provides this functionality as Haskell bindings to the ICU C++ implementation. unicode-transforms supports all forms of normalization (NFC/NFD/NFKC/NFKD) and supports the latest version of the Unicode standard (Unicode 9). One of the goals of unicode-transforms was high performance. We have successfully achieved this goal for decompose (NFD/NFKD) forms, achieving performance close to, and in one benchmark even better than the C++ implementation (i.e. the text-icu package). Compose (NFC/NFKC) implementation is not yet optimized, and though the performance of compose is decent it is not at par with the C++ implementation. This is still open for anyone looking for a challenge to beat C++. This library can potentially be integrated with the text package allowing us to keep text in a standard normalized form by default, thus freeing the Haskell programmers from worrying about explicit normalization. The library is available on Hackage under BSD3 license. Further reading https://github.com/harendra-kumar/unicode-transforms

This rapid software development tool json-autotype interprets JSON data and converts them into Haskell module with data type declarations. $ json-autotype input.json -o JSONTypes.hs

The generated declarations use automatically derived Aeson class instances to read and write data directly from/to JSON strings, and facilitate interaction with growing number of large JSON APIs. Generated parser can be immediately tested on an input data: $ runghc JSONTypes.hs input.json

The software can be installed directly from Hackage. It uses sophisticated union type unification, and robustly interprets most ambiguities using clever typing. The tool has reached maturity this year, and thanks to automated testing procedures it seems to robustly infer types for all JSON inputs considered valid by Aeson. The tool now supports Elm output, and plans to support all members of Haskell family of languages. The author welcomes comments and suggestions at <mjgajda at gmail.com>. Further reading http://hackage.haskell.org/package/json-autotype

4.9.4 Ginger Report by: Tobias Dammers Status: Active development Ginger is a Haskell implementation of the Jinja2 HTML template language. Unlike most existing Haskell templating solutions, Ginger expands templates at run-time, not compile time; this is a deliberate design decision, intended to support a typical rapid-cycle web development workflow. Also unlike most existing Haskell HTML DSLs, Ginger is completely unaware of the DOM, and does not enforce well-formed HTML. Just like Jinja2, however, it does distinguish HTML source and raw values at the type level, meaning that HTML encoding is automatic and (mostly) transparent, avoiding the most common source of XSS vulnerabilities. For a quick impression of what Ginger syntax looks like: <section class="page">

<h1>{{ page.title }}</h1>

{% if page.image %}

<img class="page-image"

src="{{ page.image.thumbURL }}" />

{% endif %}

<section class="teaser">

{{ page.teaser }}

</section>

<section class="content">

{{ page.body|markdown }}

</section>

<section class="page-meta">

Submitted by {{ page.author }} on

{{page.submitted|formatDate('%Y-%m-%d')}}

</section>

</section>

All the important features of Jinja2 have been implemented, and the library is fully usable for production work. Some features of the original Jinja2 have been left out because the author considers them Pythonisms; others are missing simply because they haven’t been implemented yet. Additionally, some features have been added that are missing in Jinja2, such as lambdas, being able to use macros as functions or filters, ‘do‘ expressions, output indenting constructs, and “script mode”, switching Ginger into a syntax that is closer to a unityped scripting language than a template language. Improvement that haven’t made it yet include TemplateHaskell support (which would allow programmers to compile Ginger templates directly into the binary, and perform template compilation at compile time rather than runtime), a built-in caching mechanism, and more configuration options. Contributions of any kind are very welcome. Further reading https://ginger.tobiasdammers.nl/

https://github.com/tdammers/ginger

http://hackage.haskell.org/package/ginger

http://jinja2.pocoo.org (the original Jinja2, not my work)

4.10 Web

WAI (Web Application Interface) is an application interface between web applications and handlers in Haskell. The Application data type is defined as follows: type Application

= Request

-> (Response -> IO ResponseReceived)

-> IO ResponseReceived

That is, a WAI application takes two arguments: a Request and a function to send a Response . So, the typical behavior of WAI application is processing a request, generating a response and passing the response to the function. Historically speaking, this interface made possible to develop handlers other than HTTP. The WAI applications can run through FastCGI (wai-handler-fastcgi), run as stand-alone (wai-handler-webkit), etc. But the most popular handler is based on HTTP, of course. The major HTTP handler for WAI is Warp which now provides both HTTP/1.1 and HTTP/2. TLS (warp-tls) is also available. New transports such as WebSocket (wai-websocket) and Event Source (wai-extra) can be implemented, too. It is possible to develop WAI applications directly. For instance, Hoogle and Mighttpd2 take this way. However, you may want to use web application frameworks such as Apiary, MFlow, rest, Servant, Scotty, Spock, Yesod, etc. WAI also provides Middleware : type Middleware = Application -> Application

WAI middleware can inspect and transform a request, for example by automatically gzipping a response or logging a request (wai-extra). Since the last HCAR, WAI started using Builder of ByteString instead of Builder of blaze-builder. Because they are identical, no backward compatibility issue happens. Further reading https://groups.google.com/d/forum/haskell-wai

4.10.2 Warp Report by: Kazu Yamamoto Participants: Michael Snoyman Status: stable Warp is a high performance, easy to deploy HTTP handler for WAI (→4.10.1). Its supports both HTTP/1.1 and HTTP/2. Since the last HCAR, no major changes were made. Further reading “Warp: A Haskell Web Server” the May/June 2011 issue of IEEE Internet Computing Issue page: http://www.computer.org/portal/web/csdl/abs/mags/ic/2011/03/mic201103toc.htm PDF: http://steve.vinoski.net/pdf/IC-Warp_a_Haskell_Web_Server.pdf

“Warp” The Performance of Open Source Applications HTML: http://www.aosabook.org/en/posa/warp.html



Yesod is a traditional MVC RESTful framework. By applying Haskell’s strengths to this paradigm, Yesod helps users create highly scalable web applications. Performance scalability comes from the amazing GHC compiler and runtime. GHC provides fast code and built-in event-based asynchronous IO. But Yesod is even more focused on scalable development. The key to achieving this is applying Haskell’s type-safety to an otherwise traditional MVC REST web framework. Of course type-safety guarantees against typos or the wrong type in a function. But Yesod cranks this up a notch to guarantee common web application errors won’t occur. declarative routing with type-safe urls — say goodbye to broken links

no XSS attacks — form submissions are automatically sanitized

database safety through the Persistent library (→4.11.1) — no SQL injection and queries are always valid

valid template variables with proper template insertion — variables are 