170 research outputs found
An EDSL approach to high performance Haskell programming
This paper argues for a new methodology for writing high per-formance Haskell programs by using Embedded Domain Specific Languages. We exemplify the methodology by describing a complete li-brary, meta-repa, which is a reimplementation of parts of the repa library. The paper describes the implementation of meta-repa and contrasts it with the standard approach to writing high performance libraries. We conclude that even though the embedded language approach has an initial cost of defining the language and some syntactic overhead it gives a more tailored programming model, stronger performance guarantees, better control over optimizations, simpler implementation of fusion and inlining and allows for mov-ing type level programming down to value level programming in some cases. We also provide benchmarks showing that meta-repa is as fast, or faster, than repa. Furthermore, meta-repa also includes push arrays and we demonstrate their usefulness for writing certain high performance kernels such as FFT
How functional programming mattered
In 1989 when functional programming was still considered a niche topic, Hughes wrote a visionary paper arguing convincingly ‘why functional programming matters’. More than two decades have passed. Has functional programming really mattered? Our answer is a resounding ‘Yes!’. Functional programming is now at the forefront of a new generation of programming technologies, and enjoying increasing popularity and influence. In this paper, we review the impact of functional programming, focusing on how it has changed the way we may construct programs, the way we may verify programs, and fundamentally the way we may think about programs
Stream Fusion, to Completeness
Stream processing is mainstream (again): Widely-used stream libraries are now
available for virtually all modern OO and functional languages, from Java to C#
to Scala to OCaml to Haskell. Yet expressivity and performance are still
lacking. For instance, the popular, well-optimized Java 8 streams do not
support the zip operator and are still an order of magnitude slower than
hand-written loops. We present the first approach that represents the full
generality of stream processing and eliminates overheads, via the use of
staging. It is based on an unusually rich semantic model of stream interaction.
We support any combination of zipping, nesting (or flat-mapping), sub-ranging,
filtering, mapping-of finite or infinite streams. Our model captures
idiosyncrasies that a programmer uses in optimizing stream pipelines, such as
rate differences and the choice of a "for" vs. "while" loops. Our approach
delivers hand-written-like code, but automatically. It explicitly avoids the
reliance on black-box optimizers and sufficiently-smart compilers, offering
highest, guaranteed and portable performance. Our approach relies on high-level
concepts that are then readily mapped into an implementation. Accordingly, we
have two distinct implementations: an OCaml stream library, staged via
MetaOCaml, and a Scala library for the JVM, staged via LMS. In both cases, we
derive libraries richer and simultaneously many tens of times faster than past
work. We greatly exceed in performance the standard stream libraries available
in Java, Scala and OCaml, including the well-optimized Java 8 streams
Selective applicative functors & probabilistic programming
Dissertação de mestrado integrado em Informatics EngineeringIn functional programming, selective applicative functors (SAF) are an abstraction between
applicative functors and monads. This abstraction requires all effects to be statically declared,
but provides a way to select which effects to execute dynamically. SAF have been shown to
be a useful abstraction in several examples, including two industrial case studies. Selective
functors have been used for their static analysis capabilities. The collection of information
about all possible effects in a computation and the fact that they enable speculative execution
make it possible to take advantage to describe probabilistic computations instead of using
monads. In particular, selective functors appear to provide a way to obtain a more efficient
implementation of probability distributions than monads.
This dissertation addresses a probabilistic interpretation for the arrow and selective abstractions
in the light of the linear algebra of programming discipline, as well as exploring
ways of offering SAF capabilities to probabilistic programming, by exposing sampling as a
concurrency problem. As a result, provides a Haskell type-safe matrix library capable of
expressing probability distributions and probabilistic computations as typed matrices, and a
probabilistic programming eDSL that explores various techniques in order to offer a novel,
performant solution to probabilistic functional programming.Em programação funcional, os functores aplicativos seletivos (FAS) são uma abstração entre functores
aplicativos e monades. Essa abstração requer que todos os efeitos sejam declarados estaticamente,
mas fornece uma maneira de selecionar quais efeitos serão executados dinamicamente. FAS têm se
mostrado uma abstração útil em vários exemplos, incluindo dois estudos de caso industriais. Functores
seletivos têm sido usados pela suas capacidade de análise estática. O conjunto de informações sobre
todos os efeitos possÃveis numa computação e o facto de que eles permitem a execução especulativa
tornam possÃvel descrever computações probabilÃsticas. Em particular, functores seletivos parecem
oferecer uma maneira de obter uma implementação mais eficiente de distribuições probabilisticas do
que monades.
Esta dissertação aborda uma interpretação probabilÃstica para as abstrações Arrow e Selective
à luz da disciplina da álgebra linear da programação, bem como explora formas de oferecer as
capacidades dos FAS para programação probabilÃstica, expondo sampling como um problema de
concorrência. Como resultado, fornece uma biblioteca de matrizes em Haskell, capaz de expressar
distribuições de probabilidade e cálculos probabilÃsticos como matrizes tipadas e uma eDSL de
programação probabilÃstica que explora várias técnicas, com o obejtivo de oferecer uma solução
inovadora e de alto desempenho para a programação funcional probabilÃstica
Functional EDSLs for Web Applications
This thesis aims to make the development of complex web applications easier,faster and safer through the application of strongly typedfunctional programming techniques.Traditional web applications are commonly written in the de facto standardlanguage of the web, JavaScript, which, being untyped, provides no guaranteesregarding the data processed by programs, increasing the burden of testing anddefensive programming.Modern web applications are often highly complex, with multipleinterdependent parts interacting over the Internet.Such applications are traditionally implemented with each component as aseparate program, exposing its functionality to other components throughdifferent API:s over some communication protocol such as HTTP.This process is mostly manual, and thus error-prone and labour intensive,with accidental API incompatibility between components being particularlyproblematic.Even in a conventional typed language, the absence of such incompatibilitiesis not guaranteed.While the different components may well be type-safe in isolation, there is noguarantee that the whole is type-safe as the communication between componentsis not type-checked.We present a web application development framework, based on the Haskellprogramming language, to increase programmer productivity and software qualityby addressing these issues.In our framework, applications with an arbitrary number of components arewritten, compiled and type-checked as a single program, guaranteeing that theapplication as a whole, including network communication, is type-safe.Communication between components is automatically generated by our framework,eliminating the risk of API incompatibilities completely.Additionally, our framework includes astate-of-the-art compiler from Haskell to JavaScript,a novel, lightweight foreign function interface to allow programs to leverageexisting JavaScript code, an embedded language for integrating low-level,high-performance kernels into otherwise high-level web applications, as well asa highly expressive relational database language
- …