unison/unison-src/transcripts/type-modifier-required.output.md
2022-03-07 14:11:10 -08:00

1.3 KiB

Type modifiers are required

Types needs to be prefixed with either unique or structural:

type Abc = Abc 

  I expected to see `structural` or `unique` at the start of
  this line:
  
      1 | type Abc = Abc 
  
  Learn more about when to use `structural` vs `unique` in the
  Unison Docs:
  https://www.unison-lang.org/learn/language-reference/unique-types/

Abilities needs to be prefixed with either unique or structural:

ability MyAbility where const : a 

  I expected to see `structural` or `unique` at the start of
  this line:
  
      1 | ability MyAbility where const : a 
  
  Learn more about when to use `structural` vs `unique` in the
  Unison Docs:
  https://www.unison-lang.org/learn/language-reference/unique-types/

There should be no errors when unique or structural is provided:

structural type AbcS = AbcS
unique type AbcU = AbcU
structural ability MyAbilityS where const : a 
unique ability MyAbilityU where const : a 

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:
  
    ⍟ These new definitions are ok to `add`:
    
      structural type AbcS
        (also named builtin.Unit)
      unique type AbcU
      structural ability MyAbilityS
      unique ability MyAbilityU