Record type inference for dummies
haskellforall.com
Record type inference for dummies
1–10 of 11 posts
Re: Record type inference for dummies
#2My pet project requires an STLC with anonymous record types and type inference for anonymous records wasn't too bad
Re: Record type inference for dummies
#3 p := struct {
Name string
Age int
}{
Name: "Alice",
Age: 30,
}Re: Record type inference for dummies
#4An anonymous record type in a language whose type system is an enum LangType in Rust is just HashMap > My pet project requires an STLC with anonymous record types and type inference for anonymous records wasn't too bad
Re: Record type inference for dummies
#5An anonymous record type in a language whose type system is an enum LangType in Rust is just HashMap > My pet project requires an STLC with anonymous record types and type inference for anonymous records wasn't too bad
PureScript has much better support for row polymorphism for this reason.
Re: Record type inference for dummies
#6Re: Record type inference for dummies
#7Re: Record type inference for dummies
#8Anonymous records feel like one of those features that are obviously useful once you work with JSON-heavy systems, but surprisingly uncommon in statically typed languages
I'm not sure I agree that anonymous records are “obviously useful” when working with JSON. JSON is not typed, so if you want your deserialized JSON to be statically typed, you need to declare typed records outside of the JSON, so I'd say it's far more useful to use type declarations that are not anonymous.
That said, anonymous types are incredibly useful in general. I work with C# a lot and its support for them is rather shallow. In particular, there is no “with” expression equivalent.
Re: Record type inference for dummies
#9The article missed Go’s anonymous structs: p := struct { Name string Age int }{ Name: "Alice", Age: 30, }
Re: Record type inference for dummies
#10The article missed Go’s anonymous structs: p := struct { Name string Age int }{ Name: "Alice", Age: 30, }
Technically anonymous I suppose because the struct is not named, but the article is mostly about type inference while your example has every type made explicit.
I was just saying that for completeness, Go should probably be mentioned in that list since it's become a pretty significant language.
(For the record, I'm an absolute Go hater, but I'm also a PL enthusiast, so...)