Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lue-bird/elm-syntax-to-haxe
transpile elm to haxe
https://github.com/lue-bird/elm-syntax-to-haxe
elm elm-syntax haxe multi-platform transpiler
Last synced: about 9 hours ago
JSON representation
transpile elm to haxe
- Host: GitHub
- URL: https://github.com/lue-bird/elm-syntax-to-haxe
- Owner: lue-bird
- License: mit
- Created: 2025-02-12T00:40:19.000Z (about 21 hours ago)
- Default Branch: main
- Last Pushed: 2025-02-12T00:42:32.000Z (about 21 hours ago)
- Last Synced: 2025-02-12T01:34:58.196Z (about 21 hours ago)
- Topics: elm, elm-syntax, haxe, multi-platform, transpiler
- Language: Elm
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changes.md
- License: LICENSE
Awesome Lists containing this project
README
> Status: still need to work around haxe not supporting values declarations with generics
Print pure [`elm-syntax`](https://dark.elm.dmy.fr/packages/stil4m/elm-syntax/latest/) declarations as
[haxe](https://haxe.org/) code.```elm
import Elm.Parser
import ElmSyntaxToHaxe"""module Sample exposing (..)
plus2 : Int -> Int
plus2 n =
n + ([ 2 ] |> List.sum)
"""
|> Elm.Parser.parseToFile
|> Result.mapError (\_ -> "failed to parse elm source code")
|> Result.map
(\syntaxModule ->
[ syntaxModule ]
|> ElmSyntaxToHaxe.modules
|> .declarations
|> ElmSyntaxToHaxe.haxeDeclarationsToModuleString
)
-->
Ok """..some type declarations and imports..
class Elm {
..some default declarations..static function sample_plus2(n:Float):Float {
return basics_add(n, list_sum(List_Cons(2.0, List_Empty)));
}
}
"""
```To try it out, you can
run [this node script](https://github.com/lue-bird/elm-syntax-to-haxe/tree/main/node-elm-to-haxe).### why haxe?
- it's pretty much a superset of elm which makes transpiling easy (good type inference, choice types, records, value-ish semantics)
- it has best-class platform support via transpilation (c++, c via hashlink, java, jvm, c#, js, ...)### be aware
- only a subset of elm is currently supported. not supported:
- `elm/regex`, `elm/file`, `elm/bytes`, `elm/http`, `elm/random`, `elm/url`, `elm/json`, `elm/parser`, `elm/virtual-dom`,
`elm/html`, `elm/svg`, `elm/browser`, `elm/time`, `elm-explorations/markdown`, `elm-explorations/webgl`, `elm-explorations/benchmark`, `elm-explorations/linear-algebra`
- `Platform`, `Platform.Cmd`, `Platform.Sub`, `Task`, `Process`
- **record update**, currying, ports, glsl, the prefix operator functions `(>>)` and `(<<)`
- `++` will default to `List.append` unless one of the arguments is a string literal. So e.g. use `a ++ b ++ ""` to append string variables (which is also faster in elm)
- `List.minimum`, `List.maximum`, `Basics.min`, `Basics.max` will only work with numbers.
- potential future candidates: `Basics.clamp`, `Basics.degrees`, `Basics.turns`,
`Basics.radians`, `Basics.logBase`, `Basics.toPolar`, `Basics.fromPolar`, `Basics.never`, `Basics.sin`, `Basics.cos`, `Basics.tan`, `Basics.asin`, `Basics.acos`, `Basics.atan`, `Basics.atan2`, `Basics.e`, `Basics.pi`,
`List.map3/4/5`, `List.head`, `List.tail`, `List.partition`, `Char.toLocaleLower`, `Char.toLocaleUpper`, `Char.isAlpha`, `Char.isAlphaNum`, `Char.isDigit`, `Char.isOctDigit`, `Char.isHexDigit`, `Bitwise`, `Array`.
Any help appreciated!
- no checks are performed before transpiling to haxe. So if you don't add a compile check of your elm input,
you might e.g. get a running program that circumvents an elm opaque type or phantom type, or a haxe program that can't be run
- not much care has been put into making the resulting code readable or even conventionally formatted
and comments are not preservedPlease [report any issues](https://github.com/lue-bird/elm-syntax-to-haxe/issues/new) you notice <3