melange-json icon indicating copy to clipboard operation
melange-json copied to clipboard

Set type t for a better approach on universal code

Open pedrobslisboa opened this issue 1 year ago • 1 comments

Hi there,

I was working on universalize the melange-json code on server-reason-react: https://github.com/ml-in-barcelona/server-reason-react/pull/133

Reading the melange-json code led me to doubt.

Could we have type t = Js.Json.t instead of using directly the Js.Json.t inside the code?

The idea is to create a nice way to have a code that works by itself, I understand it depends on Js.Json.t internally, but every usage of Json would return its type: Json.t, and will handle on every function by its type.

The usage in the end could be:

let encodeStr str : Json.t = Json.encode str

Without conflict between Js.Json.t (Which isn't the main type of Json) and any other tool, such as Yojson.

Is it valid? WDYT?

pedrobslisboa avatar May 08 '24 20:05 pedrobslisboa

Ppx_deriving_json_runtime is kinda like that, the module name isn't nice though...

andreypopp avatar Oct 05 '24 10:10 andreypopp