{"id":31483340,"url":"https://github.com/lue-bird/elm-syntax-to-moonbit","last_synced_at":"2025-10-19T09:53:23.464Z","repository":{"id":315903526,"uuid":"1060953479","full_name":"lue-bird/elm-syntax-to-moonbit","owner":"lue-bird","description":"transpile elm to moonbit","archived":false,"fork":false,"pushed_at":"2025-09-21T13:13:50.000Z","size":1003,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-21T15:13:06.892Z","etag":null,"topics":["elm","elm-syntax","moonbit","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lue-bird.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-20T23:51:55.000Z","updated_at":"2025-09-21T13:13:53.000Z","dependencies_parsed_at":"2025-09-21T15:13:18.060Z","dependency_job_id":"00ce6945-82df-4092-867e-632ef18d4eaf","html_url":"https://github.com/lue-bird/elm-syntax-to-moonbit","commit_stats":null,"previous_names":["lue-bird/elm-syntax-to-moonbit"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lue-bird/elm-syntax-to-moonbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-syntax-to-moonbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-syntax-to-moonbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-syntax-to-moonbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-syntax-to-moonbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lue-bird","download_url":"https://codeload.github.com/lue-bird/elm-syntax-to-moonbit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lue-bird%2Felm-syntax-to-moonbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277974435,"owners_count":25908398,"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-02T02:00:08.890Z","response_time":67,"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":["elm","elm-syntax","moonbit","transpiler"],"created_at":"2025-10-02T08:08:32.702Z","updated_at":"2025-10-02T08:08:35.173Z","avatar_url":"https://github.com/lue-bird.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"Print [`elm-syntax`](https://dark.elm.dmy.fr/packages/stil4m/elm-syntax/latest/) declarations as [moonbit](https://docs.moonbitlang.com/en/latest/index.html) code.\nTo try it out, you can\nrun [this script](https://github.com/lue-bird/elm-syntax-to-moonbit/tree/main/node-elm-to-moonbit).\n\n```elm\nimport Elm.Parser\nimport ElmSyntaxToMoonbit\n\n\"\"\"module Sample exposing (..)\n\nplus2 : Float -\u003e Float\nplus2 n =\n    n + ([ 2.0 ] |\u003e List.sum)\n\"\"\"\n    |\u003e Elm.Parser.parseToFile\n    |\u003e Result.mapError (\\_ -\u003e \"failed to parse elm source code\")\n    |\u003e Result.map\n        (\\syntaxModule -\u003e\n            [ syntaxModule ]\n                |\u003e ElmSyntaxToMoonbit.modules\n                |\u003e .declarations\n                |\u003e ElmSyntaxToMoonbit.moonbitDeclarationsToModuleString\n        )\n--\u003e\nOk \"\"\"...\npub fn sample_plus2(n: Double) -\u003e Double {\n    basics_add(n, list_sum_float(@list.of([2.0])))\n}\n\"\"\"\n```\n\n### be aware\n\n- not supported are\n    - ports that use non-json values like `port sendMessage : String -\u003e Cmd msg`, glsl, phantom types, `==` on a generic value\n    - `elm/file`, `elm/http`, `elm/browser`, `elm-explorations/markdown`, `elm-explorations/webgl`, `elm-explorations/benchmark`, `elm/regex` (because no support in `moonbitlang/core`), `elm-explorations/linear-algebra` (because no support in `moonbitlang/core`)\n    - `Task`, `Process`, `Platform.Task`, `Platform.ProcessId`, `Platform.Router`, `Platform.sendToApp`, `Platform.sendToSelf`, `Random.generate`, `Time.now`, `Time.every`, `Time.here`, `Time.getZoneName`, `Bytes.getHostEndianness`\n    - extensible record types outside of module-level value/function declarations. For example, these declarations might not work:\n        ```elm\n        -- in variant value\n        type Named rec = Named { rec | name : String }\n        -- in let type, annotated or not\n        let getName : { r | name : name } -\u003e name\n        ```\n        Allowed is only record extension in module-level value/functions, annotated or not:\n        ```elm\n        userId : { u | name : String, server : Domain } -\u003e String\n        ```\n        In the non-allowed cases listed above, we assume that you intended to use a regular record type with only the extension fields which can lead to moonbit compile errors if you actually pass in additional fields.\n    - The transpiled list type is not yet comparable (unlike elm lists), it is implemented but not yet published, see https://github.com/moonbitlang/core/issues/2757\n    - elm's `Char.toLocale[Case]` functions will just behave like `Char.to[Case]`\n    - elm's `VirtualDom/Html/Svg.lazyN` functions will still exist for compatibility but they will behave just like constructing them eagerly\n- dependencies cannot internally use the same module names as the transpiled project\n- the resulting code might not be readable or even conventionally formatted and comments are not preserved\n\nPlease [report any issues](https://github.com/lue-bird/elm-syntax-to-moonbit/issues/new) you notice \u003c3\n\n### why moonbit?\n\n- it has first-class support for wasm (and native)\n- it feels like a superset of elm which makes transpiling and \"ffi\" easier\n- it supposedly has fast compile times (I have yet to verify this claim)\n\n### why not moonbit?\n\n- the language is bloated\n- the language is very young and tooling like the build CLI are fragile\n- the language's promotion has made overly big claims and has the classic AI bullshit\n- the ecosystem is tiny so you will likely need to write your own FFI wrappers and similar\n\n### how do I use the transpiled output?\n\nAn example can be found in [`example-hello-world/`](https://github.com/lue-bird/elm-syntax-to-moonbit/tree/main/example-hello-world).\n\nIn your elm project, add `moon.pkg.json`\n```json\n{\"is-main\": true}\n```\nand `moon.mod.json`\n```json\n{\"name\": \"your_project_name\"}\n```\n(If you know of a simpler setup, please [open an issue](https://github.com/lue-bird/elm-syntax-to-moonbit/issues/new))\n\nand a file `main.mbt` that uses `elm.mbt`:\n\n```moonbit\nmod elm\nprint(your_module_your_function(\"yourInput\"))\n```\n\nwhere `your_module_your_function(firstArgument, secondArgument)` is the transpiled elm function `Your.Module.yourFunction firstArgument secondArgument`. (If the value/function contains extensible records, search for `your_module_your_function_` with the underscore to see the different specialized options)\n\nRun with\n```bash\ncargo run\n```\n\nIf something unexpected happened,\nplease [report an issue](https://github.com/lue-bird/elm-syntax-to-moonbit/issues/new).\n\nIn the transpiled code, you will find these types:\n\n- elm `Bool` (`True` or `False`) → moonbit `Bool` (`true` or `false`), `Char` (`'a'`) → `Char` (`'a'`), `( Bool, Char )` → `( Bool, Char )`\n- elm `Int`s will be of type `Int64`. Create and match by appending `L` to any number literal or using `Int::to_int64`/`Int64::from_int`\n- elm `Float`s will be of type `f64`. Create and match by using any number literal with a decimal point\n- elm `String`s (like `\"a\"`) will be of the custom type `StringString`.\n  Create from literals or other string slices with (`StringString::One(\"a\")`). Match with `your_string if string_string_string_equals_stringing(your_string, \"some string\")`\n- elm records like `{ y : Float, x : Float }` will be of type `GeneratedXY\u003cf64, f64\u003e` with the fields sorted and can be constructed and matched with `{ x: _, y: _ }`. `record.x` access also works\n- elm `List`s will be of type `@list.List`.\n  Create and match with the help of [`@list`/`List::`](https://mooncakes.io/docs/moonbitlang/core/list)\n- elm `Array`s will be of type `@immut/array.Array`.\n  Create and match with the helpers in [`@immut/array`](https://mooncakes.io/docs/moonbitlang/core/immut/array)\n- elm `Set`s will be of type `@immut/sorted_set.SortedSet`.\n  Create and match with the helpers in [`@immut/sorted_set`](https://mooncakes.io/docs/moonbitlang/core/immut/sorted_set)\n- elm `Dict`s will be of type `@immut/sorted_map.SortedMap`.\n  Create and match with the helpers in [`@immut/sorted_map`](https://mooncakes.io/docs/moonbitlang/core/immut/sorted_map)\n- elm `Json.Encode.Value`/`Json.Decode.Value`s will be of type `Json`.\n  Create and match with the help of [`@json.`/`Json::`](https://mooncakes.io/docs/moonbitlang/core/json)\n- elm `Bytes.Bytes` will be of type `Bytes`.\n  Create and match with the help of [`@bytes`/`Bytes::`](https://mooncakes.io/docs/moonbitlang/core/bytes)\n- a transpiled elm app does not run itself.\n  An elm main `Platform.worker` program type will literally just consist of fields `init`, `update` and `subscriptions` where\n  subscriptions/commands are returned as a list of `PlatformSubSingle`/`PlatformCmdSingle` with possible elm subscriptions/commands in a choice type.\n  It's then your responsibility as \"the platform\" to perform effects, create events and manage the state. For an example see [example-worker-blocking/](https://github.com/lue-bird/elm-syntax-to-moonbit/tree/main/example-worker-blocking) \u0026 [example-worker-concurrent/](https://github.com/lue-bird/elm-syntax-to-moonbit/tree/main/example-worker-concurrent)\n\n### improvement ideas\n\n- try and benchmark switching `String` representation from `One \u0026str | Append String String` to `(StringBuilder) -\u003e StringBuilder`\n- if lambda is called with a function, always inline that function\n- your idea 👀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-syntax-to-moonbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flue-bird%2Felm-syntax-to-moonbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flue-bird%2Felm-syntax-to-moonbit/lists"}