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
-1 votes
0 answers

Basic data types beside the common ones (int, char, long, ...) [closed]

Most languages have a defined set of core data types that are used as further building blocks within structs, objects and so on. Some of the more common ones are: functions, pointers, int, char, ...
johnworchester's user avatar
5 votes
1 answer

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,749
0 votes
1 answer

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
  • 748
5 votes
6 answers

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

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
  • 171
9 votes
3 answers

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,073
8 votes
0 answers

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
  • 181
16 votes
2 answers

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
17 votes
4 answers

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,793
8 votes
1 answer

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
  • 695
9 votes
1 answer

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,416
6 votes
4 answers

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
  • 909
13 votes
4 answers

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,663