BookPDF Available

Gentle Introduction to Dependent Types with Idris

  • University of Tourism and Management Skopje


Dependent types are a powerful concept that allows us to write proof-carrying code. Idris is a programming language that supports dependent types. We will learn about the mathematical foundations, and then write correct software and mathematically prove properties about it.This book aims to be accessible to novices that have no prior experience beyond high school mathematics. Thus, this book is designed to be self-contained.The first part of this book serves as an introduction to the theory behind Idris, while the second part is a practical introduction to Idris with examples.
A preview of the PDF is not available
... Having in mind that, in the real theory, we are not restricted to attributing only ordinary integers and the number of attributions is not fixed, we would need to extend our meta-theory to work with these terms too. In contrast, when we attribute those to types, what we get are types parametrized with terms -and this is what we are obviously familiar with -dependent types ( [6,7,8])! Of course, they are not purely dependent types, since they are required to capture some other data too, but instead can be seen as a special case of ones or just a similar concept. ...
Full-text available
In type theory, we can express many practical ideas by attributing some additional data to expressions we operate on during compilation. For instance, some substructural type theories augment variables' typing judgments with the information of their usage. That is, they allow one to explicitly state how many times - 0, 1, or many - a variable can be used. This solves the problem of resource usage control and allows us to treat variables as resources. What's more, it often happens that this attributed information is interpreted (used) during the same compilation and erased before we run a program. A case in the point is that in the same substructural type theories, their type checkers use these 0, 1, or many, to ensure that all variables are used as many times as these attributions say them to be. Yet, there wasn't any programming language concept whose concern would be to allow a programmer to express these attributions in the language itself. That is, to let the programmer express which data the one wants to attribute to what expressions and, most importantly, the meaning of the attributed data in their program. As it turned out, the presence of such a concept allows us to express many practical ideas in the language itself. For instance, with appropriate means for assigning the meaning of these attributions, this concept would allow one to express linear types as functionality in a separate program module, without the need to refine the whole type system to add them. In this paper, we present such a concept - we propose type properties. It allows a programmer to express these attributions while fulfilling the requirement of being fully on the static level. That is, it allows one to express how to interpret these attributions during compilation and erases them before a program is passed to the runtime.
Propositions as Types is closely related to the BHK Interpretation, a view of logic developed by the intuitionists Brouwer, Heyting, and Kolmogorov in the 1930s. It is often referred to as the Curry-Howard isomorphism, referring to a correspondence observed by Curry in 1934 and refined by Howard in 1969. It applies to a range of logics, including propositional, predicate, second-order, intuitionistic, classical, modal, and linear. It underpins the foundations of functional programming, explaining features including functions, records, variants, parametric polymorphism, data abstraction, continuations, monads, linear types, and session types. Propositions as Types tell us lambda calculus is isomorphic to natural deduction. It seems difficult to conceive of alien beings who do not know the fundamentals of logic, and we might expect the problem of deciphering a program written in lambda calculus to be closer to the problem of understanding the radial diagram of pulsars.
We present the type rules for a dependently-typed core calculus to- gether with a straightforward implementation in Haskell. We ex- plicitly highlight the changes necessary to shift from a simply- typed lambda calculus to the dependently-typed lambda calculus. We also describe how to extend our core language with data types and write several small example programs. The paper is accom- panied by an executable interpreter and example code that allows immediate experimentation with the system we describe.
Cambridge Core - Algorithmics, Complexity, Computer Algebra, Computational Geometry - How to Prove It - by Daniel J. Velleman
Learn You a Haskell for Great Good
  • M Lipovaca
Lipovaca, M., Learn You a Haskell for Great Good, 2011