{"id":13998283,"url":"https://github.com/shwestrick/smlfmt","last_synced_at":"2025-10-21T04:41:13.641Z","repository":{"id":37893363,"uuid":"318285970","full_name":"shwestrick/smlfmt","owner":"shwestrick","description":"A custom parser/auto-formatter for Standard ML","archived":false,"fork":false,"pushed_at":"2025-05-11T19:52:29.000Z","size":2741,"stargazers_count":76,"open_issues_count":12,"forks_count":17,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-11T20:29:14.520Z","etag":null,"topics":["autoformat","formatter","parser","standard-ml"],"latest_commit_sha":null,"homepage":"","language":"Standard ML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shwestrick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-03T18:35:36.000Z","updated_at":"2025-05-11T19:52:29.000Z","dependencies_parsed_at":"2023-02-15T17:30:47.073Z","dependency_job_id":"1204b213-b0c2-429d-944d-87bf98864d59","html_url":"https://github.com/shwestrick/smlfmt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/shwestrick/smlfmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwestrick%2Fsmlfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwestrick%2Fsmlfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwestrick%2Fsmlfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwestrick%2Fsmlfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shwestrick","download_url":"https://codeload.github.com/shwestrick/smlfmt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwestrick%2Fsmlfmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280207158,"owners_count":26290613,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autoformat","formatter","parser","standard-ml"],"created_at":"2024-08-09T19:01:32.413Z","updated_at":"2025-10-21T04:41:13.603Z","avatar_url":"https://github.com/shwestrick.png","language":"Standard ML","funding_links":[],"categories":["Standard ML"],"sub_categories":[],"readme":"# `smlfmt`\n\nA custom parser and code formatter for Standard ML. `smlfmt` is fast,\nconfigurable, and usable for large projects.\n\nAll of the SML code in this repository (everything in\n`src`) has been formatted by `smlfmt`. Take a look!\n\n**(May 2, 2025)** Released v1.2.0!\n\n**(Nov 2, 2023)** Released v1.1.0!\n\n**(Jan 10, 2023)** Released v1.0.0!\n\n**(Dec 29, 2022)** changed repository name to `smlfmt` (used to be `parse-sml`).\n\n## Features\n- Full support for Standard ML according to the formal definition.\n- Fast -- see performance results below.\n- Usable for large projects.\n    * Whole-project formatting via `.mlb` files using\n      [MLton](https://github.com/MLton/mlton) conventions,\n      including [MLBasis path maps](http://mlton.org/MLBasisPathMap).\n- Helpful error messages with visual code references and syntax highlighting.\n- Support for various SuccessorML syntax extensions.\n- Configurable indentation size and maximum width.\n- Emacs integration (see [smlfmt.el](https://github.com/diku-dk/smlfmt.el))\n\n## Performance\n`smlfmt` is fast enough for live reformatting on large individual files, and can reformat large projects in seconds.\n\nHere are measurements for `smlfmt --preview-only INPUT \u003e out` on my MacBook Air (M2, 2022).\nInput | Size (LoC) | Time\n-|-|-\n[`src/prettier-print/PrettierExpAndDec.sml`](https://github.com/shwestrick/smlfmt/blob/main/src/prettier-print/PrettierExpAndDec.sml) | 1024 | 31 ms\n[`src/base/PrettyTabbedDoc.sml`](https://github.com/shwestrick/smlfmt/blob/main/src/base/PrettyTabbedDoc.sml) | 1349 | 29 ms\n[`src/parse/ParseExpAndDec.sml`](https://github.com/shwestrick/smlfmt/blob/main/src/parse/ParseExpAndDec.sml) | 1363 | 28 ms\nMLton [`elaborate-core.fun`](https://github.com/MLton/mlton/blob/master/mlton/elaborate/elaborate-core.fun) | 3942 | 104 ms\nMLton [`x86-allocate-registers.fun`](https://github.com/MLton/mlton/blob/master/mlton/codegen/x86-codegen/x86-allocate-registers.fun) | 11034 | 216 ms\nEntire `smlfmt` source code ([`smlfmt.mlb`](https://github.com/shwestrick/smlfmt/blob/main/src/smlfmt.mlb)) | 20000 (approx.) | 305 ms\nEntire MLton source code ([`mlton.mlb`](https://github.com/MLton/mlton/blob/master/mlton/mlton.mlb)) | 160000 (approx.) | 6.6s\n\n(Timings are averages reported by [`hyperfine`](https://github.com/sharkdp/hyperfine).)\n\n## Examples: Error Messages\n\n![Example 1](examples/ex1-small.png)\n\n![Example 2](examples/ex3-small.png)\n\n## Build and run\n\nYou need [`mlton`](http://mlton.org/) installed.\n\nDo `make` and then pass a `.sml` file to format it in-place, for example:\n```bash\n$ make\n$ ./smlfmt --preview src/smlfmt.sml       # modifies src/smlfmt.sml\n```\n\nYou can also pass code through `stdin` and `stdout`.\n```bash\n$ echo \"val x = 5 val y = 6\" | ./smlfmt   # formatted output written to terminal\n\n$ cat foo.sml | ./smlfmt \u003e bar.sml        # take foo.sml as input and write output to bar.sml\n\n$ ./smlfmt \u003c foo.sml \u003e bar.sml            # same as above\n```\n\nTo format many files all at once, pass a `.mlb` file. Use `--force`\nto skip overwrite confirmations.\n```bash\n$ ./smlfmt --force src/smlfmt.mlb\n```\n\n### Command-line options\n\n`--force` skips interactive overwrite confirmations.\n\n`--preview` also prints any formatted code to stdout,\nwith syntax highlighting (if shown on terminal supporting ANSI colors).\n\n`--preview-only` is the same as `--preview`, but also skips writing to file.\n(This is incompatible with `--force`.)\n\n`--read-only` will only parse files (and report syntax errors). No interactive\nconfirmation, and no files will be modified.\n(This is incompatible with `--force`.)\n\n`--check` will verify that files are already formatted (for example, for CI).\nNo interactive confirmation, and no files will be modified.\n(This is incompatible with `--force`.)\n\n`-mlb-path-var '\u003ckey\u003e \u003cvalue\u003e'` for handling path variables, similar to\n[MLton's path maps](http://mlton.org/MLBasisPathMap).\n\n`-ribbon-frac \u003creal\u003e` (default 1.0) controls pretty-printing. The\nribbon-frac (between 0 and 1) controls how dense each line is, excluding\nindentation. Low ribbon-fracs will have very little non-whitespace content\non each line, whereas high ribbon-fracs will attempt to fill the line as\nmuch as possible. Default = 1.0\n\n`-max-width \u003cint\u003e` (default 80) controls pretty-printing.\nThis is the desired maximum number of columns in each line.\nNote that it is not always possible to ensure that the output is within\nthe max width. (For example, deeply nested `let...in...end` expressions\nwill always indent further, and long comments/strings are not broken up.)\n\n`-indent-width \u003cint\u003e` (default 2) is the desired number of spaces used in\nthe formatted output.\n\n`-tab-width \u003cint\u003e` (default 4) informs the pretty-printer of the intended\ntab-width for the input source. Typically this doesn't matter, but there are\nsome cases where a particular tab-width can influence the vertical alignment\nof multiline comments and strings. (See discussion in issue #28 for more\ndetails.)\n\n`-engine [pretty|prettier]` (default `prettier`) selects which pretty printing\nengine to use. The `prettier` engine is the newest version. The `pretty`\nengine is the old version.\n\n`--debug-engine` enables debugging output, for developers. This flag requires\nthat the `--preview-only` flag is also enabled.\n\n`-allow-top-level-exps [true|false]` (default `true`) controls whether or\nnot top-level expressions (terminated by a semicolon) are allowed.\n\n`-allow-successor-ml [true|false]` (default `false`) controls whether or not\nSuccessorML features are allowed.\n\n`-allow-opt-bar [true|false]` (default `false`) controls whether or not\nSuccessorML optional bar syntax is allowed.\n\n`-allow-record-pun-exps [true|false]` (default `false`) controls whether or not\nSuccessorML record punning syntax is allowed.\n\n`-allow-or-pats [true|false]` (default `false`) controls whether or not\nSuccessorML or-pattern syntax is allowed.\n\n`-allow-extended-text-consts [true|false]` (default `false`) controls whether\nor not SuccessorML extended text constants are allowed. Enable this to allow\nfor UTF-8 characters within strings.\n\n`-allow-sig-withtype [true|false]` (default `false`) controls whether or not\nSuccessorML `withtype` in signatures syntax is allowed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshwestrick%2Fsmlfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshwestrick%2Fsmlfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshwestrick%2Fsmlfmt/lists"}