Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Reactive) Streams? #29

Open
woeps opened this issue Feb 25, 2020 · 3 comments
Open

(Reactive) Streams? #29

woeps opened this issue Feb 25, 2020 · 3 comments
Labels
binary issues regarding the binary bin/refabricate.exe concept work on concept(s) - not possible to implement yet library issues regarding the library Refabricator question Further information is requested

Comments

@woeps
Copy link
Owner

woeps commented Feb 25, 2020

The current implementation sometimes feels like a bad rough implementation of something similar to reactive streams. - so why not go the full mile and actually use an established strems library?

I'd be very much interested in some opinnions!


Some libraries I found:

@woeps woeps added binary issues regarding the binary bin/refabricate.exe concept work on concept(s) - not possible to implement yet library issues regarding the library Refabricator question Further information is requested labels Feb 25, 2020
@woeps
Copy link
Owner Author

woeps commented Feb 27, 2020

After a little reading into the libraries, I would lean towards usint React.E

Types

In relation to #18 :
Types could be changed to something like:

type meta = { name: string };
type fabric('t) = (meta, 't);
type fabricator('out) = React.E.t(fabric('out));
type refabricator('in, 'out) = React.E.t(fabric('in)) => React.t(fabric('out)); // this will be usually done by using React's lifting functions
type factory('in, 'outOk, 'outErr) = React.E.t(fabric('in)) => React.E.t(fabric(Result.t('outOk, 'outErr)));

Refabricator Constructor

Additionally a constructor for refabricators could be provided like:

let makeRefabricator: (fabric('in) => fabric('out)) => Types.refabricator('in, out) = React.E.l1;

This means just implementing the map function is enough.

Error Handling

String

I'm not sure though how to handles errors in (re-) fabricators. Maybe limit a factories error type to just string and ok to just the fabric? (Re-) fabricators could send the same result type. Errors Would be passed through.

This means only the component which runs into the error could handle or compensate it accordingly. Having compensations in another component would mean matching and de-/serializing a string, which is't a good idea.

Polymorphic Variant

Or just use polymorphic variants and define some common errors in Types.error. In this case every component will need to handle all commonly defined errors and/or pass every other polymorphic variant through to the next component.

This would probably mean factory would become obsolete, because its just a refabricator.
Lib.Main would then add a print function which takes a list of pp ("pretty print") functions:

type pp_error('e) => ('e => string);
let errorsToString: list(pp_error) => string;

This would mean any custom component could implement it's own pp_error function and add it as an argument to errorsToString.

A default pp_error function for the common errors could be "pre-injected" into a helper function to errorsToString.

@woeps
Copy link
Owner Author

woeps commented Mar 21, 2020

I started experimenting with React on the experiment/react branch.
Once I have a good understanding of how I want to use React, I'll send a separate PR switching everything over to using React.

@woeps
Copy link
Owner Author

woeps commented Apr 26, 2020

I started experimenting with Lwt_stream on experiment/lwt-stream branch.
Will try some more things there.

I probably should try Lwt_react as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary issues regarding the binary bin/refabricate.exe concept work on concept(s) - not possible to implement yet library issues regarding the library Refabricator question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant