{"id":13678378,"url":"https://github.com/kjnilsson/fez","last_synced_at":"2025-04-10T02:22:36.446Z","repository":{"id":143427428,"uuid":"86670902","full_name":"kjnilsson/fez","owner":"kjnilsson","description":"F# to core erlang compiler experiment","archived":false,"fork":false,"pushed_at":"2019-05-16T08:43:48.000Z","size":12444,"stargazers_count":280,"open_issues_count":12,"forks_count":16,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-03T00:04:16.932Z","etag":null,"topics":["beam","erlang","fsharp","language"],"latest_commit_sha":null,"homepage":"","language":"F#","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/kjnilsson.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}},"created_at":"2017-03-30T07:11:27.000Z","updated_at":"2024-11-17T09:12:52.000Z","dependencies_parsed_at":"2024-01-07T00:08:06.450Z","dependency_job_id":null,"html_url":"https://github.com/kjnilsson/fez","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjnilsson%2Ffez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjnilsson%2Ffez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjnilsson%2Ffez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjnilsson%2Ffez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kjnilsson","download_url":"https://codeload.github.com/kjnilsson/fez/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143236,"owners_count":21054733,"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":["beam","erlang","fsharp","language"],"created_at":"2024-08-02T13:00:52.954Z","updated_at":"2025-04-10T02:22:36.419Z","avatar_url":"https://github.com/kjnilsson.png","language":"F#","funding_links":[],"categories":["F#","Compilers for Other Platforms"],"sub_categories":[],"readme":"# FEZ - an F# to core erlang experiment\n\n### What is it?\n\nFez is an early doors experiment in compiling [fsharp](http://fsharp.org) to\n[BEAM](https://github.com/erlang/otp) compatible\n[core erlang](https://www.it.uu.se/research/group/hipe/cerl).\n\nThe primary aim is to implement enough of the language to evaluate what how\nwell an ML type of language could become a practical language for writing\ncode to be run on the beam.\n\nShould this experiment succeed then it may lead to a fuller and usable fsharp\nbackend.\n\nSee [thoughts.md](https://github.com/kjnilsson/fez/blob/HEAD/thoughts.md)\nfor some discussions on potential implementation approaches.\n\n\n### Getting started\n\n#### Requirements\n\n* [.NET core](https://dotnet.github.io/)\n* [erlang 20+](https://www.erlang.org/downloads)\n\n\n```\n./build.sh   [on Linux/Mac]\n./build.cmd  [on Windows]\n\n```\n\nafter this you can:\n\n\n```\n./fezc \u003cfile.fs\u003e \u003cfile2.fs\u003e -o out     [on Linux/Mac]\n./fezc.cmd \u003cfile.fs\u003e \u003cfile2.fs\u003e -o out [on Windows]\n```\n\nto try to compile fsharp modules to the beam.\n\nYou can use the `--nobeam` parameter if you only want to compile as core erlang files.\n\nTo run the tests:\n\n```\n./run-tests.sh\n\n```\n\n\n#### Self contained releases\n\nSee [releases page](https://github.com/kjnilsson/fez/releases).\n\nDownload and extract the zip for your operating system. Then run: `fez help` to\nsee the available commands and options.\n\nTo compile:\n\n```\nfez compile \u003cfiles\u003e\n\n```\n\nThe module can then be run used in an erlang shell. The release ships with a\nset of `.beam` files that need to be included. E.g:\n\n```\n\nerl -pa \u003cpath_to_fez\u003e/ebin\n\n```\n\n\n\n### What works?\n\nFSharp is a multi-paradigmatic language and `fez` is targeting a solely functional\nlanguage (core erlang). Given this impedence mismatch it is only reasonable to\nexpect `fez` to adequately cover the functional language constructs of FSharp.\nThat said there are aspects of the imperative and object oriented paradigms that\ncan be covered, to a certain extent.\n\nThe most up-to-date resource for what language construct are covered is to look\nat [basics.fs](test/basics.fs) but it is fairly unstructured.\n\nThe lists below list feature that are implemented to one of the following\ndegrees:\n\n* `complete`\n\n    The feature is reasonably complete and unsupported APIs and constructs\n    either generate appropriate compile-time or run-time errors. Any strange\n    behaviour here needs to be reported!\n\n* `partial`\n\n    The feature is tried and proven viable but not yet fully implemented.\n\n* `prototype`\n\n    The feature is present to some limited degree. Likely to have unexpected\n    or unusual constraints. Feature may not be kept.\n\n* `unstarted`\n\n    The feature has not been started or investigated for feasibilty.\n\n#### Functional\n\n* Modules [`complete`]\n\n    An fsharp module is compiled as an erlang module. Nested modules are compiled\n    as indiviual erlang modules with fully-qualified names.\n\n* Functions [`complete`]\n\n    Private functions are not included in the erlang `export` statement. Function\n    application, currying, inner functions and lambdas are all supported.\n\n* Operators [`partial`]\n\n    Most of the common operators (`|\u003e`, `\u003e\u003e`, `+`, `-`, `/`, `snd`, `fst`) have\n    been implemented but not to completion. Please report omissions.\n\n* Pattern matching / control flow. [`complete`]\n\n    Pattern matching, including guards is supported as are `if then else`\n    expressions.\n\n* `list`/`seq` comprehensions [`partial`]\n\n    List and Seq comprehensions are supported but haven't been verified for\n    completeness.\n\n\n* List.* [`complete`]\n\n    List API is complete apart from any functions including `Array`.\n\n* Seq.* [`partial`]\n* Set.* [`partial`],\n* Option.* [`partial`]\n* Result.* [`complete`]\n* Map.* [`partial`],\n* String.* [`complete`]\n* Array* [`unstarted`]\n\n* Tuples [`complete`]\n* Records [`complete`]\n* Discriminated Unions [`complete`]\n* Active Patterns [`partial`]\n\n    Limited testing. Please report issues.\n\n* `try/finally/with` [`partial`]\n\n* Primitive types [`partial`]\n    * Currently all integers are translated to erlang integers and all\n      float types to erlang floats. Erlang integers are \"big ints\" hence things\n      like overflows and bitshifting probably wont work as expected.\n\n* `sprintf` / `printfn` [`partial`]\n\n* `query` expressions [`prototype`]\n\n    Only works with `seq`.\n\n* `async` [`partial`]\n\n    `Async.Start` and `Async.StartChild` will execute computation in a separate\n    process. The rest is mostly erased as all IO is already non-blocking in\n    erlang.\n\n* Computation Expressions [`partial`]\n\n    Limited testing.\n\n\n#### Object programming\n\n* Member methods on records and discriminated unions [`complete`]\n\n    NB: type based method overload do not work.\n\n* Static members on records and discriminated unions [`complete`]\n* Extension methods [`complete`]\n* Interface implementations on records and unions [`complete`]\n* `use` expressions [`complete`]\n\n* constructors [`prototype`]\n* inheritance [`prototype`]\n\n#### Imperative\n\n* Ref cells [`prototype`]\n\n    No automatic GC of the backing process dictionary key.\n\n* Fast integer for loop. [`partial`]\n* While loops [`unstarted`]\n\n\n#### Erlang interop\n\n* FFI [`partial`]\n\n    The `ModCall` attribute can be used to generate a function stub that delegates\n    to the configured erlang function.\n\n* ErlangTerms [`partial`]\n\n    The `ErlangTerm` attribute can be used to decorate a discriminated union\n    such that a more erlang compatible encoding will be generated instead of the\n    standard DU representation.\n\n        * Cases without fields will be lowercased and generated as atoms\n        * Cases with fields will be generated as tuples.\n\n\n### How can I help?\n\nTry it! Right now I need people to try stuff and find constructs that break or\ndon't behave as expected. Especially for functional code. Once you find something\n(and I'm sure you will) please raise an issue including the smallest possible\nrepro code.\n\nCode is also welcome of course. Especially for the standard library erlang\nmodules.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjnilsson%2Ffez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkjnilsson%2Ffez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjnilsson%2Ffez/lists"}