Questions tagged [subtypes]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
4answers
87 views

How to relate summary to detail data objects?

My application I have two types of customers: individuals and business customers. My users sometimes need to be able to see the full details of one customer, but at other times they only need to see ...
0
votes
1answer
65 views

Implicit conversion for function subtyping

Languages with coercions (i.e. implicit type conversions) allows expressing things like that (irrespective of any syntax): f : int32 → int32 = λx.x+x a : int16 = 42 b : int64 = f(a) Where type ...
14
votes
4answers
4k views

How to handle the methods that have been added for subtypes in the context of polymorphism?

When you use the concept of polymorphism you create a class hierarchy and using parents reference you call the interface functions without knowing which specific type has the object. This is great. ...
7
votes
2answers
167 views

Are lower-arity functions subtypes of higher-arity ones?

I've found that there isn't a concept similar to "arity-based subtyping" in many languages that I've programmed in, where higher-order functions could consume functions of lower arity than their ...
7
votes
3answers
729 views

How are typeclasses in functional languages different from interfaces in OO languages?

I'm learning about paradigms of functional languages. So I've read that while Subtype polymorphism is typical for OO languages, Parametric polymorphism is typical for functional languages. But I ...
13
votes
2answers
1k views

Why is behavorial subtyping undecidable?

Liskov's work in this area focused on behavioral subtyping, which besides the type system safety discussed in this article also requires that subtypes preserve all invariants guaranteed by the ...
4
votes
2answers
380 views

Why is it bad to have one mechanism for inheritance and subtyping?

It is quite well-known that (class) inheritance and subtyping (sometimes called interface inheritance) are different things: inheritance is a mechanism for sharing code, while subtyping is a ...
7
votes
4answers
744 views

Heterogeneous Associations - Data Modeling When an Object that Must Relate to One of Many Classes

Suppose you have 3 classes: ClassA, ClassB and ClassC. Now suppose you have a class Message. You want a one-to-many relationship between each one of those three classes and the Message. The goal is ...