+<html class="has-navbar-fixed-top" lang="en"><head><title>Fable · Beam (Erlang)</title><meta http-equiv="content-type" content="text/html; charset=UTF-8" charSet="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" type="text/css" href="/style.css"/><script src="https://unpkg.com/scroll-into-view-if-needed@2.2.28/umd/scroll-into-view-if-needed.min.js"></script></head><body><nav class="navbar is-fixed-top is-spaced"><div class="container"><div class="navbar-brand"><a class="navbar-item title is-4" href="https://fable.io/">Fable</a></div><div class="navbar-menu"><div class="navbar-start"><a class="navbar-item is-active" href="/docs">Documentation</a><a class="navbar-item is-hidden-mobile" href="/packages/">Packages</a><a class="navbar-item is-hidden-mobile" href="/repl/">Try</a><a class="navbar-item" href="/blog/index.html">Blog</a><a class="navbar-item is-hidden-mobile" href="/community.html">Community</a><a class="navbar-item is-hidden-mobile" href="/resources.html">Resources</a><div class="navbar-item navbar-burger-dots is-hidden-tablet"><svg height="4" stroke="none" viewBox="0 0 22 4" width="22"><circle cx="2" cy="2" r="2"></circle><circle cx="2" cy="2" r="2" transform="translate(9,0)"></circle><circle cx="2" cy="2" r="2" transform="translate(18,0)"></circle></svg></div></div><div class="navbar-end is-hidden-mobile"><a class="navbar-item" href="https://github.com/fable-compiler/fable"><span class="icon"><i class=" fab fa-github fa-lg"></i></span></a><a class="navbar-item" href="https://twitter.com/FableCompiler"><span class="icon"><i class=" fab fa-twitter fa-lg"></i></span></a><a class="navbar-item" href="https://gitter.im/fable-compiler/Fable"><span class="icon"><i class=" fab fa-gitter fa-lg"></i></span></a><a class="navbar-item" href="https://www.youtube.com/channel/UC6m70Jyr65ogDySbK7aMmzg/videos"><span class="icon"><i class=" fab fa-youtube fa-lg"></i></span></a></div></div><div class="nacara-navbar-menu"><a class="nacara-navbar-menu-item" href="/packages/">Packages</a><a class="nacara-navbar-menu-item" href="/repl/">Try</a><a class="nacara-navbar-menu-item" href="/community.html">Community</a><a class="nacara-navbar-menu-item" href="/resources.html">Resources</a><a class="nacara-navbar-menu-item" href="https://github.com/fable-compiler/fable">Github</a><a class="nacara-navbar-menu-item" href="https://twitter.com/FableCompiler">Twitter</a><a class="nacara-navbar-menu-item" href="https://gitter.im/fable-compiler/Fable">Gitter</a><a class="nacara-navbar-menu-item" href="https://www.youtube.com/channel/UC6m70Jyr65ogDySbK7aMmzg/videos">Youtube</a></div></div></nav><div class="grey-overlay"></div><div class="nacara-content"><div class="container"><div class="mobile-menu"><nav class="breadcrumb"><ul><li><a class="menu-trigger"><span></span><span></span><span></span></a></li><li class="is-active"><a>Documentation</a></li><li class="is-active"><a>Getting started</a></li><li class="is-active"><a>Beam (Erlang)</a></li></ul></nav></div><div class="columns is-gapless is-mobile"><div class="column is-menu-column is-3-desktop is-hidden-touch"><div class="menu-container"><aside class="menu"><p class="menu-label">Introduction</p><ul class="menu-list"><li><a class=" " href="/docs/index.html">What is Fable?</a></li><li><a class=" " href="/docs/introduction/dotnet-users-read-this.html">Are you a .NET developer?</a></li><li><a class=" " href="/docs/introduction/js-users-read-this.html">Are you a JS developer?</a></li></ul><p class="menu-label">Getting started</p><ul class="menu-list"><li><a class=" " href="/docs/getting-started/setup.html">Setup</a></li><li><a class=" " href="/docs/getting-started/your-first-fable-project.html">Start a new project</a></li><li><a class=" " href="/docs/getting-started/javascript.html">JavaScript</a></li><li><a class=" " href="/docs/getting-started/typescript.html">TypeScript</a></li><li><a class=" " href="/docs/getting-started/python.html">Python</a></li><li><a class=" is-active" href="/docs/getting-started/beam.html">Beam (Erlang)</a></li><li><ul class="table-of-content"><li data-toc-rank="2"><a href="#prerequisites" data-toc-element="true">Prerequisites</a></li></ul></li><li><a class=" " href="/docs/getting-started/rust.html">Rust</a></li><li><a class=" " href="/docs/getting-started/cli.html">Fable CLI</a></li></ul><p class="menu-label">Your Fable project</p><ul class="menu-list"><li><a class=" " href="/docs/your-fable-project/use-a-fable-library.html">Use a Fable library</a></li><li><a class=" " href="/docs/your-fable-project/author-a-fable-library.html">Author a Fable package</a></li></ul><p class="menu-label">New to F#?</p><ul class="menu-list"><li><a class=" " href="/docs/new-to-fsharp/learning-the-language.html">Learning the language</a></li><li><a class=" " href="/docs/new-to-fsharp/let-keyword.html">The let keyword</a></li><li><a class=" " href="/docs/new-to-fsharp/project-file.html">The project file</a></li></ul><p class="menu-label">JavaScript</p><ul class="menu-list"><li><a class=" " href="/docs/javascript/build-and-run.html">Build and Run</a></li><li><a class=" " href="/docs/javascript/features.html">Features</a></li><li><a class=" " href="/docs/javascript/compatibility.html">.NET and F# compatibility</a></li></ul><p class="menu-label">TypeScript</p><ul class="menu-list"><li><a class=" " href="/docs/typescript/build-and-run.html">Build and Run</a></li><li><a class=" " href="/docs/typescript/features.html">Features</a></li><li><a class=" " href="/docs/typescript/compatibility.html">.NET and F# compatibility</a></li></ul><p class="menu-label">Python</p><ul class="menu-list"><li><a class=" " href="/docs/python/build-and-run.html">Build and Run</a></li><li><a class=" " href="/docs/python/features.html">Features</a></li><li><a class=" " href="/docs/python/compatibility.html">.NET and F# compatibility</a></li></ul><p class="menu-label">Beam (Erlang)</p><ul class="menu-list"><li><a class=" " href="/docs/beam/build-and-run.html">Build and Run</a></li><li><a class=" " href="/docs/beam/features.html">Features</a></li><li><a class=" " href="/docs/beam/compatibility.html">.NET and F# compatibility</a></li></ul><p class="menu-label">Miscellaneous</p><ul class="menu-list"><li><a class=" " href="/docs/miscellaneous/official-samples.html">Check official samples</a></li><li><a class=" " href="/docs/miscellaneous/fable-in-videos.html">Fable in videos</a></li></ul></aside></div></div><div class="column is-9-desktop is-full-touch"><section class="section"><div class="content"><header class="page-header"><div class="columns is-vcentered"><div class="column"><nav class="breadcrumb is-category-navigation is-hidden-touch"><ul><li class="is-active"><a>Documentation</a></li><li class="is-active"><a>Getting started</a></li><li class="is-active"><a>Beam (Erlang)</a></li></ul></nav></div><div class="column is-narrow"><a class="button is-hidden-touch is-ghost" target="_blank" href="https://github.com/fable-compiler/fable-compiler.github.io/edit/dev/docs/docs/getting-started/beam.md">Edit</a></div></div><h1 class="title is-1">Beam (Erlang)</h1></header><div><style class=grvsc-styles>.grvsc-container{overflow:auto;position:relative;-webkit-overflow-scrolling:touch;padding-top:1rem;padding-top:var(--grvsc-padding-top,var(--grvsc-padding-v,1rem));padding-bottom:1rem;padding-bottom:var(--grvsc-padding-bottom,var(--grvsc-padding-v,1rem));border-radius:8px;border-radius:var(--grvsc-border-radius,8px);font-feature-settings:normal;line-height:1.4}.grvsc-code{display:table}.grvsc-line{display:table-row;box-sizing:border-box;width:100%;position:relative}.grvsc-line>*{position:relative}.grvsc-gutter-pad{display:table-cell;padding-left:.75rem;padding-left:calc(var(--grvsc-padding-left,var(--grvsc-padding-h,1.5rem))/ 2)}.grvsc-gutter{display:table-cell;-webkit-user-select:none;-moz-user-select:none;user-select:none}.grvsc-gutter::before{content:attr(data-content)}.grvsc-source{display:table-cell;padding-left:1.5rem;padding-left:var(--grvsc-padding-left,var(--grvsc-padding-h,1.5rem));padding-right:1.5rem;padding-right:var(--grvsc-padding-right,var(--grvsc-padding-h,1.5rem))}.grvsc-source:empty::after{content:' ';-webkit-user-select:none;-moz-user-select:none;user-select:none}.grvsc-gutter+.grvsc-source{padding-left:.75rem;padding-left:calc(var(--grvsc-padding-left,var(--grvsc-padding-h,1.5rem))/ 2)}.grvsc-has-line-highlighting>.grvsc-code>.grvsc-line::before{content:' ';position:absolute;width:100%}.grvsc-line-diff-add::before{background-color:var(--grvsc-line-diff-add-background-color,rgba(0,255,60,.2))}.grvsc-line-diff-del::before{background-color:var(--grvsc-line-diff-del-background-color,rgba(255,0,20,.2))}.grvsc-line-number{padding:0 2px;text-align:right;opacity:.7}.atom-one-light{background-color:#fafafa;color:#383a42}.atom-one-light .mtk1{color:#383a42}.atom-one-light .mtk10{color:#50a14f}.atom-one-light .grvsc-line-highlighted::before{background-color:var(--grvsc-line-highlighted-background-color,rgba(0,0,0,.05));box-shadow:inset var(--grvsc-line-highlighted-border-width,4px) 0 0 0 var(--grvsc-line-highlighted-border-color,rgba(0,0,0,.2))}</style><article class="message is-warning"><div class=message-body><div><p>Beam target is in alpha meaning that breaking changes can happen between minor versions.</div></div></article><p>This section is specific to Beam (Erlang) targeting. It will guide you through the process of setting up your project and using Fable to compile F# to Erlang.<article class="message is-info"><div class=message-body><div><p>Please make sure you followed the <a href=/docs/2-steps/your-first-fable-project>Fable setup guide</a> before continuing.</div></div></article><h2 id=prerequisites>Prerequisites<a href=#prerequisites aria-hidden=true tabindex=-1><span class=anchor>#</span></a></h2><p>You need <a href=https://www.erlang.org/downloads>Erlang/OTP</a> 24 or higher installed. Verify with:<pre class="atom-one-light grvsc-container"data-index=0 data-language=bash><code class=grvsc-code><span class=grvsc-line><span class=grvsc-source><span class=mtk1>erl -eval </span><span class=mtk10>'erlang:display(erlang:system_info(otp_release)), halt().'</span><span class=mtk1> -noshell</span></span></span></code></pre><ul class=textual-steps><li><p>Compile your project to Erlang:<pre class="atom-one-light grvsc-container"data-index=1 data-language=bash><code class=grvsc-code><span class=grvsc-line><span class=grvsc-source><span class=mtk1>dotnet fable --lang beam</span></span></span></code></pre><p>This generates <code>.erl</code> files in the project directory (where the <code>.fsproj</code> is) by default.<li><p>Compile the generated Erlang files:<pre class="atom-one-light grvsc-container"data-index=2 data-language=bash><code class=grvsc-code><span class=grvsc-line><span class=grvsc-source><span class=mtk1>erlc -o output/fable_modules/fable-library-beam output/fable_modules/fable-library-beam/*.erl</span></span></span>
0 commit comments