Network


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

Hotspot


Dive into the research topics where Marcos Viera is active.

Publication


Featured researches published by Marcos Viera.


international conference on functional programming | 2009

Attribute grammars fly first-class: how to do aspect oriented programming in Haskell

Marcos Viera; S. Doaitse Swierstra; Wouter Swierstra

Attribute Grammars (AGs), a general-purpose formalism for describing recursive computations over data types, avoid the trade-off which arises when building software incrementally: should it be easy to add new data types and data type alternatives or to add new operations on existing data types? However, AGs are usually implemented as a pre-processor, leaving e.g. type checking to later processing phases and making interactive development, proper error reporting and debugging difficult. Embedding AG into Haskell as a combinator library solves these problems. Previous attempts at embedding AGs as a domain-specific language were based on extensible records and thus exploiting Haskells type system to check the well formedness of the AG, but fell short in compactness and the possibility to abstract over oft occurring AG patterns. Other attempts used a very generic mapping for which the AG well-formedness could not be statically checked. We present a typed embedding of AG in Haskell satisfying all these requirements. The key lies in using HList-like typed heterogeneous collections (extensible polymorphic records) and expressing AG well-formedness conditions as type-level predicates (i.e., type-class constraints). By further type-level programming we can also express common programming patterns, corresponding to the typical use cases of monads such as Reader, Writer and State. The paper presents a realistic example of type-class-based type-level programming in Haskell.


Electronic Notes in Theoretical Computer Science | 2010

Typed Transformations of Typed Grammars: The Left Corner Transform

Arthur I. Baars; S. Doaitse Swierstra; Marcos Viera

One of the questions which comes up when using embedded domain specific languages is to what extent we can analyze and transform embedded programs, as normally done in more conventional compilers. Special problems arise when the host language is strongly typed, and this host type system is used to type the embedded language. In this paper we describe how we can use a library, which was designed for constructing transformations of typed abstract syntax, in the removal of left recursion from a typed grammar description. The algorithm we describe is the Left-Corner Transform, which is small enough to be fully explained, involved enough to be interesting, and complete enough to serve as a tutorial on how to proceed in similar cases. The described transformation has been successfully used in constructing a compositional and efficient alternative to the standard Haskell read function.


symposium/workshop on haskell | 2008

Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime

Marcos Viera; S. Doaitse Swierstra; Eelco Lempsink

The Haskell definition and implementation of read is far from perfect. In the first place read is not able to handle the associativities defined for infix operators. Furthermore, it puts constraints on the way show is defined, and especially forces it to generate far more parentheses than expected. Lastly, it may give rise to exponential parsing times. All this is due to the compositionality requirement for read functions, which imposes a top-down parsing strategy. We propose a different approach, based on typed abstract syntax, in which grammars describing the data types are composed dynamically. Using the transformation libraries described in a companion paper these syntax descriptions are combined and transformed into parsers at runtime, from which the required read function are constructed. In this way we obtain linear parsing times, achieve consistency with the defined associativities, and may use a version of show which generates far fewer parentheses, thus improving readability of printed values. The described transformation algorithms can be incorporated in a Haskell compiler, thus moving most of the work involved to compile time.


language descriptions tools and applications | 2012

Grammar fragments fly first-class

Marcos Viera; S. Doaitse Swierstra; Atze Dijkstra

We present a Embedded Domain Specific language in the form of a Haskell library (EDSL) for expressing grammar (fragments), using typed abstract syntax with observable references. Thus grammar fragments have become fully typed, first-class Haskell values. We can analyze and transform such representations and generate parsers from them. What makes our approach special is that we can combine embedded grammar fragments on the fly, i.e. after they have been compiled and that the Haskell type system is used to check the consistency of a collection of combined fragments. We show how we can extend an initial, limited grammar embedded in a compiler with new syntactic constructs, either by introducing new non-terminals or by adding new productions for existing non-terminals. We do not impose any restrictions on the individual grammar fragments, nor on the structure as a whole.


language descriptions tools and applications | 2012

UUAG meets AspectAG: how to make attribute grammars first-class

Marcos Viera; S. Doaitse Swierstra; Arie Middelkoop

The Utrecht University Attribute Grammar Compiler takes attribute grammar declarations from multiple source files and generates an attribute grammar evaluator consisting of a single Haskell source text. The problem with such generative approaches is that, once the code is generated and compiled, neither new attributes can be introduced nor existing ones can be modified without providing access to all the source code and without having to regenerate and recompile the entire program. In contrast to this textual approach we recently constructed the Haskell combinator library AspectAG with which one can construct attribute grammar fragments as a Haskell value. Such descriptions can be individually type-checked, compiled, distributed and composed to construct a compiler. This method however results in rather inefficient compilers, due to the costs incurred by the increased flexibility. We show how to combine the two approaches by generating AspectAG code fragments from UUAGC sources, thus making it possible to trade between efficiency and flexibility; besides enabling a couple of optimizations for AspectAG resulting in a considerable speed improvement this makes existing UUAGC code reusable in a flexible environment.


SBLP'12 Proceedings of the 16th Brazilian conference on Programming Languages | 2012

Attribute grammar macros

Marcos Viera; S. Doaitse Swierstra

Having extensible languages is appealing, but raises the question of how to construct extensible compilers and how to compose compilers out of a collection of pre-compiled components. Being able to deal with attribute grammar fragments as first-class values makes it possible to describe semantics in a compositional way; this leads naturally to a plug-in architecture, in which a core compiler can be constructed as a (collection of) pre-compiled component(s), and to which extra components can safely be added as need arises. We extend AspectAG, a Haskell library for building strongly typed first-class attribute grammars, with a set of combinators that make it easy to describe semantics in terms of already existing semantics in a macro-like style, just as syntax macros extend the syntax of a language. We also show how existing semantics can be redefined, thus adapting some aspects from the behavior defined by the macros.


implementation and application of functional languages | 2016

A Lazy Language Needs a Lazy Type System: Introducing Polymorphic Contexts

S. Doaitse Swierstra; Marcos Viera; Atze Dijkstra

Most type systems that support polymorphic functions are based on a version of System-F. We argue that this limits useful programming paradigms for languages with lazy evaluation. We motivate an extension of System-F alleviating this limitation. First, using a sequence of examples, we show that for lazily evaluated languages current type systems may force one to write a program in an unnatural way; in particular, we argue that in such languages the relationship between polymorphic and existential types can be made more systematic by allowing to pass back (part of) an existential result of a function call as an argument to the function call that produced that value. After presenting our extension to System-F we show how we can implement the strict-state thread monad ST by using a returned existential type to instantiating a polymorphic function that returns that type. Currently this monad is built-in into the runtime system of GHC and as such has become part of the language. Our proposed language extension, i.e. the introduction of polymorphic contexts, reverses the relationship between the context of a function call and the called function with respect to where it is decided with which type to instantiate a type variable.


Science of Computer Programming | 2015

Compositional compiler construction

Marcos Viera; S. Doaitse Swierstra

We describe an implementation of an Oberon0 compiler using the techniques proposed in the CoCoCo project. The compiler is constructed out of a collection of pre-compiled, statically type-checked language-definition fragments written in Haskell. Oberon0 compiler implemented using the techniques proposed in the CoCoCo project.Built from pre-compiled, statically type-checked language-definition fragments.Written in Haskell.


types in languages design and implementation | 2009

Typed transformations of typed abstract syntax

Arthur I. Baars; S. Doaitse Swierstra; Marcos Viera


implementation and application of functional languages | 2013

First Class Syntax, Semantics, and Their Composition

Marcos Viera; S. Doaitse Swierstra

Collaboration


Dive into the Marcos Viera's collaboration.

Top Co-Authors

Avatar
Top Co-Authors

Avatar
Top Co-Authors

Avatar

Arthur I. Baars

Polytechnic University of Valencia

View shared research outputs
Top Co-Authors

Avatar
Top Co-Authors

Avatar
Top Co-Authors

Avatar
Researchain Logo
Decentralizing Knowledge