Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Gleam unexpected struct

I’m 100% new to Gleam and tried a simple struct example I found.

// src/first.gleam

pub struct Cat {
  name: String
  is_cute: Bool
}

pub fn main() {
  Cat(name: "Nubi", is_cute: True)
}

However, I get a compile error:

% gleam run
error: Syntax error
  ┌─ C:\Users\Sven\programming\Gleam\first\src\first.gleam:3:1
  │
3 │ pub struct Cat {
  │ ^^^ I was not expecting this

Expected one of:
An import, const, type, if block, or function.

What is the solution to this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Version output:
% gleam --version gleam 1.0.0

>Solution :

Seems that the compiler gives a hint: Expected one of: An import, const, type, if block, or function..

pub type Cat {
  Cat(name: String, is_cute: Bool)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading