38 research outputs found

    Fighting bit Rot with Types (Experience Report: Scala Collections)

    Get PDF
    We report on our experiences in redesigning Scala\u27s collection libraries, focussing on the role that type systems play in keeping software architectures coherent over time. Type systems can make software architecture more explicit but, if they are too weak, can also cause code duplication. We show that code duplication can be avoided using two of Scala\u27s type constructions: higher-kinded types and implicit parameters and conversions

    Dependent Object Types

    Get PDF
    We propose a new type-theoretic foundation of Scala and languages like it: the Dependent Object Types (DOT) calculus. DOT models Scala’s path-dependent types, abstract type members and its mixture of nominal and structural typing through the use of reïŹnement types. The core formalism makes no attempt to model inheritance and mixin composition. DOT normalizes Scala’s type system by unifying the constructs for type members and by providing classical intersection and union types which simplify greatest lower bound and least upper bound computations. In this paper, we present the DOT calculus, both formally and informally. We also discuss our work-in-progress to prove typesafety of the calculus

    As formas de expressĂąo do preconceito na infĂąncia

    Get PDF
    Dissertação de Mestrado apresentada ao Instituto Superior de Psicologia Aplicada para obtenção de grau de Mestre na especialidade de Psicologia Educacional.O objectivo deste estudo Ă© verificar de que forma a idade das crianças influencia a forma de expressĂŁo de preconceito das mesmas, ou seja, de que forma se expressa o preconceito na infĂąncia, em dois grupos diferentes de idade (seis/sete anos e nove/dez anos), esperando-se que as crianças mais novas expressem o preconceito de forma directa e as mais velhas de forma indirecta, por terem interiorizado a norma social vigente anti-racista. Este estudo Ă© experimental, tendo sido recolhida uma amostra de 120 participantes de uma escola homogĂ©nea da regiĂŁo de Cascais. Para testar as hipĂłteses colocadas recorreu-se a ANOVAS e ao Teste de ScheffĂ© (comparação mĂșltipla de mĂ©dias). Desta forma, observa-se que, ao contrĂĄrio do que se tinha proposto, tanto as crianças mais novas como as crianças mais velhas expressam-se de forma indirecta no que diz respeito ao preconceito face a indivĂ­duos negros, ou seja, estas crianças sĂŁo justas na distribuição de recursos, mas por exemplo, as crianças mais novas ao colocarem-se no papel de outro, como a mĂŁe e o melhor amigo, jĂĄ expressam o racismo de forma indirecta. Deve ainda referir-se que as crianças mais novas e mais novas seguem a norma social do pai.The goal of this study is to determine how children’s age influences their way of expressing prejudice, or in other words, how prejudice is expressed in childhood, in two different age groups (six/seven and nine/ten years hold), expecting that younger children will expressed directly prejudice, and the oldest children indirectly, because they have already internalized the social norm of anti-racism. This is an experimental study, with a sample of 120 participants from one homogeneous school in the Cascais area. In order to test the hypothesis, ANOVAS and ScheffĂ© test (multiple comparison of averages), were used. In spite of what was initially proposed, it was observed that both younger and older children express their prejudice towards black individuals in an indirect way. Thus, these children distributed the resources with justice, but for example, younger children express an indirect racism when assuming the role of their mother or the role of their best friend. Both younger and older children tend to follow the social norm of their father

    Scala-Virtualized: Linguistic Reuse for Deep Embeddings

    Get PDF
    Scala-Virtualized extends the Scala language to better support hosting embedded DSLs. Scala is an expressive language that provides a flexible syntax, type-level computation using implicits, and other features that facilitate the development of em- bedded DSLs. However, many of these features work well only for shallow embeddings, i.e. DSLs which are implemented as plain libraries. Shallow embeddings automatically profit from features of the host language through linguistic reuse: any DSL expression is just as a regular Scala expression. But in many cases, directly executing DSL programs within the host language is not enough and deep embeddings are needed, which reify DSL programs into a data structure representation that can be analyzed, optimized, or further translated. For deep embeddings, linguistic reuse is no longer automatic. Scala-Virtualized defines many of the language’s built-in constructs as method calls, which enables DSLs to redefine the built-in semantics using familiar language mechanisms like overloading and overriding. This in turn enables an easier progression from shallow to deep embeddings, as core language constructs such as conditionals or pattern matching can be redefined to build a reified representation of the operation itself. While this facility brings shallow, syntactic, reuse to deep embeddings, we also present examples of what we call deep linguistic reuse: combining shallow and deep components in a single DSL in such a way that certain features are fully implemented in the shallow embedding part and do not need to be reified at the deep embedding level

    Squid: Type-Safe, Hygienic, and Reusable Quasiquotes

    Get PDF
    Quasiquotes have been shown to greatly simplify the task of metaprogramming. This is in part because they hide the data structures of the intermediate representation (IR), instead allowing metaprogrammers to use the concrete syntax of the language they manipulate. Scala has had ``syntactic'' quasiquotes for a long time, but still misses a statically-typed version like in MetaOCaml, Haskell and F#. This safer flavor of quasiquotes has been particularly useful for staging and domain-specific languages. In this paper we present Squid, a metaprogramming system for Scala that fills this gap. Squid quasiquotes are novel in three ways: they are the first statically-typed quasiquotes we know that allow code inspection (via pattern matching); they are implemented purely as a macro library, without modifications to the compiler; and they are reusable in the sense that they can manipulate different IRs. Adapting (or binding) a new IR to Squid is done simply by implementing a well-defined interface in the style of object algebras (i.e., tagless-final). We detail how Squid is implemented, leveraging the metaprogramming tools already offered by Scala, and show three application examples: the definition of a binding for a DSL in the style of LMS; a safe ANF conversion; and the introduction of type-safe, hygienic macros as an alternative to the current macro system

    Type Constructor Polymorphism for Scala: Theory and Practice (Type constructor polymorfisme voor Scala: theorie en praktijk)

    No full text
    A static type system is an important tool in efficiently developing correct software. We describe the theoretical underpinnings as well as the practical side of our extension of Scala's type system. More concretely, we generalised Scala's support for parametric polymorphism -- typically called "genericity" in object-oriented languages -- to the higher-order case. We call the result "type constructor polymorphism", as Scala programmers may now safely abstract over type constructors. This generalisation, amplified by the synergy with Scala's existing features such as implicits, represents an important asset in the library designer's abstraction-building tool belt, while the user of these abstractions need not worry about their inner workings. The theoretical side of the story focusses on the lacunae in the existing Scala formalisms, and presents our core calculus that solves these. Finally, we elaborate on our vision for future improvements of the type system, based on our practical experience with type constructor polymorphism.status: publishe

    Fighting bit rot with types

    No full text
    We report on our experiences in redesigning Scala's collection libraries, focussing on the role that type systems play in keeping software architectures coherent over time. Type systems can make software architecture more explicit but, if they are too weak, can also cause code duplication. We show that code duplication can be avoided using two of Scala's type constructions: higher-kinded types and implicit parameters and conversions.status: publishe

    Generics of a Higher Kind

    No full text
    Abstract. With Java 5 and C # 2.0, first-order parametric polymorphism was introduced in mainstream object-oriented programming languages under the name of generics. Although the first-order variant of generics is very useful, it also imposes some restrictions: it is possible to abstract over a type, but the resulting type constructor cannot be abstracted over. This can lead to code duplication. We removed this restriction in Scala, by allowing type constructors as type parameters and abstract types. This paper presents the design and implementation of the resulting type constructor polymorphism. It combines type constructor polymorphism with implicit parameters to yield constructs similar to, and at times more expressive than, Haskell’s constructor type classes. The paper also studies interactions with other object-oriented language constructs, and discusses the gains in expressiveness.
    corecore