Questions tagged [type-checking]
verifying that a variable, expression or value has the declared type
80
questions
2
votes
2answers
36 views
Are type variables really only used in mathematical conversation about types?
Are type variables really only used in mathematical conversation about types? i.e. are type variables (meta-variables that only contain the type classification label) only exist in proofs for types ...
0
votes
1answer
56 views
What is the difference between $ \alpha \to \alpha $ vs $ \forall \alpha. \alpha \to \alpha$?
I was studying polymorphic types and I was finding the distinction with monomorphic types difficult to pin down (context CS 421). From the course I linked the have the following (vague attempt) at a ...
5
votes
1answer
73 views
What does $ \forall \alpha_1, \dots , \alpha_n . \tau $ mean formally as a type?
I was learning about polymorphic types but I couldn't understand the notation, can someone explain it means (context cs421 UIUC):
$$ \forall \alpha_1, \dots , \alpha_n . \tau $$
its supposed to be a ...
9
votes
1answer
1k views
Why does Coq include let-expressions in its core language
Coq includes let-expressions in its core language.
We can translate let-expressions to applications like this:
let x : t = v in b ~> (\(x:t). b) v
I understand ...
8
votes
1answer
462 views
Representation of the concatenation at the type level
I would like to learn more about concatenative programming through the creation of a small simple language, based on the stack and following the concatenative paradigm.
Unfortunately, I haven't found ...
2
votes
0answers
37 views
Real world example of contraction and weakening
Can you provide me a real world example of contraction and weakening in the type system of a popular language like Java, Kotlin, etc.? I heard that Rust has got explicit contraction but I don´t ...
3
votes
0answers
89 views
Type inference for System F-omega
There have been some nice papers about simple type inference for System F: "HMF: Simple Type Inference for First-Class Polymorphism", "Practical type inference for arbitrary-rank types", and "Complete ...
12
votes
5answers
1k views
Is there any use case for the bottom type as a function parameter type?
If a function has return type of ⊥ (bottom type), that means it never returns. It can for example exit or throw, both fairly ordinary situations.
Presumably if a function had a parameter of type ⊥ it ...
1
vote
1answer
34 views
Add type checking/inference to my programming language
I am currently creating my own compiled programming language, and I have come to a point where I would like to start working on the type system and introduce some type checking. Ideally I would like ...
1
vote
0answers
36 views
How does C++'s type checking work when passing overloaded or templated functions as parameter
As I understand, C++ in general features 'one-way' type checking. That is checking the sub-expressions and get their types, and see if the types so far satisfy the constraints imposed by the current ...
4
votes
2answers
136 views
Check if a lambda constructor is well-typed
In basic type inference for 𝜆-calculus with parametric polymorphism à la Hindley–Milner,
when can we say that we cannot give a type to a lambda constructor?
For example
$$(λx.λy.y(x\ ...
4
votes
0answers
41 views
Static type analysis with dynamic scoping?
Both in school and out, I have only ever encountered dynamic scoping paired with dynamic typing. Is there any published work (even if just academic, not yet implemented in a "real" programming ...
6
votes
1answer
70 views
Type system with subtyping on abstract data types?
Consider this example on binary trees in some ML-like language:
...
2
votes
0answers
32 views
Question about let syntax in type systems
I'm on the Wikipedia page for Hindley-Milner type systems, on the section about "let polymorphism": https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system#Let-polymorphism
I'm a bit ...
2
votes
0answers
25 views
How does the free program identifiers (fpi) extend over constraints and type schemes in $HM(X)$?
Chapter 10 of Advanced Topics in Types and Programming Languages; gives a very comprehensive description of type inference by constraints solving.
They introduce the free program indentifiers of an ...
3
votes
1answer
299 views
Drawbacks of adding type equality to 1ML
In the 1ML – Core and Modules United (F-ing First-Class Modules) paper, the author gives the following example for why module types do not form a lattice under subtyping:
...
6
votes
2answers
228 views
LET REC recursive expression static typing rule
I'm taking a programming languages course and had a question regarding the typing rules for a recursive let rec expression in a static typing system.
To be more ...
1
vote
0answers
44 views
Propositional extentionality in the lean theorem prover?
Propositional extentionality in the lean theorem prover is stated as the following axiom:
axiom proptext {a b : Prop} : (a $\iff$ b) \to a = b
My confusion about this is as follows: Previously I’...
2
votes
0answers
66 views
Relation between “formal verification”, “formal proof”, and “type systems” for software verification?
I have a vague understanding what formal verification is about, a vague understanding of what the cutting edge is of type theory for programming languages, and a better understanding of formal proofs.
...
2
votes
0answers
35 views
What is the difference between ADTs and ASDLs?
ASDL stands for Abstract Syntax Description Language (ASDL), whereby ADT stands for Algebraic data type.
By looking at Python.asdl it appears to me to be the same thingy, just with different names, ...
5
votes
1answer
70 views
Type system for Query DSL with only simple GADTs: what typing judgments are needed?
Background
I have several F# codebases with reasonably high level of complexity of code. In order to convince myself that the code is solid I do whatever I can to write as much of it as possible type-...
1
vote
2answers
98 views
Symbolic Evaluation for Type Inference in a Dynamic Language
Say I have the following contrived example code:
...
2
votes
1answer
119 views
Assertion of Type Inference Rules/Type Checking
I have a problem in a book I am trying to accomplish.
I understand the overall type of the expression is boolean and how it derives. (y * x) will be rule 4 (counting from top right). (y * x) + x when ...
2
votes
1answer
74 views
What is the type system (or class of type systems) that that ensures all your tree Branches end in Leaves?
I've come across this situation numerous times in the past few years where I have some classes like (pseudo-Java):
...
11
votes
2answers
187 views
Reducing products in HoTT to church/scott encodings
So I am currently going though the HoTT book with some people. I made the claim that most inductive types we will see can be reduced to types containing only dependent function types and universes by ...
8
votes
1answer
2k views
Is there a difference between type safety and type soundness?
I've been trying to tease apart the definitions of type safety and type soundness and I'm having a heck of a time of it. I asked a professor recently and after a bit of thought he said that there ...
4
votes
1answer
148 views
Linear/affine lifetimes without subtyping
Are there any type systems similar to rust that don't depend on subtyping ? Can we express that one value must be consumed or dropped before another? For instance if I had an array of huge values on ...
4
votes
1answer
82 views
What's the advantage of “value restriction” over its alternatives?
What is the motivation to pick "value restriction" over other candidates?
Examples of alternatives:
Enclosing pureness into the function type, for example:
...
8
votes
0answers
249 views
Type-classes for type inference
I'm creating a semantic analyzer with type inference. For the basics I've got a type variable and a type construct with name and a list of types.
I want to support overloading and I know that Haskell ...
7
votes
2answers
655 views
Higher-ranked polymorphism without explicit application or subtyping?
So, I'm familiar with two main strategies of having higher-ranked polymorphism in a language:
System-F style polymorphism, where functions are explicitly typed, and instantiation happens explicitly ...
8
votes
2answers
866 views
Relation between type-checking decidability, typability decidability and strong normalization
Yo! This is probably a stupid question, however I've never seen it written down explicitly if, for instance, decidability of type-checking is equivalent to the strong normalization property. Therefore ...
6
votes
2answers
348 views
What's the advantage of typed assembly?
I've seen scattered references to typed assembly in high assurance literature, but I don't really understand the advantage.
If the compiler/runtime are capable of passing the types down to the CPU, ...
3
votes
2answers
288 views
Which type compilers report if they cannot infer a precise type?
In the presence of subtyping, a type checker can usually infer only some inequality constraints on the type rather than the exact type. Of course, internally it will store the full constraints. But ...
5
votes
1answer
97 views
Local type argument synthesis when type variable does not appear in arguments
I am implementing the techniques described in the classic Local Type Inference paper. Specifically, I am implementing the type argument synthesis algorithm from section 3.
My algorithm seems to ...
2
votes
0answers
97 views
Dependent types as regular expressions
Would be possible to encode dependent types as regular expressions? if so, ¿is there some work about?
It's common to represent restrictions for elements in a traversable data structure with them, ...
7
votes
1answer
284 views
Reference request: optimizing procedures on lists in dynamic languages by performing safety checks in advance
For my science fair project, I implemented an optimization to Python's sort routine. The idea is to move the safety checks that have to be carried out during each comparison, e.g. type checks and ...
3
votes
2answers
58 views
how to use type application rule (T-TAPP)?
In the following rule,
$$\dfrac{ \Gamma \vdash t_1 : \forall X.T_{12} }
{ \Gamma \vdash t_1 \ [T_2] : [X \mapsto T_2]T_{12} }
\textsf{ (T-TApp)}$$
whend doing type checking, how ...
4
votes
1answer
80 views
How to understand these exposure algorithm rules for System F sub?
The book "Types and Programming Languages" said System F sub type checking introduce exposure typing rules alongside algorithmic typing and sub-typing rules.
...
3
votes
1answer
271 views
Algebraic data types - unions
Are there any programming languages where algebraic data types can be expressed not only by using intersection and disjoint union but also a standard set union (intersection + disjoint union)?
Do ...
3
votes
1answer
178 views
how type checking fails?
I was doing a type checking example in system f sub on paper to understand how it works.
according to Pierce's book Types and Programming Languages, numbers and their types are following in system f ...
8
votes
1answer
196 views
Relation between Type Assignment system (TA) and Hindley-Milner system
Recently I started my studies in type theory/type systems and Lambda Calculus.
I have already read about Simple Typed Lambda Calculus in Church and Curry style. The last one is also known as Type ...
6
votes
1answer
207 views
Safe way to explicitly define new types instead of using Algebraic data types for my functional language
Question:
As I'm working on a Hindley-Milner typed lambda calculus, in order to make it usable I need to add some types such as list and pairs. The way I currently do it is, I have an ...
3
votes
2answers
137 views
Get term type during evaluation using Hindley-Milner type system
I've implemented a lambda calculus evaluator and use the Hindley-Milner algorithm to infer terms types and ensure type correctness without the user having to explicitly annotate types.
But now I'd ...
5
votes
1answer
175 views
Does Damas-Milner still have principal types if existential type schemata are added?
In the Damas-Milner type system, type schemata can be formed in two ways:
$T$
$\forall X. S$
Where $T$ ranges over monotypes and $S$ ranges over type schemata. The type-checking algorithm for this ...
3
votes
2answers
494 views
System f-sub, how to do type checking?
I was reading that system f-sub (polymorphic lambda calculus with sub-typing) and I was quite confused with its one checking rule called "T-TAPP".
This rule as following (ctx denotes the typing ...
0
votes
0answers
398 views
Type inference and Type checking
I understand that adding the annotations (dependent typing) may cause the type checking of the programming language to become undecidable.
What about type inference ?
Whether type checking and type ...
5
votes
1answer
244 views
Proving preservation under substitution System F Omega
I am going over the proofs for the simply typed lambda calculus in the book "Types and Programming languages" by Benjamin Pierce. I am trying to find inspiration for the similar proofs for System F ...
5
votes
2answers
373 views
Decidability of dependent typing on primitive recursive languages
With a dependent type system in a normal functional language type checking may never halt. This is partially because dependent typing removes the isolation between types, and code. My question is this:...
2
votes
0answers
26 views
Where does the term “Amechanicity” for type-error generation come from
I've been looking at these slides about improving type error messages for programming languages.
One of the things they describe, starting at Slide 8, is the concept of amechanicity. Anytime the ...
2
votes
1answer
70 views
Confusion about data types, compilers, hardware data representation and static vs dynamic typing
I am trying to understand static vs dynamic typing, but am really struggling to see how everything fits together.
It all starts with data types. As far as I understand, data types are quite abstract ...