aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter5_advanced_features/lesson06_externals/code.gleam
blob: 1101b826eabedc04930741c4145fe11d39dcc912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gleam/io

// A type with no Gleam constructors
pub type DateTime

// An external function that creates an instance of the type
@external(javascript, "./my_package_ffi.mjs", "now")
pub fn now() -> DateTime

// The `now` function in `./my_package_ffi.mjs` looks like this:
// export function now() {
//   return new Date();
// }

pub fn main() {
  io.debug(now())
}