On 3/21/20, unlimitedscolobb <unlimitedscol...@gmail.com> wrote: > Hello, > > I come to Racket from Haskell and so far I am quite happy, as I feel freer > to do some weird stuff from time to time, and I am absolutely in love with > the Lisp-parens syntax. > > As a former Haskeller, one of the first things I tried was Typed Racket. > It worked like a charm for small examples, but started getting in my way > too much as soon as I got to some more advanced stuff (e.g. polymorphic > functions, generics, eval, even apply). My immediate reaction was ditching > types for contracts, which are rather fine and allow me to use a familiar > language, but I am somewhat worried about the performance penalties > defining everything via define/contract may incur. Also, it seems weird to > set up runtime contract checks where a simple type annotation would do. > I have no problem with Typed Racket not being able to type every single one > of my functions (after all, I came to Racket to be able to do weird stuff), > but so far I couldn't figure out what would be the best way to mix typed > into two separate files. > > What is the standard practice for mixing typed and untyped code within a > single module? Submodules? Typed regions within untyped code? Maybe > there is an example somewhere I can have a look at?
Yep, submodules and typed regions are the two ways to do this. The plot library uses typed submodules in untyped code in a few small places: https://github.com/racket/plot/blob/master/plot-lib/plot/private/common/contract.rkt https://github.com/racket/plot/blob/master/plot-lib/plot/private/common/parameter-groups.rkt I've done a similar thing to make typed parameters in untyped code. Not sure about best practices, but I definitely prefer keeping typed and untyped code in separate modules. For contracts, though, (provide (contract-out ...)) gives better error messages than define/contract. -- 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/CAFUu9R6NyvCz2TWL4%3DBBQ0edff18LGTQcUytkXngESvrDQYx_g%40mail.gmail.com.