Programming with Applicative-like expressions

05/26/2019
by   Jan Malakhovski, et al.
0

The fact that Applicative type class allows one to express simple parsers in a variable-less combinatorial style is well appreciated among Haskell programmers for its conceptual simplicity, ease of use, and usefulness for semi-automated code generation (metaprogramming). We notice that such Applicative computations can be interpreted as providing a mechanism to construct a data type with "ports" "pluggable" by subcomputations. We observe that it is this property that makes them so much more convenient in practice than the usual way of building the same computations using conventional composition. We distill this observation into a more general algebraic structure of (and/or technique for expressing) "Applicative-like" computations and demonstrate several other instances of this structure. Our interest in all of this comes from the fact that the aforementioned instances allow us to express arbitrary transformations between simple data types of a single constructor (similarly to how Applicative parsing allows to transform from streams of Chars to such data types) using a style that closely follows conventional Applicative computations, thus greatly simplifying (if not completely automating away) a lot of boiler-plate code present in many functional programs.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
05/16/2019

First-Class Subtypes

First class type equalities, in the form of generalized algebraic data t...
research
02/06/2018

Code Reuse With Transformation Objects

We present an approach for a lightweight datatype-generic programming in...
research
06/15/2021

Introducing Type Properties

In type theory, we can express many practical ideas by attributing some ...
research
03/18/2022

How Do Programmers Express High-Level Concepts using Primitive Data Types?

We investigated how programmers express high-level concepts such as path...
research
10/08/2019

Do People Prefer "Natural" code?

Natural code is known to be very repetitive (much more so than natural l...
research
01/10/2019

Cocon: Computation in Contextual Type Theory

We describe a Martin-Löf style dependent type theory, called Cocon, that...
research
07/15/2017

Memoisation: Purely, Left-recursively, and with (Continuation Passing) Style

Memoisation, or tabling, is a well-known technique that yields large imp...

Please sign up or login with your details

Forgot password? Click here to reset