# Is it possible to unsafely assume sub-types in Typed Racket?

**URL:** <https://racket.discourse.group/t/is-it-possible-to-unsafely-assume-sub-types-in-typed-racket/1140>\
**Category:** Questions & Answers\
**Tags:** question, typed-racket, unsafe\
**Created:** [July 10, 2022, 5:15am UTC](https://racket.discourse.group/t/is-it-possible-to-unsafely-assume-sub-types-in-typed-racket/1140 "2022-07-10T05:15:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcn](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pcn](https://racket.discourse.group/u/pcn)\
**Post date:** [July 10, 2022, 5:15am UTC](https://racket.discourse.group/t/is-it-possible-to-unsafely-assume-sub-types-in-typed-racket/1140/1 "2022-07-10T05:15:40Z")

</div>

Typed Racket exposes [unsafe primitives](https://docs.racket-lang.org/ts-reference/Unsafe_Typed_Racket_operations.html) that make it possible to [unsafely cast](https://github.com/philnguyen/typed-racket-hacks/blob/master/typed-racket-hacks/unsafe.rkt#L13) a value to an arbitrary type. Is it also possible to use existing unsafe utilities to somehow make Typed Racket assume that one type is another's subtype?

I imagine a few uses for such unsafe operation:

- To implement GADT, where, within some scope, for example, we make Typed Racket assume that `(Expr a)` and `(Expr Integer)` are the same type
- To [encode higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf) through type-level de-functionalization, where we make Typed Racket assume that a direct type application (e.g. `(List a)`) is the same as a spelled-out type application `(Type-App List:Tag a)`

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [July 11, 2022, 2:41pm UTC](https://racket.discourse.group/t/is-it-possible-to-unsafely-assume-sub-types-in-typed-racket/1140/2 "2022-07-11T14:41:20Z")

</div>

No, you can't permanently change the subtyping algorithm. That seems like it would impose some tricky implementation constraints.
