3 ms·
It is the same concept. In rust structs are defined with the struct keyword, and can have methods. And there is no class keyword for classes. In haskell, struc
by mejutoco 4y ago
It is the same concept. In rust structs are defined with the struct keyword, and can have methods. And there is no class keyword for classes.
In haskell, structs are defined with the keyword data. Maybe that is where the inspiration comes from.
https://lotz84.github.io/haskellbyexample/ex/structs https://lotz84.github.io/haskellbyexample/ex/structs
In any case, it seems each language chooses equally confusing keywords. Syntax is not a big deal IMO if the concept is clear.
- eru 4y ago> In haskell, structs are defined with the keyword data. Maybe that is where the inspiration comes from. In Haskell, Rust and Python you can also just have tuples, if you want to. In Haskell you can use `newtype` or `type` to name your tuples and use them as records. Of course, as you say, you can also use the `data` keyword in Haskell. Or you can use church encoding to use functions as records.. Lots of (confusing) possibilities.