7 research outputs found
FliPpr: A Prettier Invertible Printing System
When implementing a programming language, we often write
a parser and a pretty-printer. However, manually writing both programs
is not only tedious but also error-prone; it may happen that a pretty-printed
result is not correctly parsed. In this paper, we propose FliPpr,
which is a program transformation system that uses program inversion
to produce a CFG parser from a pretty-printer. This novel approach
has the advantages of fine-grained control over pretty-printing, and easy
reuse of existing efficient pretty-printer and parser implementations
Efficient and Type-Safe Generic Data Storage
AbstractIn this paper we present an elegant method for sequentializing arbitrary data using the generic language extension of the functional programming language Clean. We show how the proposed operations can be used to store values of any concrete data type in several kinds of IO containers (such as files or arrays of characters), and how to manipulate stored data efficiently. Moreover, by extending stored data with encoded type information, data manipulation will be type-safe. Defining these operations generically has the advantage that specific instances for user defined data types can be generated fully automatically. Compared to traditional sequentialization methods (or to common data manipulation, using relational data bases) our operations are an order of magnitude faster
Extensional equality preservation and verified generic programming
In verified generic programming, one cannot exploit the structure of concrete
data types but has to rely on well chosen sets of specifications or abstract
data types (ADTs). Functors and monads are at the core of many applications of
functional programming. This raises the question of what useful ADTs for
verified functors and monads could look like. The functorial map of many
important monads preserves extensional equality. For instance, if are extensionally equal, that is, , then and are also
extensionally equal. This suggests that preservation of extensional equality
could be a useful principle in verified generic programming. We explore this
possibility with a minimalist approach: we deal with (the lack of) extensional
equality in Martin-L\"of's intensional type theories without extending the
theories or using full-fledged setoids. Perhaps surprisingly, this minimal
approach turns out to be extremely useful. It allows one to derive simple
generic proofs of monadic laws but also verified, generic results in dynamical
systems and control theory. In turn, these results avoid tedious code
duplication and ad-hoc proofs. Thus, our work is a contribution towards
pragmatic, verified generic programming.Comment: Manuscript ID: JFP-2020-003
Arrows, like Monads, are Monoids
Monads are by now well-established as programming construct in functional languages. Recently, the notion of âArrow â was introduced by Hughes as an extension, not with one, but with two type parameters. At first, these Arrows may look somewhat arbitrary. Here we show that they are categorically fairly civilised, by showing that they correspond to monoids in suitable subcategories of bifunctors C op ĂC â C. This shows that, at a suitable level of abstraction, arrows are like monads â which are monoids in categories of functors C â C. Freyd categories have been introduced by Power and Robinson to model computational effects, well before Hughes â Arrows appeared. It is often claimed (informally) that Arrows are simply Freyd categories. We shall make this claim precise by showing how monoids in categories of bifunctors exactly correspond to Freyd categories
Polytypic Data Conversion Programs
Several generic programs for converting values from regular datatypes to some other format, together with their corresponding inverses, are constructed. Among the formats considered are shape plus contents, compact bit streams and pretty printed strings. The different data conversion programs are constructed using John Hughes' arrow combinators along with a proof that printing (from a regular datatype to another format) followed by parsing (from that format back to the regular datatype) is the identity. The printers and parsers are described in PolyP, a polytypic extension of the functional language Haskell