我有以下数据可以有或没有船:
data LaserCollisionResult = NoCollision | LaserToLaserCollision Ship | LaserToShipCollision Ship deriving (Eq, Show)
然后,稍后,我尝试检查 LaserCollisionResult 是否属于 LaserToLaserCollision 类型,但出现错误。我的 lambda 函数是这样的:
laserPaths' = map (\(p,r) -> if r == LaserToLaserCollision then doSomethingWith p else p) $ zip laserPaths laserCollisionResults
我得到的错误是:
Couldn't match type 'LaserCollisionResult' with 'Ship -> LaserCollisionResult'
Expected type: [Ship -> LaserCollisionResult]
Actual type: [LaserCollisionResult]
In the second argument of 'zip', namely laserCollisionResults.
如何检查laserCollisionResults 中的LaserCollisionResult 是否属于LaserToLaserCollision 类型?