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
15 votes
3 answers
767 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 ...
8 votes
3 answers
420 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 ...
6 votes
1 answer
211 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: ...
8 votes
0 answers
127 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 ...
5 votes
3 answers
224 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 ...