# Typed abstract methods / typed interfaces

**URL:** <https://racket.discourse.group/t/typed-abstract-methods-typed-interfaces/1197>\
**Category:** Questions & Answers\
**Tags:** typed-racket\
**Created:** [August 1, 2022, 9:10pm UTC](https://racket.discourse.group/t/typed-abstract-methods-typed-interfaces/1197 "2022-08-01T21:10:27Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [August 11, 2022, 1:46pm UTC](https://racket.discourse.group/t/typed-abstract-methods-typed-interfaces/1197/6 "2022-08-11T13:46:50Z")

</div>

I have in fact found an answer to the interface part of my question (see caveat below) in the docs right here: [4&nbsp;Typed Classes](https://docs.racket-lang.org/ts-reference/Typed_Classes.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.Class%29%29) , in the documentation for `#:implements`. Here is how it applies to my original example:

```scheme
(define-type my-interface<%> (Class (abstract-increment (-> Integer Integer))))

(: my-impl% (Class #:implements my-interface<%>
                   (extra-method (-> String))))
(define my-impl%
  (class object%
    (super-new)
    (define/public (abstract-increment x) (+ x 1))
    (define/public (extra-method) "I am an extra method")))

;(define obj1 (new my-interface<%>)) ; Type name used out of context.
(define obj2 (new my-impl%))
(send obj2 abstract-increment 1)
(send obj2 extra-method)

```

That's quite cool, because you get actual interfaces. You just need to keep in mind that you get them via a different mechanism than (untyped) Racket's `interface` construct.

_Caveat:_ This _almost_ works for me, because ideally I would like to pass type parameters to the parent class/interface (cf. [this other question](https://racket.discourse.group/t/inheritance-of-parameterized-typed-classes/1217)), and `#:implements` does not accept type constructors.

---

_[View the full topic](https://racket.discourse.group/t/typed-abstract-methods-typed-interfaces/1197)._
