KitApps / schema-refined

Clojure library to keep you away from bugs with precise schemas (refined types with runtime checks)
MIT License
67 stars 2 forks source link

Reimplement StructMap & StructDispatchMap using variant-spec (fixes issue #5) #22

Closed gsnewmark closed 4 years ago

gsnewmark commented 6 years ago

Fixes issue #5.

There are two obvious issues with new StructDispatchMap implementation and I'm not sure this simplification is actually worth it :disappointed: :

1) we can't obtain dispatch value to show in error in case no dispatch branches matched the value https://github.com/KitApps/schema-refined/compare/feature-cleanup-struct-impl?expand=1#diff-599ae3465d726ee432cd5735a58c70a9R1245 I believe this can really harm readability.

2) dispatch value for input would be extracted for each dispatch branch separately until one of them matches https://github.com/KitApps/schema-refined/compare/feature-cleanup-struct-impl?expand=1#diff-599ae3465d726ee432cd5735a58c70a9R1240 This one probably harms performance a bit, especially if dispatch-fn is complex (but why would one make it complex?), but in my opinion is not as bad as the first issue I mentioned.

gsnewmark commented 4 years ago

Given the issues I've described initially, I don't think it makes sense to switch implementation, especially taking into account Schema didn't have any breaking internal changes during the last year.