How Gleam compiles down to JavaScript.
0
gleam.js.txt.md
35 lines 514 B view raw view rendered
1Gleam: 2 3```gleam 4import gleam/io 5 6@external(javascript, "./js.js", "stringMe") 7pub fn string_me() -> String 8 9pub fn main() -> Nil { 10 io.println(string_me()) 11} 12``` 13 14JS: 15 16```js 17export function stringMe() { 18 return document.getElementById("input").value; 19} 20``` 21 22Compiled Gleam: 23 24```js 25import * as $io from "../gleam_stdlib/gleam/io.mjs"; 26import { stringMe as string_me } from "./js.js"; 27 28export { string_me }; 29 30export function main() { 31 return $io.println(string_me()); 32} 33``` 34 35And $io.println() is just console.log.