9 research outputs found

    Tracing monadic computations and representing effects

    Full text link
    In functional programming, monads are supposed to encapsulate computations, effectfully producing the final result, but keeping to themselves the means of acquiring it. For various reasons, we sometimes want to reveal the internals of a computation. To make that possible, in this paper we introduce monad transformers that add the ability to automatically accumulate observations about the course of execution as an effect. We discover that if we treat the resulting trace as the actual result of the computation, we can find new functionality in existing monads, notably when working with non-terminating computations.Comment: In Proceedings MSFP 2012, arXiv:1202.240

    The constrained-monad problem

    Get PDF
    In Haskell, there are many data types that would form monads were it not for the presence of type-class constraints on the operations onthat data type. This is a frustrating problem in practice, because there is a considerable amount of support and infrastructure for monads that these data types cannot use. Using several examples,we show that a monadic computation can be restructured into a normal form such that the standard monad class can be used. The technique is not specific to monads, and we show how it can also be applied to other structures, such as applicative functors. One significant use case for this technique is domain-specific languages,where it is often desirable to compile a deep embedding of a computation to some other language, which requires restricting the types that can appear in that computation

    数学と計算機科学の相互作用:計算代数とHaskellにおける安全性と拡張性

    Get PDF
    筑波大学 (University of Tsukuba)201

    Efficient abstractions for visualization and interaction

    Get PDF
    Abstractions, such as functions and methods, are an essential tool for any programmer. Abstractions encapsulate the details of a computation: the programmer only needs to know what the abstraction achieves, not how it achieves it. However, using abstractions can come at a cost: the resulting program may be inefficient. This can lead to programmers not using some abstractions, instead writing the entire functionality from the ground up. In this thesis, we present several results that make this situation less likely when programming interactive visualizations. We present results that make abstractions more efficient in the areas of graphics, layout and events

    Über logisch-funktionale Programmierung und deren Anwendung zum Testen

    Get PDF
    Die vorliegende Arbeit untersucht die Implementierung logisch-funktionaler Programmierung und deren Anwendung zur automatischen Generierung von Testdaten. Logisch-funktionale Programmierung vereint zwei deklarative Programmierparadigmen, funktionale Programmierung und Logikprogrammierung, in einem einheitlichen Programmiermodell. Es stellt sich heraus, dass diese Kombination zur Spezifikation und automatischen Generierung von Testdaten gut geeignet ist. Motiviert durch die erkannte Verwandtschaft von Testdatengenerierung und logisch-funktionaler Programmierung, stellt die Arbeit einen neuen Ansatz vor, logisch-funktionale Programme in rein funktionalen Programmiersprachen auszudrücken

    Gestione degli effetti in linguaggi di programmazione funzionale: tecniche di modellazione e interpretazione

    Get PDF
    Nel corso degli anni i linguaggi di programmazione imperativi “mainstream” – come Java, Python e JavaScript – sono stati fortemente influenzati dal paradigma di programmazione funzionale, adottando e riconoscendo l’utilita` di numerose tecniche come funzioni anonime, tipi di dato algebrici (ADT), pattern matching, strutture dati immutabili, ecc. Un approccio che ad oggi rimane prettamente confinato al mondo della pro- grammazione funzionale pura `e quello che consiste nel modellare esplicitamente gli effetti delle funzioni, separando in maniera netta – grazie al supporto automatico del type system – codice puro da quello che puo` presentare side effect. In linguaggi di programmazione imperativi che non supportano nativamente questi meccanismi, `e possibile ottenere una separazione analoga utilizzando archi- tetture come quella “esagonale”. Tuttavia, il rispetto di queste buone pratiche di programmazione `e lasciato interamente all’autodisciplina del programmatore e non `e imposto automaticamente dal compilatore. La risultante presenza incontrollata di side effect ha l’effetto di creare reti di dipendenze invisibili che rendono complesso ragionare sulle propriet`a del codice, testarlo o effettuare refactoring. L’obiettivo di questa tesi `e fornire una visione complessiva delle principali tecniche che possono essere adottate per modellare e rendere esplicita la presenza dei side effect nelle funzioni: Monad Transformer Library (MTL) e free monad. Infine, viene mostrato un approccio emergente basato sull’utilizzo degli effetti algebrici. Tutti i meccanismi analizzati sono introdotti in maniera graduale accompagnando la trattazione con diversi esempi e frammenti di codice che evidenziano i benefici che queste tecniche possono apportare

    Practical Type Inference for the GADT Type System

    Get PDF
    Generalized algebraic data types (GADTs) are a type system extension to algebraic data types that allows the type of an algebraic data value to vary with its shape. The GADT type system allows programmers to express detailed program properties as types (for example, that a function should return a list of the same length as its input), and a general-purpose type checker will automatically check those properties at compile time. Type inference for the GADT type system and the properties of the type system are both currently areas of active research. In this dissertation, I attack both problems simultaneously by exploiting the symbiosis between type system research and type inference research. Deficiencies of GADT type inference algorithms motivate research on specific aspects of the type system, and discoveries about the type system bring in new insights that lead to improved GADT type inference algorithms. The technical contributions of this dissertation are therefore twofold: in addition to new GADT type system properties (such as the prevalence of pointwise type information flow in GADT patterns, a generalized notion of existential types, and the effects of enforcing the GADT branch reachability requirement), I will also present a new GADT type inference algorithm that is significantly more powerful than existing algorithms. These contributions should help programmers use the GADT type system more effectively, and they should also enable language implementers to provide better support for the GADT type system

    Programming monads operationally with Unimo

    No full text
    Monads are widely used in Haskell for modeling computational effects, but defining monads remains a daunting challenge. Since every part of a monad’s definition depends on its computational effects, programmers cannot leverage the common behavior of all monads easily and thus must build from scratch each monad that models a new computational effect. I propose the Unimo framework which allows programmers to define monads and monad transformers in a modular manner. Unimo contains a heavily parameterized observer function which enforces the monad laws, and programmers define a monad by invoking the observer function with arguments that specify the computational effects of the monad. Since Unimo provides the common behavior of all monads in a reusable form, programmers no longer need to rebuild the semantic boilerplate for each monad and can instead focus on the more interesting and rewarding task of modeling the desired computational effects

    Programming monads operationally with Unimo

    No full text
    corecore