swarm/data
Brent Yorgey 1a4dcd82f0
Require types to start with an uppercase letter (#1583)
Closes #1547 , which was caused by misspelled/nonexistent types being interpreted as type variables.  In #1550 I proposed one solution to the problem, namely, to stop implicitly quantifying types and require explicit `forall` on any polymorphic type.  This PR represents an alternative solution: to keep implicit quantification but require all types to start with an uppercase letter, as in Haskell.  I think I like this one better but I'm open to feedback.

Specifically, with this PR:
- All built-in type constructors (`Int`, `Cmd`, `Unit`, etc.) must start with a capital letter
- Type variables:
    - Must start with a lowercase letter or underscore
    - May not be named a lowercase version of a type constructor, *e.g.* `int`
        - This is important so that old code with lowercase types is not silently accepted by parsing the former types as implicitly quantified type variables; even in cases where old code no longer typechecks, this will give better error messages.
- Term variables:
    - May start with upper- or lowercase
    - May be named lowercase versions of type names, *e.g.* `let f : Int -> Int = \int. int + 1` is fine

This PR obviously represents a bigger breaking change.  Once we merge this we might consider adding an option to `swarm format` to be able to parse old code with lowercase types and then reformat it with uppercase, to aid in porting code.

Once this is merged I will also regenerate the wiki pages that mention types.

Closes #1550.
2024-05-21 04:16:32 +00:00
..
scenarios Require types to start with an uppercase letter (#1583) 2024-05-21 04:16:32 +00:00
schema reorganize code in Assembly.hs (#1829) 2024-05-10 17:47:40 +00:00
test/language-snippets Record best code size (#974) 2023-05-02 07:06:01 +00:00
worlds infinite improbability drive device enabling teleport command (#1724) 2024-01-14 00:31:12 +00:00
about.txt Update about to 2023 (#1384) 2023-07-20 13:04:56 +00:00
adjectives.txt Use a new opaque type for robots instead of strings (#303) 2022-03-02 03:00:44 +00:00
entities.yaml Require types to start with an uppercase letter (#1583) 2024-05-21 04:16:32 +00:00
logo.txt switch from U+2591 Light Shade to U+2592 Medium Shade (#449) 2022-06-20 17:56:55 +00:00
names.txt Use a new opaque type for robots instead of strings (#303) 2022-03-02 03:00:44 +00:00
recipes.yaml infinite improbability drive device enabling teleport command (#1724) 2024-01-14 00:31:12 +00:00
terrains.yaml extensible terrain (#1775) 2024-02-29 06:22:21 +00:00