Hello everyone, A while ago I had written a MessagePack library Racket: https://pkgs.racket-lang.org/package/msgpack
Yesterday I made a change to narrow down some of the types from `Any` (which is wrong) to `Packable`. This has tanked my performance to the point where the tests for non-scalar types (vectors and hashes) time out on the package server, and thus fail. https://gitlab.com/HiPhish/MsgPack.rkt/commit/0b6cdc7115389db97a8de2a5175c1feb4c939f8f Please let me provide some context first: MessagePack is a serialisation format similar to JSON, except binary, so it should be smaller and faster. Only certain types can be packed (serialised) and unpacked (deserialised). Here is the specification: https://github.com/msgpack/msgpack/blob/master/spec.md TL;DR: numbers, strings, byte string, booleans, some null element (I use void), and arrays and dictionaries of any of these. I grouped the union of these types into the compound type `Packable`: https://gitlab.com/HiPhish/MsgPack.rkt/blob/master/packable.rkt#L24 I have also defined a predicate for this new type: https://gitlab.com/HiPhish/MsgPack.rkt/blob/master/packable.rkt#L36 As you can see the `Packable` type is recursive; if an object is a vector or a hash table then all its elements have to be packable as well. Could this be the reason for the performance loss? Another thing I noticed is that the predicate does not provide any proposition, if it succeeds the type checker is not informed that the object is of type `Packable`. Another is that Typed Racket seems unable to narrow down the type of the result. Take a look at this example: > (require msgpack) > (define bs (call-with-output-bytes (λ (out) (pack 3 out)))) > bs - : Bytes #"\3" > (define v (call-with-input-bytes bs (λ (in) (unpack in)))) > v - : Packable 3 > (+ v 3) ; readline-input:8:3: Type Checker: type mismatch ; expected: Number ; given: Packable ; in: v ; [,bt for context] > (exact-integer? v) - : Boolean #t So the type checker can figure out that v is an integer, but it cannot treat it as one for addition. -- 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. For more options, visit https://groups.google.com/d/optout.