-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0bbfd7
commit 7f1ac49
Showing
4 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
slug: monopoly-in-ocaml-3 | ||
title: "Meetup 14: Monopoly in OCaml continued - part 3" | ||
authors: [prometheansacrifice] | ||
--- | ||
|
||
[@theteachr](https://github.com/theteachr) showed us the minimal TUI he wrote for the game and explained the game loop. | ||
|
||
**Highlights** | ||
|
||
1. We discussed how game loop had to be kept a pure function of game state and player moves | ||
2. Possible improvements with a `Seq` modules | ||
|
||
|
||
|
||
## Next Meetup | ||
|
||
Checkout [Upcoming Meetups](/upcoming-meetups) | ||
|
||
## Stay in touch with us | ||
|
||
Twitter: https://x.com/ReasonBangalore | ||
|
||
Discord: https://discord.com/invite/Ytr36fRC4C | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
slug: monopoly-in-ocaml-4 | ||
title: "Meetup 15: Monopoly in OCaml continued - part 4" | ||
authors: [prometheansacrifice] | ||
--- | ||
|
||
[@theteachr](https://github.com/theteachr) showed us the new game loop using `Seq.of_dispenser` making the game loop look like this. | ||
|
||
|
||
```ocaml | ||
let () = | ||
let game = | ||
[ "ocaml"; "reason"; "melange"; "dune" ] | ||
|> List.map Player.make | ||
|> Game.start | ||
in | ||
read_command | ||
|> Seq.of_dispenser | ||
|> Seq.filter_map Command.parse | ||
|> Seq.scan Command.exec game | ||
|> Seq.take_while Game.is_not_over | ||
|> Seq.iter Tui.draw | ||
``` | ||
|
||
**Highlights** | ||
|
||
We discussed, | ||
1. Possible use of GADTs for handling propert card transformations. You can find the git branch [here](https://github.com/theteachr/fortune/tree/gadt-property) | ||
2. use of `Seq.unfold`. [Code](https://github.com/theteachr/fortune/tree/unfold) | ||
3. Modular card transformations. [Code](https://github.com/theteachr/fortune/tree/property-modules) | ||
|
||
|
||
|
||
## Next Meetup | ||
|
||
Checkout [Upcoming Meetups](/upcoming-meetups) | ||
|
||
## Stay in touch with us | ||
|
||
Twitter: https://x.com/ReasonBangalore | ||
|
||
Discord: https://discord.com/invite/Ytr36fRC4C | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
slug: tree-sitter-for-ocaml | ||
title: "Meetup 16: Tree sitter for Reason and OCaml" | ||
authors: [prometheansacrifice] | ||
--- | ||
|
||
[@theteachr](https://github.com/KaranAhlawat) led the session explaining Tree sitter, how to write a grammar, debug tree-sitter-ocaml issies on helix. We even explored extending the Reason tree sitter grammar with a class definition. Here's the WIP snippet. | ||
|
||
|
||
```diff | ||
diff --git a/grammar.js b/grammar.js | ||
index 9f587a4..7bc6748 100644 | ||
--- a/grammar.js | ||
+++ b/grammar.js | ||
@@ -56,6 +56,7 @@ module.exports = grammar(require("./embedded/ocaml"), { | ||
$.expression_statement, | ||
$.open_statement, | ||
$.module_definition, | ||
+ $.class_definition, | ||
$.mutable_record_update, | ||
), | ||
|
||
@@ -71,6 +72,22 @@ module.exports = grammar(require("./embedded/ocaml"), { | ||
$._semicolon, | ||
), | ||
|
||
+ class_definition: ($) => | ||
+ seq( | ||
+ "class", | ||
+ // TODO optional($._attribute), | ||
+ $.class_binding, | ||
+ $._semicolon, | ||
+ ), | ||
+ | ||
+ class_binding: ($) => | ||
+ seq( | ||
+ field("name", choice($._class_name, alias("_", $.class_name))), | ||
+ // optional($._module_typed), | ||
+ seq("=", field("body", $._module_expression)), | ||
+ // repeat($.item_attribute), | ||
+ ), | ||
+ | ||
module_binding: ($) => | ||
seq( | ||
field("name", choice($._module_name, alias("_", $.module_name))), | ||
``` | ||
|
||
## Next Meetup | ||
|
||
Checkout [Upcoming Meetups](/upcoming-meetups) | ||
|
||
## Stay in touch with us | ||
|
||
Twitter: https://x.com/ReasonBangalore | ||
|
||
Discord: https://discord.com/invite/Ytr36fRC4C | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters