Skip to content

Support referencing user-defined types from terms and other user-defined types#67

Merged
chrisdone merged 5 commits intomainfrom
cd/2024-12-31-ref-types-by-name
Dec 31, 2024
Merged

Support referencing user-defined types from terms and other user-defined types#67
chrisdone merged 5 commits intomainfrom
cd/2024-12-31-ref-types-by-name

Conversation

@chrisdone
Copy link
Copy Markdown
Owner

Adds support for referencing other types, as in this example:

-- User-defined types can reference other types now.
data Person = Person {
  name :: Text,
  address :: Main.Address
  }
data Address = Address {
  line1 :: Text, line2 :: Text
}
main = do
  let p :: Main.Person = Main.Person { name = "Chris", address = Main.Address { line1 = "1 North Pole", line2 = "Earth" } }
  Text.putStrLn $ Record.get @"name" p
  Text.putStrLn $
    Record.get @"line1" @Text $
      Record.get @"address" @Main.Address p
      --                    ^ Unfortunately this is needed or else the
      --                    nested access causes an ambiguous type
      --                    variable. But it's not too bad.

@chrisdone chrisdone merged commit 15c53bb into main Dec 31, 2024
@chrisdone chrisdone deleted the cd/2024-12-31-ref-types-by-name branch December 31, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant