我必须制作一个将 House 转换为 NHouse 的功能。
data House = House { hworking :: Working, hfinished :: Finished}
type Working = [Roof] , type Finished = [Roof]
data NHouse = NHouse {rot :: [NRoof]}
data NRoof = NRoof {h :: Roof, st :: Status }
data Status = Working | Finished
我想过做一个辅助功能,将 NRoof 中的每个屋顶转换,然后将其应用于房屋中的每个屋顶。
但我就是想不通。我正在做这样的事情:
nWorking :: Roof -> NRoof
nWorking x = NRoof {x, Working }