How to modify just one field of a record without rewriting it completely?
在这里,我学到了一种有用的Haskell语法,可以在不完全重写记录的情况下修改记录的元素:
oldrecord { somefield = newvalue }
元组是否有可能类似的东西?
type ABigTuple = (Int, Int, Double, Int, String)
aBigTuple :: ABigTuple
aBigTuple = (5, 6, 3.2, 10, "asdf")
anotherBigTuple = -- replace the 3rd elt of the prev tuple with 5.5 i/o 3.2
这是否有可能类似于记录,还是我必须重写整个元组?
答案 0 :(得分:11)