Table of Contents
Fetching ...

GeckoGraph: A Visual Language for Polymorphic Types

Shuai Fu, Tim Dwyer, Peter J. Stuckey

TL;DR

GeckoGraph introduces a visual notation for polymorphic type annotations to complement traditional text-based type notation, with the goal of improving readability, comprehension, and comparison of complex types. The authors design a color- and shape-based diagrammatic system that encodes simple types, data types, function types, and type-class constraints, plus advanced features like kind information and precise interactivity. In a large controlled study (the Zero to Hero game) with 714 participants, GeckoGraph increased overall success rates and particularly aided novices, while not increasing task time on average. The work suggests GeckoGraph can support programming assistance, documentation, and pedagogy, and points to future directions including accessibility improvements and in-the-wild evaluations.

Abstract

Polymorphic types are an important feature in most strongly typed programming languages. They allow functions to be written in a way that can be used with different data types, while still enforcing the relationship and constraints between the values. However, programmers often find polymorphic types difficult to use and understand and tend to reason using concrete types. We propose GeckoGraph, a graphical notation for types. GeckoGraph aims to accompany traditional text-based type notation and to make reading, understanding, and comparing types easier. We conducted a large-scale human study using GeckoGraph compared to text-based type notation. To our knowledge, this is the largest controlled user study on functional programming ever conducted. The results of the study show that GeckoGraph helps improve programmers' ability to succeed in the programming tasks we designed, especially for novice programmers.

GeckoGraph: A Visual Language for Polymorphic Types

TL;DR

GeckoGraph introduces a visual notation for polymorphic type annotations to complement traditional text-based type notation, with the goal of improving readability, comprehension, and comparison of complex types. The authors design a color- and shape-based diagrammatic system that encodes simple types, data types, function types, and type-class constraints, plus advanced features like kind information and precise interactivity. In a large controlled study (the Zero to Hero game) with 714 participants, GeckoGraph increased overall success rates and particularly aided novices, while not increasing task time on average. The work suggests GeckoGraph can support programming assistance, documentation, and pedagogy, and points to future directions including accessibility improvements and in-the-wild evaluations.

Abstract

Polymorphic types are an important feature in most strongly typed programming languages. They allow functions to be written in a way that can be used with different data types, while still enforcing the relationship and constraints between the values. However, programmers often find polymorphic types difficult to use and understand and tend to reason using concrete types. We propose GeckoGraph, a graphical notation for types. GeckoGraph aims to accompany traditional text-based type notation and to make reading, understanding, and comparing types easier. We conducted a large-scale human study using GeckoGraph compared to text-based type notation. To our knowledge, this is the largest controlled user study on functional programming ever conducted. The results of the study show that GeckoGraph helps improve programmers' ability to succeed in the programming tasks we designed, especially for novice programmers.
Paper Structure (92 sections, 14 figures)

This paper contains 92 sections, 14 figures.

Figures (14)

  • Figure 1: An example type error where a programmer mistakenly provided a Char instead of a String literal. Left -- The compiler shows an error message comparing the provided Char type to a confusingly named type t0 a0. Right -- GeckoGraph shows the exact message with the two types in graphic notation, highlighting the structural difference rather than identifier names.
  • Figure 2: Examples of various types as represented in GeckoGraph, including type variables (A) and concrete types (B). Data types (C, D, E), function types (F, G, H), and type classes (I, J).
  • Figure 3: An example of using the function indicator. The function indicator can be used to easily identify the arity of a function type by counting the connecting function indicators. For high-order functions where functions are arguments of other functions, it is very easy to see the "order" of functions and how they are arranged.
  • Figure 4: Advanced features of GeckoGrap. (A) GeckoGraph supports Kind Visualization if the inferred kind is greater than *. (B) GeckoGraph supports qualified constraints by extending the extended area across multiple type variables. (C) GeckoGraph supports Multiple Parameter Type Classes, using different shapes of the same color to indicate that multiple variables must satisfy certain type classes collectively. (D) GeckoGraph supports the precise selection of its sub-structures.
  • Figure 5: Previous Versions of GeckoGraph. Different encodings represent named types, type variables, type constructors, and high-order functions.
  • ...and 9 more figures