djtango
2016-11-16 13:29:47

Is there any way to express a HashTable in typed/racket like: #hash((a . 1)(b . "b")(c . #(1 2 3))) with any greater specificity than (HashTable Symbol (U Integer String (Vectorof Real)))

Because this type would be correct and more precise (HashTable 'a Integer 'b String 'c (Vectorof Real))


leafac
2016-11-16 13:44:25

I don’t know of a way to do this. But, at this point, wouldn’t you be better off with a structure?


djtango
2016-11-16 13:52:35

yes - I’m using structs at the moment, but hashes feel nicer to deal with functionally as you can use symbols as function arguments (I come from a Clojure background)


djtango
2016-11-16 13:55:27

In terms of types - structs definitely have what I am looking for, but it can get a bit clunky having struct accessors everywhere. May just need to write a syntax wrapper


leafac
2016-11-16 14:32:52

I see what you mean, but unfortunately I don’t have an answer for you. Except to say that at first I didn’t like structure accessors either, but I’m starting to appreciate them. Maybe you can give them a try. And good luck :+1:


djtango
2016-11-16 14:51:33

ok - np thanks for getting back to me. Hopefully I’ll get used to the structs, syntax wrapping does feels rackety though