Skip to main content

Questions tagged [type-inference]

For questions about type inference, where the types of expressions, variables, or functions are automatically determined by the compiler or interpreter without complete explicit type annotations

Filter by
Sorted by
Tagged with
6 votes
1 answer
119 views

Understanding the "operational" reading of typing judgements in PFPL by Robert Harper, Chapter 4 Statics

I'm reading Practical Foundations for Programming Languages by Robert Harper and am confused by the exercises in Chapter 4, "Statics", where he discusses a (monomorphic) type system. The ...
Jay Lee's user avatar
  • 223
1 vote
1 answer
273 views

Type-checking Python vs Typescript

mypy is very slow, pyright is fast but not quick enough in a large codebase, and tsc gives an immediate intellisense and type errors. I do not know whether it is because Python has more complex type ...
mq7's user avatar
  • 113
5 votes
1 answer
317 views

Can final and full lattice type theory be combined?

Let us assume a language that has final with Java semantics, i.e. a final type cannot have subtypes. Further, let that language have a full lattice type theory with at least one bottom type, e.g. ...
feldentm's user avatar
  • 1,779
0 votes
1 answer
151 views

What are pros and cons of return type deduction? [closed]

I added return type deduction to my (strongly and statically typed) language, but now I'm kind of concerned that it may not be a good thing. My language has no function declarations separate from the ...
chrysante's user avatar
  • 778
6 votes
6 answers
922 views

What are the consequences of allowing decimal-point-less number literals to be interpreted as floats?

In some languages, a number literal's type can be inferred from nearby expressions. For example, 1u64 + 2 might give a u64 value ...
Rydwolf Programs's user avatar
4 votes
1 answer
319 views

Determining the most optimized data type for the platform with type inference

For my programming language, I have built an engine that goes after the parser and before the compiler. This engine analyzes, validates, and simplifies the AST. During the analasys, it determines as ...
Hg0428's user avatar
  • 173
10 votes
3 answers
2k views

Is a unification algorithm overkill for local type inference?

I'd like to create a type system similar to the one in Swift or Kotlin, where you have top-level functions that declare their parameters and return types, but you have some type inference with local ...
Rob N's user avatar
  • 1,083
13 votes
1 answer
299 views

Extending Hindley Milner with (mutual) recursion

What's a good approach for extending Hindley Milner with mutual recursion without de-sugaring to let+fix+records? My thinking is (assuming no polymorphic recursion) Collect mutually recursive lets ...
aindurti's user avatar
  • 231
16 votes
2 answers
1k views

What are the other potential downsides, if any, of making `<$>` and `<*>` (but not `pure`) implicit?

Here, <$> is the infix functor map operation with type Functor f => (a -> b) -> f a -> f b for any functor ...
Wheelwright's user avatar
18 votes
4 answers
3k views

When do we need complex type inference?

Two of the most significant type inference schemes are Hindley-Milner and Bidirectional typing but when do we actually need do type inference? The simple case is something like: ...
Bruce Adams's user avatar
  • 2,843
8 votes
1 answer
345 views

What are the key steps to compiling a custom programming language that is similar to Rust (typechecking, type inference, and borrow checking)?

I have been working on a custom programming language for a bit, and keep coming back to the fact that I am not easily visualizing in my mind how the compiler will work past the step of creating the ...
Lance's user avatar
  • 705
10 votes
1 answer
361 views

What are some options for integrating subtyping with Damas-Hindley-Milner inference?

Type inference in a Damas-Hindley-Milner type system with subtyping is known to be undecidable in general. What makes it so difficult? What options are there to get around undecidability which could ...
Pseudonym's user avatar
  • 4,706
6 votes
4 answers
291 views

How do languages handle bitwise flags?

In most languages, enum types intersect with number types, implicitly converting between them so you can do ...
Hydroper's user avatar
  • 1,017
14 votes
4 answers
428 views

How can I infer the type of an empty literal?

I have a language like this: var s is str ""; var l is list[int] []; var m is map[int]str {}; where [] is ...
bigyihsuan's user avatar
  • 1,821