113 research outputs found

    No Unification Variable Left Behind: Fully Grounding Type Inference for the HDM System

    Get PDF
    The Hindley-Damas-Milner (HDM) system provides polymorphism, a key feature of functional programming languages such as Haskell and OCaml. It does so through a type inference algorithm, whose soundness and completeness have been well-studied and proven both manually (on paper) and mechanically (in a proof assistant). Earlier research has focused on the problem of inferring the type of a top-level expression. Yet, in practice, we also may wish to infer the type of subexpressions, either for the sake of elaboration into an explicitly-typed target language, or for reporting those types back to the programmer. One key difference between these two problems is the treatment of underconstrained types: in the former, unification variables that do not affect the overall type need not be instantiated. However, in the latter, instantiating all unification variables is essential, because unification variables are internal to the algorithm and should not leak into the output. We present an algorithm for the HDM system that explicitly tracks the scope of all unification variables. In addition to solving the subexpression type reconstruction problem described above, it can be used as a basis for elaboration algorithms, including those that implement elaboration-based features such as type classes. The algorithm implements input and output contexts, as well as the novel concept of full contexts, which significantly simplifies the state-passing of traditional algorithms. The algorithm has been formalised and proven sound and complete using the Coq proof assistant

    Cr\`eme de la Crem: Composable Representable Executable Machines (Architectural Pearl)

    Full text link
    In this paper we describe how to build software architectures as a composition of state machines, using ideas and principles from the field of Domain-Driven Design. By definition, our approach is modular, allowing one to compose independent subcomponents to create bigger systems, and representable, allowing the implementation of a system to be kept in sync with its graphical representation. In addition to the design itself we introduce the Crem library, which provides a concrete state machine implementation that is both compositional and representable, Crem uses Haskell's advanced type-level features to allow users to specify allowed and forbidden state transitions, and to encode complex state machine -- and therefore domain-specific -- properties. Moreover, since Crem's state machines are representable, Crem can automatically generate graphical representations of systems from their domain implementations

    The Thoralf Plugin: For Your Fancy Type Needs

    Get PDF
    Many fancy types (e.g., generalized algebraic data types, type families) require a type checker plugin. These fancy types have a type index (e.g., type level natural numbers) with an equality relation that is difficult or impossible to represent using GHC’s built-in type equality. The most practical way to represent these equality relations is through a plugin that asserts equality constraints. However, such plugins are difficult to write and reason about. In this paper, we (1) present a formal theory of reasoning about the correctness of type checker plugins for type indices, and, (2) apply this theory in creating Thoralf, a generic and extensible plugin for type indices that translates GHC constraint problems to queries to an external SMT solver. By “generic and extensible”, we mean the restrictions on extending Thoralf are slight, and, if some type index could be encoded as an SMT sort, then a programmer could extend Thoralf by providing this encoding function

    Pattern Synonyms

    Get PDF
    Pattern matching has proven to be a convenient, expressive way of inspecting data. Yet this language feature, in its traditional form, is limited: patterns must be data constructors of concrete data types. No computation or abstraction is allowed. The data type in question must be concrete, with no ability to enforce any invariants. Any change in this data type requires all clients to update their code. This paper introduces pattern synonyms, which allow programmers to abstract over patterns, painting over all the shortcomings listed above. Pattern synonyms are assigned types, enabling a compiler to check the validity of a synonym independent of its definition. These types are intricate; detailing how to assign a type to a pattern synonym is a key contribution of this work. We have implemented pattern synonyms in the Glasgow Haskell Compiler, where they have enjoyed immediate popularity, but we believe this feature could easily be exported to other languages that support pattern matching

    A generic algorithm for checking exhaustivity of pattern matching

    Get PDF
    Algebraic data types and pattern matching are key features of functional programming languages. Exhaustivity checking of pattern matching is a safety belt that defends against unmatched exceptions at runtime and boosts type safety. However, the presence of language features like inheritance, typecase, traits, GADTs, path-dependent types and union types makes the checking difficult and the algorithm complex. In this paper we propose a generic algorithm that decouples the checking algorithm from specific type theories. The decoupling makes the algorithm simple and enables easy customization for specific type systems

    Pharmacokinetics of high-dose oral thiamine hydrochloride in healthy subjects

    Get PDF
    Background: High dose oral thiamine may have a role in treating diabetes, heart failure, and hypermetabolic states. The purpose of this study was to determine the pharmacokinetic profile of oral thiamine hydrochloride at 100 mg, 500 mg and 1500 mg doses in healthy subjects. Methods: This was a randomized, double-blind, single-dose, 4-way crossover study. Pharmacokinetic measures were calculated. Results: The AUC010hrAUC_{0-10 hr} and CmaxC_{max} values increased nonlinearly between 100 mg and 1500 mg. The slope of the AUC010hrAUC_{0-10 hr} vs dose, as well as the CmaxC_{max} vs dose, plots are steepest at the lowest thiamine doses. Conclusion: Our study demonstrates that high blood levels of thiamine can be achieved rapidly with oral thiamine hydrochloride. Thiamine is absorbed by both an active and nonsaturable passive process

    Predicting Venous Thromboembolic Events in Patients with Coronavirus Disease 2019 Requiring Hospitalization: an Observational Retrospective Study by the COVIDIC Initiative in a Swiss University Hospital.

    Get PDF
    Coronavirus disease 2019 (COVID-19) can result in profound changes in blood coagulation. The aim of the study was to determine the incidence and predictors of venous thromboembolic events (VTE) among patients with COVID-19 requiring hospital admission. Subjects and Methods. We performed a retrospective study at the Lausanne University Hospital with patients admitted because of COVID-19 from February 28 to April 30, 2020. Among 443 patients with COVID-19, VTE was diagnosed in 41 patients (9.3%; 27 pulmonary embolisms, 12 deep vein thrombosis, one pulmonary embolism and deep vein thrombosis, one portal vein thrombosis). VTE was diagnosed already upon admission in 14 (34.1%) patients and 27 (65.9%) during hospital stay (18 in ICU and nine in wards outside the ICU). Multivariate analysis revealed D-dimer value > 3,120 ng/ml (P < 0.001; OR 15.8, 95% CI 4.7-52.9) and duration of 8 days or more from COVID-19 symptoms onset to presentation (P 0.020; OR 4.8, 95% CI 1.3-18.3) to be independently associated with VTE upon admission. D-dimer value ≥ 3,000 ng/l combined with a Wells score for PE ≥ 2 was highly specific (sensitivity 57.1%, specificity 91.6%) in detecting VTE upon admission. Development of VTE during hospitalization was independently associated with D-dimer value > 5,611 ng/ml (P < 0.001; OR 6.3, 95% CI 2.4-16.2) and mechanical ventilation (P < 0.001; OR 5.9, 95% CI 2.3-15.1). VTE seems to be a common COVID-19 complication upon admission and during hospitalization, especially in ICU. The combination of Wells ≥ 2 score and D - dimer ≥ 3,000 ng/l is a good predictor of VTE at admission

    Candesartan Attenuates Diabetic Retinal Vascular Pathology by Restoring Glyoxalase-I Function

    Get PDF
    This is an uncopyedited electronic version of an article accepted for publication in Diabetes. The American Diabetes Association, publisher of Diabetes, is not responsible for any errors or omissions in this version of the manuscript or any version derived from it by third parties. The definitive publisher-authenticated version will be available in a future issue of Diabetes in print and online a
    corecore