3 ms·
It's not anything like Python. The language that it is most like is probably F# or OCaml. Python's type checkers are optional. They only verify code with annot
by lpil 2y ago
It's not anything like Python. The language that it is most like is probably F# or OCaml.
Python's type checkers are optional. They only verify code with annotations.
Gleam's type checker is mandatory, so it is impossible to compile code without type checking being performed. Type inference and checking are always fully performed, and adding type annotations doesn't make the compiler perform any extra checking.
> How do you even know the inferred type of your function is what you really think it should be? (I’m familiar with inference gone crazy from Haskell.)
Gleam doesn't have subtyping so this is typically trivial, but idiomatic code has all functions annotated for clarity. You can also hover in your editor, or read the documentation Gleam generates and publishes from code automatically.