{"id":13395438,"url":"https://github.com/leostera/reason-design-patterns","last_synced_at":"2025-04-05T10:09:00.370Z","repository":{"id":36798912,"uuid":"165561011","full_name":"leostera/reason-design-patterns","owner":"leostera","description":"🗺 An unofficial collection of \"design patterns\" for ReScript, Reason, and OCaml","archived":false,"fork":false,"pushed_at":"2023-01-02T19:04:57.000Z","size":80,"stargazers_count":481,"open_issues_count":3,"forks_count":21,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-05-02T06:18:48.730Z","etag":null,"topics":["design-patterns","how-to","ocaml","patterns","reason","reasonml","recipes","rescript","rescript-lang"],"latest_commit_sha":null,"homepage":"","language":"Reason","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leostera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"AbstractMachinesLab"}},"created_at":"2019-01-13T22:22:24.000Z","updated_at":"2024-04-14T20:45:47.000Z","dependencies_parsed_at":"2023-01-17T04:53:48.575Z","dependency_job_id":null,"html_url":"https://github.com/leostera/reason-design-patterns","commit_stats":null,"previous_names":["leostera/reason-design-patterns","ostera/reason-design-patterns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leostera%2Freason-design-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leostera%2Freason-design-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leostera%2Freason-design-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leostera%2Freason-design-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leostera","download_url":"https://codeload.github.com/leostera/reason-design-patterns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","how-to","ocaml","patterns","reason","reasonml","recipes","rescript","rescript-lang"],"created_at":"2024-07-30T17:01:58.719Z","updated_at":"2025-04-05T10:09:00.346Z","avatar_url":"https://github.com/leostera.png","language":"Reason","readme":"# 🗺 Reason Design Patterns\n\nAn unofficial collection of \"Design Patterns\" collected from learning,\nexperimenting, and working with Reason and OCaml.\n\nThese \"patterns\" have worked well for me, but, since experience is subjective,\nYMMV. They are not infallible, they are 100% not something I invented (but\nmerely rediscovered), and if you have any input please send PRs!\n\nIf you've found this content useful, considering ordering a copy my book: [Practical ReScript](https://practicalrescript.com)\n\n## Project Layout\n\n1. [Yawaramin's Modular Project\n   Structure](https://dev.to/yawaramin/a-modular-ocaml-project-structure-1ikd)\n\n## Working with Types\n\nWhether you are modeling TODO lists or mission-critical stuff, these patterns\nshould help you build types that are safe to use, refactor, and evolve.\n\n1. [Smart Constructors](patterns/smart-constructors.md), to give your types\n   additional refinements that can only be done at runtime\n2. [Constructor + View](patterns/constructor-view.md), to keep your types\n   abstract without losing pattern-matching\n\n## Domain Modeling\n\nIf your code says too much about how things are done, fights records and\nvariants, or is plagued by empty lists and booleans that mean special things,\ntake a look at these:\n\n1. [Boolean Blindness](patterns/boolean-blindness.md)\n2. [\"Pretend\" Modules](patterns/pretend-modules.md)\n\n## Module Design\n\nWhen you are writing modules and libraries, it's foundational to get some\nthings right. A stable interface that leaks no implementation details, good\ncontainment of concerns, and the right amount of flexibility are some of the\nthings to consider.\n\nFind below some patterns to help you write modules:\n\n1. [Interface First](patterns/interface-first.md)\n2. [\"Pretend\" Modules](patterns/pretend-modules.md)\n3. [1 Module for 1 Thing](patterns/1-module-1-thing.md)\n4. [Interpreter Pattern](patterns/interpreter/README.md)\n5. [100-Named-Args Functions](patterns/100-named-args-functions.md)\n6. [Private Types](patterns/private-types.md)\n\n## Error Handling that Scales\n\n1. [PolyVariant Error Propagation](patterns/polyvariant-error-propagation.md)\n2. [Rresult's Guide to Custom Error\n   Types](http://erratique.ch/software/rresult/doc/Rresult.html#usage)\n\n## Examples\n\n1. [smart-constructors](patterns/smart-constructors/SmartConstructors.re)\n2. [constructor-views](patterns/constructor-view/ConstructorViewFinal.re)\n3. [boolean-blindness](patterns/boolean-blindness/BooleanBlindness.re)\n4. [providing-evidence](patterns/providing-evidence/ProvidingEvidence.re)\n5. [interface-first](patterns/pretend-modules/InterfaceFirst.re)\n6. [pretend-modules](patterns/pretend-modules/PretendModules.re)\n7. [interface-first](patterns/pretend-modules/InterfaceFirst.re)\n8. [one-module-one-thing](patterns/one-module-one-thing/OneModuleOneThing.re)\n9. [100-named-args-functions](patterns/100-named-args-functions/HundredNamedArgsFunctions.re)\n10. [private-types](patterns/private-types/PrivateTypes.re)\n11. [interpreter-pattern](patterns/interpreter/FreeMonadInterpreter.re)\n\nTo run examples:\n\n```sh\nnpm install\nnpm start\n```\n","funding_links":["https://github.com/sponsors/AbstractMachinesLab"],"categories":["Reason","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleostera%2Freason-design-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleostera%2Freason-design-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleostera%2Freason-design-patterns/lists"}