elm-guides / elm-for-js

Community driven Elm guide for JS people
229 stars 21 forks source link

Consideration: discussion of modules, scope and modularity #6

Open netaisllc opened 9 years ago

netaisllc commented 9 years ago

This may just be a me-specific problem, but I'm missing a decent conceptual grounding about how modules impact scope. Specifically, I'm grinding at the moment about how to achieve decent modularity yet still share central nervous system things like signals and addresses.

Current example apps abound, but they are all fitted to very small uses cases and demonstrate "statement use" rather than how a real-world app would hang together. Even ToDoMVC fails that test.

Yes, I'm reading EC's architecture notes, but they are rather "by an expert, for experts"; I'm neither. Alas.

mgold commented 9 years ago

One pattern I've had success with is a "wide diamond" of modules. I have Common module that defines types, and perhaps JSON encoders and decoders on those types. Then I have the bulk of the modules where I do my dirty work, each drawing on Common. Then I have Main, which imports everything, ties it all together, and contains the ports.

I wrote an article on scope, which I've been meaning to do anyway. It's more syntactic than architectural, but hopefully it's helpful in some way.

netaisllc commented 9 years ago

Nice. TY!