|
|
|
|
|
by sshine
1221 days ago
|
|
Great article. Rust struct and Haskell records work pretty much the same way, too: // Rust
Item { name, price }
Item { name: name, price: price }
match item {
Item { name, .. } => todo!(),
}
corresponding to -- Haskell
Item { item, price }
Item { item = item, price = price }
case item of
Item { name, .. } -> undefined
Haskell has some opt-in flexibility wrt. packing and unpacking of field names [1].[1]: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/reco... |
|