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

[sfh][2023] Day 1 (OCaml/Reason) #120

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions solomonhawk/2023/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
esy.lock/* linguist-generated
10 changes: 10 additions & 0 deletions solomonhawk/2023/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.merlin
.DS_Store
node_modules/
_build
_esy
_release
*.byte
*.native
*.install
inputs/*
12 changes: 12 additions & 0 deletions solomonhawk/2023/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"[dune]": {
"editor.formatOnSave": true
},
"[reason]": {
"editor.formatOnSave": true
},
"ocaml.sandbox": {
"kind": "esy",
"root": "${workspaceFolder:2023}"
}
}
52 changes: 52 additions & 0 deletions solomonhawk/2023/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# AOC Reason

## Install Deps

$ esy

This is an alias for `esy install` or `esy i`.

## Build

$ esy b

`b` is an alias for `esy build`.

## Run

$ esy x aoc

`x` is an alias for `esy exec`.

## Watch

$ npm run build:watch

## Test

$ npm run test
$ npm run test:watch

**Note**: Only one dune process can be run at a time (it locks the build directory), so you must stop the watch process before running tests.

## Notes/Questions

- [ ] Can `esy` be used with `asdf-ocaml` in a sensible way?
- [ ] `esy` has it's own project sandboxing (like `opam` switches, but project-specific by default)

## References

- https://www.chrisarmstrong.dev/posts/setting-up-a-new-reason-project
- https://mukulrathi.com/ocaml-tooling-dune/
- https://reasonml.github.io/en/try.html
- https://github.com/fangyi-zhou/advent-of-code-ocaml-starter/tree/main
- https://github.com/fangyi-zhou/advent-of-code/tree/main/2022
- https://github.com/DrearyLisper/aoc-2022
- https://ocaml.org/docs
- https://reasonml.github.io/docs/en/overview
- https://dune.readthedocs.io/en/stable/index.html
- https://esy.sh/docs/getting-started/
- https://github.com/janestreet/ppx_inline_test/tree/master
- https://discuss.ocaml.org/t/how-to-set-up-unit-testing-in-2023/12682/26
- https://discuss.ocaml.org/t/ocaml-stdlib-and-death-by-a-thousand-papercuts/9180/9
- https://c-cube.github.io/ocaml-containers/last/containers/index.html
20 changes: 20 additions & 0 deletions solomonhawk/2023/aoc.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
depends: [
"dune" {>= "3.11"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
4 changes: 4 additions & 0 deletions solomonhawk/2023/bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(name main)
(public_name aoc)
(libraries aoc))
5 changes: 5 additions & 0 deletions solomonhawk/2023/bin/main.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
open Aoc;

let () = {
Day1.run();
};
3 changes: 3 additions & 0 deletions solomonhawk/2023/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.11)
(name aoc)
(generate_opam_files true)
24 changes: 24 additions & 0 deletions solomonhawk/2023/esy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "aoc-2023",
"dependencies": {
"@opam/containers": "3.12",
"@opam/dune": ">= 3.8.0",
"@opam/reason": "*",
"ocaml": "5.1.4"
},
"devDependencies": {
"@opam/merlin": "*",
"@opam/ocaml-lsp-server": "*",
"@opam/ocamlformat": "*",
"@opam/ppx_assert": "*",
"@opam/ppx_compare": "v0.16.0",
"@opam/ppx_expect": "v0.16.0",
"@opam/ppx_inline_test": "*",
"@opam/ppx_sexp_conv": "v0.16.0",
"@opam/sexplib": "v0.16.0",
"@opam/utop": "*"
},
"esy": { "buildsInSource": "_build", "build": [ "dune build -p aoc" ] },
"scripts": { "build:watch": "dune build -w -p aoc" },
"installConfig": { "pnp": false }
}
3 changes: 3 additions & 0 deletions solomonhawk/2023/esy.lock/.gitattributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these esy.lock/ meant to be committed?

Copy link
Contributor Author

@solomonhawk solomonhawk Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that they should be committed (like package-lock.json, but more verbose). The docs on esy.sh mention it here. Also, this starter repo doesn't omit them.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions solomonhawk/2023/esy.lock/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading