问题:我有许多常见字段的不同记录类型.我如何"包含"记录类型定义中的公共字段?
例:
newtype RecordType1 = RecordType1 { a :: Int, b :: Int, y :: String }
newtype RecordType2 = RecordType2 { a :: Int, b :: Int, z :: Boolean }
Run Code Online (Sandbox Code Playgroud)
如何在PureScript中编写等效的?
newtype RecordType1 = RecordType1 { CommonFields, y :: String }
newtype RecordType2 = RecordType2 { CommonFields, z :: Boolean }
Run Code Online (Sandbox Code Playgroud)
" PureScript类型系统概述"中Union
提到的类型类可能是我所寻求的......但它似乎是自PureScript 0.12.0以来的.
有什么建议?有什么我想念的吗?
谢谢!