Record types vs. "Product" types?
App Development2 posts330 views3 likesLast activity Nov 2022
WA
WallaceKellyOP
Nov 2022While learning Daml, I relied heavily on the Fast Track to Daml Cheat Sheet. In the Data section, there are examples for both “Record” and “Product” types.
Record data MyRecord = MyRecord { label1 : Int, label2 : Text}
Product type data IntAndText = IntAndText with myInt : Int, myText : Text
However, as I now read An Introduction to Daml / Data Types, I find this example of a “Record”:
data MyRecord = MyRecord with
my_txt : Text
my_int : Int
my_dec : Decimal
my_list : [Text]
I get the sneaking suspicion that the two ideas (record types and product types) are the same thing. And that the { } syntax and the with syntax are two alternative syntaxes.
Is there any difference between these two things?
CO
cocreature
Nov 2022You got the right idea:
Record types and product types are usually used as synonymous at least in Daml. And {} and with are just different syntax for defining them. {} is what we inherit from Haskell and then with got added in Daml as an (arguably) more friendly alternative.