Inferring Algebraic Effects
نویسنده
چکیده
We present a complete polymorphic effect inference algorithm for an ML-style language with handlers of not only exceptions, but of any other algebraic effect such as input & output, mutable references and many others. Our main aim is to offer the programmer a useful insight into the effectful behaviour of programs. Handlers help here by cutting down possible effects and the resulting lengthy output that often plagues precise effect systems. Additionally, we present a set of methods that further simplify the displayed types, some even by deliberately hiding inferred information from the programmer. Though Haskell [10] fans may not think it is better to write impure programs in ML [18], they do agree it is easier. You can insert a harmless printout without rewriting the rest of the program, and you can combine multiple effects without a monad transformer. This flexibility comes at a cost, though —ML types offer no insight into what effects may happen. The suggested solution is to use an effect system [16, 29, 4, 31, 33, 3, 27], which enriches existing types with information about effects. An effect system can play two roles: it can be descriptive and inform about potential effects, and it can be prescriptive and limit the allowed ones. In this paper, we focus on the former. It turns out that striking a balance between expressiveness and simplicity of a descriptive effect system is hard. One of the bigger problems is that effects tend to pile up, and if the effect system takes them all into account, we are often left with a lengthy output listing every single effect there is. In this paper, we present a complete inference algorithm for an expressive and simple descriptive polymorphic effect system of Eff [2] (freely available at http://eff-lang.org), an ML-style language with handlers of not only exceptions, but of any other algebraic effect [22] such as input & output, non-determinism, mutable references and many others [23, 2]. Handlers prove to be extremely versatile and can express stream redirection, transactional memory, backtracking, cooperative multi-threading, delimited continuations, and, like monads, give programmers a way to define their own. And as handlers eliminate effects, they make the effect system non-monotone, which helps with the above issue of a snowballing output. 2012 ACM CCS: [Theory of computation]: Semantics and reasoning—Program reasoning—Program analysis.
منابع مشابه
Inferring Type Isomorphisms Generically — With an application to an XML Schema–Haskell data binding
1 1 Introduction Typed functional languages like Haskell [35] and ML [24,33] typically support the declaration of user-defined, polymorphic algebraic datatypes. In Haskell, for example, we might define a datatype representing dates in a number of ways. The most straightforward and conventional definition is probably the one given by Date below,
متن کاملType Derivation Using the Projection Operation
We present techniques for deriving types from existing object-oriented types using the rela-tional algebraic projection operation and for inferring the methods that are applicable to these types. Such type derivation occurs, for example, as a result of deening algebraic views over object types. We refactor the type hierarchy and place the derived types in the type hierarchy in such a way that t...
متن کاملOn Template-Based Inference of Rich Invariants in Leon
We present an approach for inferring rich invariants involving user-defined recursive functions over numerical and algebraic data types. In our approach, the developer provides the desired shape of the invariant using a set of templates. The templates are quantifier-free affine predicates with unknown coefficients. We also provide an enumeration based strategy for automatically inferring some o...
متن کاملComputing Array Shapes in MATLAB
This paper deals with the problem of statically inferring the shape of an array in languages such as MATLAB. Inferring an array’s shape is desirable because it empowers better compilation and interpretation; specifically, knowing an array’s shape could permit reductions in the number of run-time array conformability checks, enable memory preallocation optimizations, and facilitate the in-lining...
متن کاملA Dimension Reduction Method for Inferring Biochemical Networks
We present herein an extension of an algebraic statistical method for inferring biochemical reaction networks from experimental data, proposed recently in [3]. This extension allows us to analyze reaction networks that are not necessarily full-dimensional, i.e., the dimension of their stoichiometric space is smaller than the number of species. Specifically, we propose to augment the original al...
متن کاملFormalization of a Knowledge-based Approach for Representing and Learning Spatial Structure of a Large-scale Space
This paper has outlined the formalization of learning and representing human movement in a street network as a large scale space. The proposed approach is based on development of a DSS for spatial commonsense knowledge management. Learning the large-scale structure, the traveler must necessarily build a cognitive map of the environment by integrating observations over extended periods of time, ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Logical Methods in Computer Science
دوره 10 شماره
صفحات -
تاریخ انتشار 2013