Organize modules in multiple files and dependency cycle problems

Hello.
I’m a newbe in ML and I’m having some trouble understanding the best way to organize module files and hope someone could give me some pointers.

Using a Stream library that I’m writing as an example

I have a “Source.res” file (and consequently module) that has “base types” and some basic sources like “single”, “values”, etc… and have “Transformers” in a separate modile as well has “Sinks” and also a “Through”

I use them like this:
Source.values([1, 2, 3]) → Transform.map(a => a * 10) → Sink.forEach(b => Js.log(b))

I also have other source modules like SourceFs and SourceWS that I use like so:

SourceFs.readDir(“some/path”) → Through.log → Sink.drain

I would like to instead of creating new modules extend the Source module so I can:

Source.readDir(“some/path”) → Through.log → Sink.drain

I want to “extend” Sources module with “readDir” or “websocket” but dependency cycles get in the way and I not sure how to implement mutually recursive modules in separate files

Could someone give me tips on how to organize this? Also tips on how to modularize a stream library would be great.

Thanks :slight_smile:

Can not give you suggestions without showing the code, but you can reference the library Webapi, it helps me a lot in organizing modules.

1 Like