You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Mapbox FFI is a mix of zero-runtime-cost bindings to raw Mapbox types/functions and a layer of Reason types with runtime conversion to Mapbox types. I probably won't knock all of this out at once, but here's a plan to clean things up:
Move GeoJSON out of this repo
Inside src/ make two directories
FFI (filled with low-level abstract types)
Re ( filled with Reason wrappers and runtime conversions)
The low-level bindings in src/FFI/ should provide as much safety as possible while bringing virtually no runtime cost. We should generate *.rei interfaces here and aggressively hide anything unsafe.
Examples of strategies in FFI:
[@bs.deriving abstract] all over the place
Obj.magic to cast types to their Mapbox supertypes
= "%identity" to constrain strings, emulating enums
The src/Re/ directory should have 1:1 mappings to files in the FFI directory (mostly, probably?), but all objects should be Reason records, all subtyping should be represented as variants, and all functions that call into the FFI should do runtime conversion as needed.
This approach should make it clear when you're choosing between clean JS code vs real Reason data that can be pattern-matched and updated using normal patterns (but with more overhead in the compiled JS).
The text was updated successfully, but these errors were encountered:
Currently, the Mapbox FFI is a mix of zero-runtime-cost bindings to raw Mapbox types/functions and a layer of Reason types with runtime conversion to Mapbox types. I probably won't knock all of this out at once, but here's a plan to clean things up:
src/
make two directoriesThe low-level bindings in
src/FFI/
should provide as much safety as possible while bringing virtually no runtime cost. We should generate*.rei
interfaces here and aggressively hide anything unsafe.Examples of strategies in FFI:
[@bs.deriving abstract]
all over the placeObj.magic
to cast types to their Mapbox supertypes= "%identity"
to constrain strings, emulating enumsThe
src/Re/
directory should have 1:1 mappings to files in the FFI directory (mostly, probably?), but all objects should be Reason records, all subtyping should be represented as variants, and all functions that call into the FFI should do runtime conversion as needed.This approach should make it clear when you're choosing between clean JS code vs real Reason data that can be pattern-matched and updated using normal patterns (but with more overhead in the compiled JS).
The text was updated successfully, but these errors were encountered: