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

[New topic] Modules #8

Open
Martinsos opened this issue May 4, 2021 · 9 comments
Open

[New topic] Modules #8

Martinsos opened this issue May 4, 2021 · 9 comments

Comments

@Martinsos
Copy link
Member

  • Internal
@soupi
Copy link

soupi commented May 5, 2021

@Martinsos
Copy link
Member Author

@soupi thanks, these are nice explanations, they will come in handy! Besides giving extra control to the library consumer, I also found Internal modules to be the only way to test inner workings of a module.

@soupi
Copy link

soupi commented Nov 4, 2021

Haskell school will have a section on module: haskellfoundation/HaskellSchool#28

@Martinsos
Copy link
Member Author

Haskell school will have a section on module: haskellfoundation/HaskellSchool#28

Thanks! They seem to be focusing on basic workings of modules -> I instead hope to focus on organizing them from the higher level and using Internal as a mechanism.

@Martinsos
Copy link
Member Author

Martinsos commented Nov 8, 2021

I started some work here https://github.com/wasp-lang/haskell-handbook/blob/master/module-tree-api.md .

@soupi
Copy link

soupi commented Nov 8, 2021

In that case, I've covered internal modules in the book, and Gabriella suggests one way to organize modules (which is a bit different than what I've seen in many places, but definitely good general advice).

@Martinsos
Copy link
Member Author

Aha I haven't noticed you covered that in your book, that is great! Some thoughts:

  • If I am developing module X, I usually don't put everything into X.Internal and then re-export only "public" stuff in the X. Instead, I usually start writing module X, and then when I figure out something is internal/private, I move it to X.Internal, at the end ending up with "private" stuff being in X.Internal and "public" stuff being in X, with potentially re-exporting some things from X.Internal if needed. I wonder if there is a significant difference between the two approaches? I guess not?
  • I found Internal modules to be crucial for testing, maybe that is also worth mentioning. I don't know any other way to test "private" functions.

@Martinsos
Copy link
Member Author

Regarding vertical vs horizontal -> I also prefer vertical approach, as Gabriella suggests. I figured that out for the first time while working on AngularJS projects some time ago and have stuck with it since then. I usually call that "feature-based" organization vs "type-based" organization, based on this article: https://johnpapa.net/angular-growth-structure/ .

@soupi
Copy link

soupi commented Nov 9, 2021

I wonder if there is a significant difference between the two approaches? I guess not?

When separating to public and private modules one issue that can crop up is cyclic dependencies - it's reasonable for public to depend on private, but the other way around is also likely. Especially for things like data type definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants