0
我必須創建一個函數將House轉換爲NHouse。Haskell代數類型和函數轉換
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輔助功能,然後APLY,爲家中的每個屋頂。
但我只是無法弄清楚。我正在做這樣的事情:
nWorking :: Roof -> NRoof
nWorking x = NRoof {x, Working }
看了你的問題別人看了他們。(什麼是拍賣?) – Satvik