{"id":21202680,"url":"https://github.com/minoki/sml-toml","last_synced_at":"2026-01-02T02:02:37.279Z","repository":{"id":217462425,"uuid":"743035874","full_name":"minoki/sml-toml","owner":"minoki","description":"TOML parser for Standard ML","archived":false,"fork":false,"pushed_at":"2024-09-03T09:35:15.000Z","size":79,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T15:09:16.299Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/minoki.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}},"created_at":"2024-01-14T05:38:37.000Z","updated_at":"2024-10-30T21:06:56.000Z","dependencies_parsed_at":"2024-01-19T03:25:18.471Z","dependency_job_id":"10b46f92-db09-44d0-afdd-ded5ba3fb181","html_url":"https://github.com/minoki/sml-toml","commit_stats":null,"previous_names":["minoki/sml-toml"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoki%2Fsml-toml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoki%2Fsml-toml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoki%2Fsml-toml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoki%2Fsml-toml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minoki","download_url":"https://codeload.github.com/minoki/sml-toml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243655845,"owners_count":20326154,"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":[],"created_at":"2024-11-20T20:17:38.824Z","updated_at":"2026-01-02T02:02:37.206Z","avatar_url":"https://github.com/minoki.png","language":"Standard ML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sml-toml\n\nThis is a parser of [TOML v1.0.0](https://toml.io/en/v1.0.0) for Standard ML.\n\n## Usage\n\nMultiple compilers including SML/NJ, MLton, SML#, and LunarML are supported.\n`toml.mlb` and `toml.cm` and `toml.smi` provides:\n\n```sml\nsignature TOML_VALUE\nstructure TomlValue\nsignature PARSE_TOML\nstructure ParseToml\nsignature TOML_PARSE_ERROR\nstructure TomlParseError\nsignature TOML_VALUE_HANDLER\nfunctor ParseToml\nsignature VALIDATE_UTF8\nstructure ValidateUtf8\n```\n\n### TOML value\n\nTOML value is expressed as `TomlValue.value`.\n\n```sml\nsignature TOML_VALUE = sig\n  datatype value = STRING of string (* UTF-8 encoded *)\n                 | INTEGER of IntInf.int\n                 | FLOAT of real\n                 | BOOL of bool\n                 | DATETIME of string (* 2024-01-12T19:20:21[.123]+09:00 *)\n                 | LOCAL_DATETIME of string (* 2024-01-12T19:20:21[.123] *)\n                 | DATE of string (* 2024-01-12 *)\n                 | TIME of string (* 19:20:21[.99999] *)\n                 | ARRAY of value list\n                 | TABLE of (string * value) list\n  type table = (string * value) list\n  structure Integer : sig\n    type int = IntInf.int\n    val + : int * int -\u003e int\n    val * : int * int -\u003e int\n    val fromInt : Int.int -\u003e int\n    val fromString : string -\u003e int option\n  end\n  val string : string -\u003e value\n  val integer : Integer.int -\u003e value\n  val float : string -\u003e value\n  val bool : bool -\u003e value\n  val datetime : string -\u003e value\n  val localDatetime : string -\u003e value\n  val date : string -\u003e value\n  val time : string -\u003e value\n  val array : value list -\u003e value\n  val subtable : table -\u003e value\n  val table : (string * value) list -\u003e table\nend\nstructure TomlValue :\u003e TOML_VALUE\n```\n\n### Parser\n\nThe parse function is available as `ParseToml.parse`.\n\n```sml\nsignature PARSE_TOML = sig\n  type value\n  type table\n  type path = string list\n  val parse : (char, 'strm) StringCvt.reader -\u003e 'strm -\u003e table\nend\nstructure ParseToml :\u003e PARSE_TOML\n                       where type value = TomlValue.value\n                       where type table = TomlValue.table\n```\n\nNote that `ParseToml.parse` does not do UTF-8 validation.\nIf you want to check for invalid UTF-8 sequences, combine with `ValidateUtf8.validatingReader`.\nSee `test/decoder.sml` for example.\n\n### Error handling\n\nErrors are thrown as `TomlParseError.ParseError`.\n\n```sml\nsignature TOML_PARSE_ERROR = sig\n  datatype error = UNEXPECTED of { encountered : string, expected : string }\n                 | PREFIX_ZERO\n                 | INVALID_UNICODE_SCALAR\n                 | INVALID_DATE\n                 | INVALID_TIME\n                 | DUPLICATE_KEY of string list\n  val toString : error -\u003e string\n  exception ParseError of error\nend\nstructure TomlParseError :\u003e TOML_PARSE_ERROR\n```\n\n### Advanced usage\n\nIf you want to use a different value type than `TomlValue.value`, define your `TOML_VALUE_HANDLER` and use `ParseToml` functor to generate your parser.\n\n```sml\nsignature TOML_VALUE_HANDLER = sig\n  type value\n  type table\n  structure Integer : sig\n    type int\n    val + : int * int -\u003e int\n    val * : int * int -\u003e int\n    val fromInt : Int.int -\u003e int\n    val fromString : string -\u003e int option\n  end\n  val string : string -\u003e value\n  val integer : Integer.int -\u003e value\n  val float : string -\u003e value\n  val bool : bool -\u003e value\n  val datetime : string -\u003e value\n  val localDatetime : string -\u003e value\n  val date : string -\u003e value\n  val time : string -\u003e value\n  val array : value list -\u003e value\n  val subtable : table -\u003e value\n  val table : (string * value) list -\u003e table\nend\n\nfunctor ParseToml (Handler : TOML_VALUE_HANDLER) :\u003e PARSE_TOML\n                                                    where type value = Handler.value\n                                                    where type table = Handler.table\n```\n\n### UTF-8 validation\n\n```sml\nsignature VALIDATE_UTF8 = sig\n  exception InvalidUtf8\n  type 'strm validating_stream\n  val mkValidatingStream : 'strm -\u003e 'strm validating_stream\n  val validatingReader : (char, 'strm) StringCvt.reader -\u003e (char, 'strm validating_stream) StringCvt.reader\nend\nstructure ValidateUtf8 :\u003e VALIDATE_UTF8\n```\n\n## Test\n\nThis program passes [toml-test](https://github.com/toml-lang/toml-test):\n\n```sh-session\n$ cd test\n$ make\n$ env GOBIN=\"$(pwd)\" go install github.com/toml-lang/toml-test/cmd/toml-test@latest\n$ ./toml-test ./decoder\ntoml-test [./decoder]: using embedded tests: 415 passed,  0 failed\n```\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminoki%2Fsml-toml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminoki%2Fsml-toml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminoki%2Fsml-toml/lists"}