【发布时间】:2018-03-30 19:11:28
【问题描述】:
shapeToPic :: Shape -> Picture
shapeToPic (Line a b) = polyline [a, b]
shapeToPic (Rectangle a b) = rectangle a b
形状由
定义data Shape = Rectangle Side Side
| Ellipse Side Side
| Polygon [Point]
| Line Point Point
deriving (Show)
我得到的错误:
<interactive>:55:41: error: * Couldn't match type(Integer, Integer)' 与Double' Expected type: Side Actual type: (Integer, Integer) * In the second argument ofRectangle',即(5, 7)' In the first argument ofshapeToPic',即(Rectangle (3, 3) (5, 7))' In the first argument ofdrawingOf',即 `(shapeToPic (矩形 (3, 3) (5, 7)))'
对 Haskell 来说有点新,我知道我需要放置一个“Side”类型,因为矩形需要 2 个点,但是,不确定问题出在哪里。我有2分?任何解决此问题的帮助将不胜感激!
【问题讨论】:
标签: haskell