subtype이란 무엇인가?

F가 G의 서브타입이라면 G가 쓰일 자리에 F가 쓰여도 된다.

In programming language theory, subtyping (also subtype polymorphism or inclusion polymorphism) is a form of type
polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of
substitutability, meaning that program elements, typically subroutines or functions, written to operate on elements of
the supertype can also operate on elements of the subtype.

프로그래밍 이론에서 subtyping(subtype polymorphism, inclusion polymorphism이라고 불리는) 은 타입다형성의 한 형태이다. 상위타입으로 작성된 서브루틴이나 함수들이 하위타입을 대입해도 동일하게 하는 것을 서브타입이라고 부른다. 그냥 하나의 타입만 있을 때가 아닌 kind를 다룰 때 이 서브타입에 어떤 규칙들을 지켜야 하는지

https://softwareengineering.stackexchange.com/questions/255878/correct-terminology-in-type-theory-types-type-constructors-kinds-sorts-and-va

  • 값(value)
  • 타입(type)
  • 종류(kinds)
  • 타입생성자
  • 타입파라미터

covariant, countra-variant

https://typelevel.org/blog/2016/02/04/variance-and-functors.html

우리가 Generic을 만들 때 다음과 같은 개념들을 사용한다. T’이 T의 서브타입일 때 다음과 같이 정의된다.

키워드 의미 표기
covariant F[T'] 는 F[T]의 서브타입이다 [+T]
countravariant F[T] 는 F[T']의 서브타입이다. [-T]
invariant F[T] 와 F[T']는 어떠한 관계도 없다 [T]

변성과 반변성의 개념에 대해서 이해해보자.

함수의 인자는 반공변적이고 리턴타입은 공변적이어야 한다 .

https://stackoverflow.com/questions/41098105/subtyping-between-function-types