2 ms·
I believe you could also use the heterogeneous map (HMap) type if you wanted static typing: (defalias Pid (HMap :complete? true :mandat
by weavejester 12y ago
I believe you could also use the heterogeneous map (HMap) type if you wanted static typing:
(defalias Pid
(HMap
:complete? true
:mandatory {:set-point Num
:k-p Num
:k-i Num
:k-d Num
:error-sum Num
:error-last Num
:output-max Num
:output Num}))
And then use it as you might expect:
(ann calculate-pid [Pid Num -> Pid])
There's no real downside to using a record, but they're really only necessary for polymorphism.
- pi-rat 12y agoThanks! I'm just getting started with core.typed, and record felt more natural as it's annotated just as you would annotate a function. I expected there to be a way to create a type a map just like that, but just haven't had the time to read up on it. So thank you for the example, will definitely play more with core.typed.