4 ms·
Ah, ok. I'll change my comment. I've heard it referred to as structural typing though, and googling "structural typing vs duck typing" gets the right results.
by tiglionabbit 10y ago
Ah, ok. I'll change my comment. I've heard it referred to as structural typing though, and googling "structural typing vs duck typing" gets the right results.
- leshow 10y agoThis 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.