小编Mat*_*ois的帖子

如何在PureScript中组合记录类型的行?(PureScript 0.12.0中是否有Union类型类的替代方法?)

问题:我有许多常见字段的不同记录类型.我如何"包含"记录类型定义中的公共字段?

例:

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以来的.

有什么建议?有什么我想念的吗?

谢谢!

union records rows purescript

3
推荐指数
2
解决办法
365
查看次数

标签 统计

purescript ×1

records ×1

rows ×1

union ×1