xvaldetaro / purescript-hyrule-paraglider

Explore Hyrule with of Paraglider Rx-inpired operators
6 stars 0 forks source link

Proposal: create a flat structure of single files that do one thing #1

Closed mikesol closed 2 years ago

mikesol commented 2 years ago

I think a nice structure for this repo could be a very flat one of minimalistic functions, each of which does one thing and is clearly documented.

For example, memoBeh (or whatever we name it) would be it's own file, mailboxed (which we could move here from hyrule) could be its own file, the fireAndForget could be its own file, take could be its own file, etc. This is because there is no "logic" to the toolbox - when we are reaching for any one of these, we don't think "memoBeh is from the X family of functions which is in file Y." We just want memoBeh, and if it's in MemoBeh.purs, we're done looking.

Another possibility would be to do one gigantic file, which is what's done in birds and works quite well. However, the issue with hyrule, is that the implementations can get quite large, so the file easily could get unwieldy.

How does that sound?

xvaldetaro commented 2 years ago

I'm ok either way. What do you think would be the most standard way for this in Purescript? Currently all the Operators are in one big file (there are other files for helper stuff).

mikesol commented 2 years ago

For util libraries like Simple.JSON and Aviary.Birds, the standard is one big file, but in those cases, everything is in one file and the util methods are not exposed to the outside.

Here, even though it's unconventional, I'd recommend all the util stuff in separate files. For logical clumps like ST or DisposingRef or Rx compat, it makes sense for them to remain clumped together as they currently are.

But otherwise I'd create separate files, ie BlockingGetN.purs, FromEffect.purs, FromAff.purs, FromCallable.purs and then re-export everything in one top-level file. For example, if I were browsing the repo and saw BlockingGetN.purs, I'd understand quickly what's going on because the name of the function & file is clear, whereas if it were in AffBridge.purs, I may not find it because I don't know where to look. Perhaps all of this would go under an FRP folder.

How does this sound?

xvaldetaro commented 2 years ago

Sounds good to me. Will move everything to separate files then!

xvaldetaro commented 2 years ago

@mikesol just to confirm: The file and the function will have the same name i.e.: Paraglider.Operator.CombineFold.combineFold, right?

Do you have some neat way to move methods and rename files for PS projects, or is it all manual?

xvaldetaro commented 2 years ago

https://github.com/xvaldetaro/purescript-hyrule-paraglider/pull/4