Network


Latest external collaboration on country level. Dive into details by clicking on the dots.

Hotspot


Dive into the research topics where Patrik Jansson is active.

Publication


Featured researches published by Patrik Jansson.


symposium on principles of programming languages | 2006

Fast and loose reasoning is morally correct

Nils Anders Danielsson; John Hughes; Patrik Jansson; Jeremy Gibbons

Functional programmers often reason about programs as if they were written in a total language, expecting the results to carry over to non-total (partial) languages. We justify such reasoning.Two languages are defined, one total and one partial, with identical syntax. The semantics of the partial language includes partial and infinite values, and all types are lifted, including the function spaces. A partial equivalence relation (PER) is then defined, the domain of which is the total subset of the partial language. For types not containing function spaces the PER relates equal values, and functions are related if they map related values to related values.It is proved that if two closed terms have the same semantics in the total language, then they have related semantics in the partial language. It is also shown that the PER gives rise to a bicartesian closed category which can be used to reason about values in the domain of the relation.


european symposium on programming | 1999

Polytypic Compact Printing and Parsing

Patrik Jansson; Johan Jeuring

A generic compact printer and a corresponding parser are constructed. These programs transform values of any regular datatype to and from a bit stream. The algorithms are constructed along with a proof that printing followed by parsing is the identity. Since the binary representation is very compact, the printer can be used for compressing data - possibly supplemented with some standard algorithm for compressing bit streams. The compact printer and the parser are described in the polytypic Haskell extension PolyP.


implementation and application of functional languages | 2003

Polytypic programming in haskell

Ulf Norell; Patrik Jansson

A polytypic (or generic) program captures a common pattern of computation over different datatypes by abstracting over the structure of the datatype. Examples of algorithms that can be defined polytypically are equality tests, mapping functions and pretty printers. A commonly used technique to implement polytypic programming is specialization, where a specialized version of a polytypic function is generated for every datatype it is used at. In this paper we describe an alternative technique that allows polytypic functions to be defined using Haskells class system (extended with multi-parameter type classes and functional dependencies). This technique brings the power of polytypic programming inside Haskell allowing us to define a Haskell library of polytypic functions. It also increases our flexibility, reducing the dependency on a polytypic language compiler.


european symposium on programming | 2010

Testing polymorphic properties

Jean-Philippe Bernardy; Patrik Jansson; Koen Claessen

This paper is concerned with testing properties of polymorphic functions. The problem is that testing can only be performed on specific monomorphic instances, whereas parametrically polymorphic functions are expected to work for any type. We present a schema for constructing a monomorphic instance for a polymorphic property, such that correctness of that single instance implies correctness for all other instances. We also give a formal definition of the class of polymorphic properties the schema can be used for. Compared to the standard method of testing such properties, our schema leads to a significant reduction of necessary test cases.


Journal of Functional Programming | 1998

Polytypic unification

Patrik Jansson; Johan Jeuring

Unification, or two-way pattern matching, is the process of solving an equation involving two first-order terms with variables. Unification is used in type inference in many programming languages and in the execution of logic programs. This means that unification algorithms have to be written over and over again for different term types. Many other functions also make sense for a large class of datatypes; examples are pretty printers, equality checks, maps etc. They can be defined by induction on the structure of user-defined datatypes. Implementations of these functions for different datatypes are closely related to the structure of the datatypes. We call such functions polytypic. This paper describes a unification algorithm parametrised on the type of the terms, and shows how to use polytypism to obtain a unification algorithm that works for all regular term types.


Journal of Functional Programming | 2009

Algebra of programming in agda: Dependent types for relational program derivation

Shin-Cheng Mu; Hsiang-Shang Ko; Patrik Jansson

Relational program derivation is the technique of stepwise refining a relational specification to a program by algebraic rules. The program thus obtained is correct by construction. Meanwhile, dependent type theory is rich enough to express various correctness properties to be verified by the type checker. We have developed a library, AoPA (Algebra of Programming in Agda), to encode relational derivations in the dependently typed programming language Agda. A program is coupled with an algebraic derivation whose correctness is guaranteed by the type system. Two non-trivial examples are presented: an optimisation problem and a derivation of quicksort in which well-founded recursion is used to model terminating hylomorphisms in a language with inductive types.


workshop on generic programming | 2008

A comparison of c++ concepts and haskell type classes

Jean-Philippe Bernardy; Patrik Jansson; Marcin Zalewski; Sibylle Schupp; Andreas P. Priesnitz

Earlier studies have introduced a list of high-level evaluation criteria to assess how well a language supports generic programming. Since each language that meets all criteria is considered generic, those criteria are not fine-grained enough to differentiate between languages for generic programming. We refine these criteria into a taxonomy that captures differences between type classes in Haskell and concepts in C++, and discuss which differences are incidental and which ones are due to other language features. The taxonomy allows for an improved understanding of language support for generic programming, and the comparison is useful for the ongoing discussions among language designers and users of both languages.


mathematics of program construction | 2004

Prototyping Generic Programming in Template Haskell

Ulf Norell; Patrik Jansson

Generic Programming deals with the construction of programs that can be applied to many different datatypes. This is achieved by parameterizing the generic programs by the structure of the datatypes on which they are to be applied. Programs that can be defined generically range from simple map functions through pretty printers to complex XML tools.


mathematics of program construction | 2008

Algebra of Programming Using Dependent Types

Shin-Cheng Mu; Hsiang-Shang Ko; Patrik Jansson

Dependent type theory is rich enough to express that a program satisfies an input/output relational specification, but it could be hard to construct the proof term. On the other hand, squiggolists know very well how to show that one relation is included in another by algebraic reasoning. We demonstrate how to encode functional and relational derivations in a dependently typed programming language. A program is coupled with an algebraic derivation from a specification, whose correctness is guaranteed by the type system.


Journal of Functional Programming | 2010

Generic programming with c++ concepts and haskell type classes: A comparison

Jean-Philippe Bernardy; Patrik Jansson; Marcin Zalewski; Sibylle Schupp

Earlier studies have introduced a list of high-level evaluation criteria to assess how well a language supports generic programming. Languages that meet all criteria include Haskell because of its type classes and C++ with the concept feature. We refine these criteria into a taxonomy that captures commonalities and differences between type classes in Haskell and concepts in C++ and discuss which differences are incidental and which ones are due to other language features. The taxonomy allows for an improved understanding of language support for generic programming, and the comparison is useful for the ongoing discussions among language designers and users of both languages.

Collaboration


Dive into the Patrik Jansson's collaboration.

Top Co-Authors

Avatar
Top Co-Authors

Avatar

Jean-Philippe Bernardy

Chalmers University of Technology

View shared research outputs
Top Co-Authors

Avatar

Cezar Ionescu

Potsdam Institute for Climate Impact Research

View shared research outputs
Top Co-Authors

Avatar

Nicola Botta

Potsdam Institute for Climate Impact Research

View shared research outputs
Top Co-Authors

Avatar

Cezar Ionescu

Potsdam Institute for Climate Impact Research

View shared research outputs
Top Co-Authors

Avatar
Top Co-Authors

Avatar

Claes Niklasson

Chalmers University of Technology

View shared research outputs
Top Co-Authors

Avatar

Marcin Zalewski

Chalmers University of Technology

View shared research outputs
Top Co-Authors

Avatar

Ulf Norell

Chalmers University of Technology

View shared research outputs
Top Co-Authors

Avatar

Sibylle Schupp

Hamburg University of Technology

View shared research outputs
Researchain Logo
Decentralizing Knowledge