Skip to main content

Questions tagged [algebraic-data-types]

For questions about algebraic data types, a language feature for creating composite types and values of them. Specific questions may also want to use the sum-types or product-types tags.

Filter by
Sorted by
Tagged with
8 votes
2 answers
357 views

How are algebraic data types implemented?

I'm trying to make a simple compiler, and am getting stuck with IR code generation for lists in my language. I asked around and learned about algebraic data types and how they work, but I can't seem ...
NotAlfred's user avatar
  • 145
8 votes
1 answer
298 views

Can total (primitive) corecursion be implemented?

I'm trying to understand how to implement corecursion in a total functional context. I've already implemented recursion using standard techniques (for loops) but I ...
Corbin's user avatar
  • 851
15 votes
3 answers
803 views

Towards a better default listlike datastructure for functional languages

In most functional languages I know of, linked lists are the default datastructure of choice for many operations. The benefits are clear - they're clearly encoded with ADTs, and can be utilised easily ...
blueberry's user avatar
  • 2,455
8 votes
3 answers
516 views

How to incorporate sum types into SQL?

The blog post states that a major drawback of SQL is its lack of sum type support. Assuming we could redesign SQL today (without necessarily having to worry about compatibility) what are some specific ...
Jw C's user avatar
  • 231
8 votes
0 answers
136 views

How does GADTs as in Haskell-like languages compare to indexed families in dependent types?

In Haskell, GADTs are only indexed by types, while indexed families in DT are mainly indexed by terms. With the presence of without-K, it is hard to refute cases just by unifying type terms, while in ...
ice1000's user avatar
  • 2,424
6 votes
1 answer
241 views

Are there disadvantages to having subtypes of algebraic data types?

Many languages support algebraic data types which are essentially tagged unions of tuples or structs. For example, suppose we have a type for an expression node in an AST: ...
kaya3's user avatar
  • 19.1k
5 votes
3 answers
269 views

What is implied by the names "sum type" and "product type"?

Algebraic data types include two concepts with names that feel like they imply something clever, but that I can't for the life of me understand: Sum type: This refers to tagged unions, like Rust's ...
Rydwolf Programs's user avatar