Reason Style Guide
General Style
- Indentation: 2 spaces
- Line Length: 80 characters
- Semicolons: Not required
- Curly Braces: Use the K&R style
- Comments: Use
/* */
for multi-line comments and//
for single-line comments. Comments should be clear and concise, explaining the purpose of the code. - Variable Naming: Use camelCase for variable names.
- Function Naming: Use camelCase for function names.
- File Naming: Use snake_case for file names.
Code Examples
K&R Style Curly Braces:
let myFunction = (a, b) => {
let result = a + b;
return result;
};
File Naming:
// my_file.re
Formatting
Code Formatter: Use reason-format
to format your code. https://github.com/reasonml-community/reason-format
Naming Conventions
Variable Naming:
let myVariable = "hello";
Function Naming:
let myFunction = () => {
// ...
};
Specific Examples
Example 1: Using Reason.Print
for debugging:
/* Example of using Reason.Print for debugging. */
Reason.Print.print("This is a debug message.");
Example 2: Implementing a simple function:
/* A simple function to add two numbers. */
let add = (a, b) => {
let result = a + b;
return result;
};
Project Structure
- src: Contains the source code for the project.
- test: Contains the unit tests for the project.
Contributing
Contributions to the project are welcome. Please follow the following guidelines:
- Fork the repository: Create a fork of the repository on GitHub.
- Create a new branch: Create a new branch for your changes.
- Commit your changes: Commit your changes with a clear and concise message.
- Push your branch: Push your branch to your fork.
- Submit a pull request: Submit a pull request to the main repository.