https://github.com/chantastic/til
stuff i just learned
https://github.com/chantastic/til
Last synced: 9 months ago
JSON representation
stuff i just learned
- Host: GitHub
- URL: https://github.com/chantastic/til
- Owner: chantastic
- License: mit
- Created: 2017-09-01T23:37:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-02T00:14:40.000Z (almost 9 years ago)
- Last Synced: 2025-03-22T03:11:33.559Z (about 1 year ago)
- Size: 1000 Bytes
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# til
stuff i just learned
## 2017.09.01
**In Ocaml/Reason, every `files` is a `module`.**
Say I have `schoole.re` and it looks like this:
```
/* school.re */
type profession = Teacher | Director;
let person1 = Teacher;
let getProfession person =>
switch person {
| Teacher => "A teacher"
| Director => "A director"
};
```
Without import/export statements, the above is wrapped as a module `School` and accessible throughout my project.
Consiquently, Ocaml/Reason allows nested modules.
```
/* school.re */
type profession = Teacher | Director;
let person1 = Teacher;
let getProfession person =>
switch person {
| Teacher => "A teacher"
| Director => "A director"
};
module GPA {...};
module Records = {...};
module Rooms = {...};
```
These are accessible through the `School` module like so: `School.GPA`
#### My initial reaction
As a n00b, this is super weird. It feels unscalable.
However, as a fan of flat organization patterns, I'm cautiously excited.
#### References
[Reason on Modules](https://reasonml.github.io/guide/language/module)
[What's in a language, Cheng Lou](https://www.youtube.com/watch?v=24S5u_4gx7w)