Generate Purescript types from your Rust types. (unmaintained)
APACHE-2.0 License
NOTE: This library is currently unmaintained. Please contact @tomhoule if you would like to do something about it.
Wouldn't it be nice if you could share your data type definitions between your Rust backend and your Purescript app? Now you can!
Waterslide generates Purescript type definitions from Rust structs and enums. It works on stable Rust.
#[derive(AsPursType)]
or by manually implementing AsPursType
if you havepurs_module!
macro (e.g.purs_module!("Data.Dogs".to_string() ; Dachsund, ChowChow, Mutt<Void, Void>)
).PursModule
'sDisplay
impl.You might want to put the module generation code in a separate binary, which is easy to do with Cargo.
Important: on the Purescript side, you want to use the
Data.Argonaut.Generic.Aeson
codec to encode and decode the JSON types.
Important*: on the Rust side, your enums have to be annotated with
#[serde(tag = "tag", content = "contents")]
These restrictions will be lifted in the future by the development of an
Argonaut codec that mirrors serde_json
's defaults.
For running code, take a look at the basic example. The tests also provide a lot of usage examples, notably for generic types.
Vec
...)Alternative<T, U>
, Paginated<T>
...)AsPursType
(unstable interface)Things I want to add in the coming weeks (in no particular order):
The idea of this library came from Haskell's purescript-bridge package.
That would be awesome! There are no particular guidelines for pull requests (maybe in the future). We adhere to the Rust Code of Conduct.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.