alt.hn

6/23/2026 at 1:04:38 PM

Record type inference for dummies

http://haskellforall.com/2026/06/record-type-inference-for-dummies

by g0xA52A2A

6/26/2026 at 1:27:47 PM

Anonymous 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

by PashaGo

6/27/2026 at 6:57:26 AM

If a statically typed language has no support for record type (or the support it does have is insufficient for your purposes) then you are forced to find other ways to express your logic, so over time those other ways start feeling more natural due to familiarity, and then you end up feeling that you don't need record types (or more extensive support for them), which in turn leads language designers/implementors to leave it out, and so the cycle repeats.

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.

by Timwi

6/26/2026 at 5:34:05 AM

An anonymous record type in a language whose type system is an enum LangType in Rust is just HashMap<String, Box<LangType>>

My pet project requires an STLC with anonymous record types and type inference for anonymous records wasn't too bad

by vatsachak

6/26/2026 at 1:00:40 PM

Anonymous records aren't complex in principle. The main challenge Haskell has always faced in this area, is the simple fact that its type system (and syntax) weren't designed for anonymous records from the start, so they have to be shoehorned in without breaking existing semantics.

PureScript has much better support for row polymorphism for this reason.

by wavemode

6/26/2026 at 12:47:34 PM

The article missed Go’s anonymous structs:

    p := struct {
        Name string
        Age  int
    }{
        Name: "Alice",
        Age:  30,
    }

by antonvs

6/27/2026 at 6:59:51 AM

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.

by Timwi

6/27/2026 at 3:41:08 PM

The article mentions Typescript and Purescript under the heading "Static typing" - their definitions correspond exactly to the Go definition, with explicit types for the members.

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...)

by antonvs

6/27/2026 at 5:34:49 PM

Author here: those type annotations are optional in the case of TypeScript and PureScript; I only included the type annotations for clarity

That said, I didn't know about Go's support for inline struct definitions like that!

by Gabriel439

6/27/2026 at 2:18:31 AM

[flagged]

by moozechen