我在omegagb 的开发日志中看到了这个片段:
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
是用来定义新类型的。