On 2020-11-14 02:58:44 -0800, hashim....@gmail.com wrote: > Any advice on how to make this work? Or whether to simply not do this in > typed racket?
It's possible to do this in Typed Racket but it's just a bit more cumbersome as you need to make the function type row-polymorphic. Here's a version that should typecheck: ;;; #lang typed/racket/base (require typed/racket/class) (define-type recipe<%> (Class (init [name String]) (get-name (-> String)))) (: recipe% recipe<%>) (define recipe% (class object% (init [name : String]) (super-new) (: _name String) (define _name name) (define/public (get-name) _name))) (: amount-mixin (All (r #:row) (-> (Class #:implements recipe<%> #:row-var r) (Class #:implements recipe<%> #:row-var r (init [amount Number]) (get-amount (-> Number)))))) (define (amount-mixin %) (class % (init [amount : Number]) (: _amount Number) (define _amount amount) (super-new) (inherit get-name) (define/public (get-amount) _amount))) (: unit-mixin (All (r #:row) (-> (Class #:implements recipe<%> #:row-var r) (Class #:implements recipe<%> #:row-var r (init [unit String]) (get-unit (-> String)))))) (define (unit-mixin %) (class % (init [unit : String]) (: _unit String) (define _unit unit) (super-new) (inherit get-name) (define/public (get-unit) _unit))) (unit-mixin (amount-mixin recipe%)) ;;; Cheers, Asumu -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/20201117221028.6ruudpxbmu2err76%40nixos.