Questions tagged [subtype]

198 questions
180
votes
6 answers

Designer Added then removed by Visual Studio on load/unload

Anyone see this before? I have a large Visual Studio project that keeps adding [Subtype]Designer[/Subtype] to my .vcproj then removing it on the next open and close of the project. There is only one class defined in StoredImageControl.cs. Anyone…
Jeff Lundstrom
  • 1,811
  • 2
  • 11
  • 5
59
votes
2 answers

Impredicative types vs. plain old subtyping

A friend of mine posed a seemingly innocuous Scala language question last week that I didn't have a good answer to: whether there's an easy way to declare a collection of things belonging to some common typeclass. Of course there's no first-class…
48
votes
2 answers

Why is PartialFunction <: Function in Scala?

In Scala, the PartialFunction[A, B] class is derived from type Function[A, B] (see Scala Reference, 12.3.3). However, this seems counterintuitive to me, since a Function (which needs to be defined for all A) has more stringent requirements than a…
jpalecek
  • 44,865
  • 7
  • 95
  • 139
27
votes
2 answers

How does `isInstanceOf` work?

Assume, we have: class B class A extends B trait T Then it holds: val a: A with T = new A with T a.isInstanceOf[B] // result is true ! Is it right to say, the isInstanceOf method checks, if there is at least one type (not all types) which…
John Threepwood
  • 14,225
  • 25
  • 81
  • 141
20
votes
3 answers

How to eliminate subtype dependency?

In the example below I have written one to_str() function and one set() procedure for every pls_integer subtype. The functions and procedures are almost identical except the type. How I can eliminate the need to write yet another to_str() and set()…
user272735
  • 9,795
  • 8
  • 57
  • 86
19
votes
6 answers

In what ways are subtypes different from subclasses in usage?

A subtype is established when a class is linked by means of extending or implementing. Subtypes are also used for generics. How can I differentiate subtyping from subclasses?
Oh Chin Boon
  • 21,393
  • 45
  • 133
  • 208
15
votes
1 answer

What are the alternatives to subtype polymorphism in scala?

I'm interested to know the complete set of alternatives to subtype polymorphism in scala.
Channing Walton
  • 3,737
  • 1
  • 27
  • 55
12
votes
5 answers

How do I apply subtypes into an SQL Server database?

I am working on a program in which you can register complaints. There are three types of complaints: internal (errors from employees), external (errors from another company) and supplier (errors made by a supplier). They hold different data which…
Fusyion
  • 704
  • 1
  • 11
  • 23
12
votes
4 answers

Is List a subtype of List and why?

Here is what I know: Double is a subtype of Number and List is not a subtype of List. List is not a subtype of List because you can add Cat to List but you can't do that with List. List
kahofanfan
  • 297
  • 1
  • 10
12
votes
1 answer

Parse to a Subclass by default with Jackson

I have a class called Product and some subclasses extending it. Now in my annotations I have many types, like this: @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.WRAPPER_OBJECT) @JsonSubTypes({@Type(value=RoomProduct.class,…
Tomás Duhourq
  • 143
  • 1
  • 1
  • 8
10
votes
2 answers

have perl6 invoke the right multi sub specialized by subtype(subset)

I have a type hierarchy constructed with perl6's subset command and some multi subs specialized on these type. How to give the highest precedence to the sub specialized by the most narrow subtype when multi dispatch happens? Here is the simplified…
lovetomato
  • 861
  • 3
  • 11
9
votes
1 answer

What is the difference between type class dependence in haskell and sub typing in OOP?

We often use type class dependence to emulate the sub typing relationship. e.g: when we want to express the sub typing relationship between Animal, Reptile and Aves in OOP: abstract class Animal { abstract Animal move(); abstract Animal…
luochen1990
  • 3,124
  • 1
  • 16
  • 30
9
votes
2 answers

Subtype in Scala: what is "type X <: Y"?

Can anyone explain the subtype(<:) in the following code? Why it could be used like that? When we use that? Thanks. trait SwingApi { type ValueChanged <: Event val ValueChanged: { def unapply(x: Event): Option[TextField] } …
yuefengz
  • 3,118
  • 1
  • 13
  • 24
8
votes
1 answer

What is an Isabelle/HOL subtype? What Isar commands produce subtypes?

I'd like to know about Isabelle/HOL subtypes. I explain a little about why it's important to me in my partial answer to my last SO question: Trying to Treat Type Classes and Sub-types Like Sets and Subsets Basically, I only have one type, so it…
user2190811
6
votes
0 answers

Argonaut CodecJson and decoding subtypes

In the Argonaut DecodeJson trait there is a method ||| for chaining together decoders, so that the first succeeding decoder is chosen. There is also a similar method in DecodeResult which has the same effect. It looks at first glance as though one…
Robin Green
  • 29,408
  • 13
  • 94
  • 178
1
2 3
13 14