10,464 research outputs found
Aspect-Oriented Programming with Type Classes
We consider the problem of adding aspects to a strongly typed language which supports type classes. We show that type classes as supported by the Glasgow Haskell Compiler can model an AOP style of programming via a simple syntax-directed transformation scheme where AOP programming idioms are mapped to type classes. The drawback of this approach is that we cannot easily advise functions in programs which carry type annotations. We sketch a more principled approach which is free of such problems by combining ideas from intentional type analysis with advanced overloading resolution strategies. Our results show that type-directed static weaving is closely related to type class resolution -- the process of typing and translating type class programs
Proof Relevant Corecursive Resolution
Resolution lies at the foundation of both logic programming and type class
context reduction in functional languages. Terminating derivations by
resolution have well-defined inductive meaning, whereas some non-terminating
derivations can be understood coinductively. Cycle detection is a popular
method to capture a small subset of such derivations. We show that in fact
cycle detection is a restricted form of coinductive proof, in which the atomic
formula forming the cycle plays the role of coinductive hypothesis.
This paper introduces a heuristic method for obtaining richer coinductive
hypotheses in the form of Horn formulas. Our approach subsumes cycle detection
and gives coinductive meaning to a larger class of derivations. For this
purpose we extend resolution with Horn formula resolvents and corecursive
evidence generation. We illustrate our method on non-terminating type class
resolution problems.Comment: 23 pages, with appendices in FLOPS 201
Proving Type Class Laws for Haskell
Type classes in Haskell are used to implement ad-hoc polymorphism, i.e. a way
to ensure both to the programmer and the compiler that a set of functions are
defined for a specific data type. All instances of such type classes are
expected to behave in a certain way and satisfy laws associated with the
respective class. These are however typically just stated in comments and as
such, there is no real way to enforce that they hold. In this paper we describe
a system which allows the user to write down type class laws which are then
automatically instantiated and sent to an inductive theorem prover when
declaring a new instance of a type class.Comment: Presented at the Symposium for Trends in Functional Programming, 201
- …