4 research outputs found

    A completely unique account of enumeration

    Get PDF
    How can we enumerate the inhabitants of an algebraic datatype? This paper explores a datatype generic solution that works for all regular types and indexed families. The enumerators presented here are provably both complete and unique—they will eventually produce every value exactly once—and fair—they avoid bias when composing enumerators. Finally, these enumerators memoise previously enumerated values whenever possible, thereby avoiding repeatedly recomputing recursive results

    Generic Deriving of Generic Traversals

    Get PDF
    Functional programmers have an established tradition of using traversals as a design pattern to work with recursive data structures. The technique is so prolific that a whole host of libraries have been designed to help in the task of automatically providing traversals by analysing the generic structure of data types. More recently, lenses have entered the functional scene and have proved themselves to be a simple and versatile mechanism for working with product types. They make it easy to focus on the salient parts of a data structure in a composable and reusable manner. This paper uses the combination of lenses and traversals to give rise to a library with unprecedented expressivity and flexibility for querying and modifying complex data structures. Furthermore, since lenses and traversals are based on the generic shape of data, this information is used to generate code that is as efficient as hand-optimised versions. The technique leverages the structure of data to produce generic abstractions that are then eliminated by the standard workhorses of modern functional compilers: inlining and specialisation

    Sovelluskohtaiset tyyppijärjestelmät

    Get PDF
    Type system tailored for specific domain could radically improve quality of the program. Many domains have natural types, yet they are difficult to encode in mainstream languages’ type systems. If the encoding is possible, it’s luckily to be very troublesome to work with. We investigate a single approach of developing domain specific type systems and type checking and inference algorithms for them, and apply it to MATLAB and JavaScript programs.Tyyppijärjestelmä, joka on suunniteltu tiettyä sovellusaluetta varten, voi mer- kittävästi parantaa sovelluksen laatua. Monilla sovellusalueilla on luonnollisia tyyppejä, joita ei ole helppo ilmaista yleiskäyttöisten ohjelmointikielten tyyp- pijärjestelmissä. Ja vaikka se olisikin mahdollista, koodaus ei ole välttämättä luonteva. Tässä tutkielmassa tarkastellaan erästä tapaa suunnitella ja toteuttaa sovelluskohtaisia tyyppijärjestelmiä ja niiden tyyppitarkistus- ja tyyppipäättely- algoritmeja. Sovellamme menetelmää Matlab- ja JavaScript-kielillä kirjoitettuihin ohjelmiin

    True sums of products

    No full text
    corecore