我看到這個片段在the devlog of omegagb:什麼數據...在Haskell中意味着什麼?
data ExecutionAST result where
Return :: result -> ExecutionAST result
Bind :: (ExecutionAST oldres) -> (oldres -> ExecutionAST result) ->
ExecutionAST result
WriteRegister :: M_Register -> Word8 -> ExecutionAST()
ReadRegister :: M_Register -> ExecutionAST Word8
WriteRegister2 :: M_Register2 -> Word16 -> ExecutionAST()
ReadRegister2 :: M_Register2 -> ExecutionAST Word16
WriteMemory :: Word16 -> Word8 -> ExecutionAST()
ReadMemory :: Word16 -> ExecutionAST Word8
什麼是data ... where
是什麼意思?我認爲關鍵字data
用於定義新類型。
能有人向我解釋,爲什麼這裏需要GADT? – wliao
@wliao:添加了解釋。 – sdcvvc
我發現你的解釋比視頻剪輯更好。謝謝。 – wliao