3 ms·
This isn't the same concept as structural typing I don't think, but purescript has something called extensible records that quite similar to what the previous p
by leshow 10y ago
This isn't the same concept as structural typing I don't think, but purescript has something called extensible records that quite similar to what the previous poster describes:
function :: forall a. { f :: String, g :: String | a } -> String
This is a function that takes an extensible record. i.e. 'a' is some type which has fields f of type String and g of type String, at minimum.
- wyager 10y agoExtensible records are a form of structural typing. Purescript has good support for both nominal (via data declarations) and structural (via extensible records) typing. It has the best native support for both paradigms of any language that I can think of off the top of my head.
- mseepgood 10y agofunc example(x interface{f() string; g() string}) string { } Go's structural typing is based on methods instead of fields, but it's structural typing as well.