Html5 canvas PureScript";无法匹配类型";记录错误

Html5 canvas PureScript";无法匹配类型";记录错误,html5-canvas,purescript,Html5 Canvas,Purescript,我遵循PureScript书中的一个函数,我必须定义一个函数renderPath,它接受一个点s(x和y)数组,并使用它们绘制一条路径(使用PureScript画布),其中点定义为 type Point = { x :: Number, y :: Number } 我决定将函数分为两个步骤。第一步是将移动到阵列中的第一个点,然后在其余点上使用lineTo 这是我到目前为止编写的函数,它只有第一步。但我有一个错误,我就是想不出来 下面是函数 import Prelude import Contr

我遵循PureScript书中的一个函数,我必须定义一个函数
renderPath
,它接受一个
s(x和y)数组,并使用它们绘制一条路径(使用
PureScript画布
),其中
定义为

type Point = { x :: Number, y :: Number }
我决定将函数分为两个步骤。第一步是将
移动到阵列中的第一个点,然后在其余点上使用
lineTo

这是我到目前为止编写的函数,它只有第一步。但我有一个错误,我就是想不出来

下面是函数

import Prelude
import Control.Monad.Eff (Eff)
import Data.Array.Partial (head, tail)
import Data.Maybe (Maybe(..))
import Graphics.Canvas (CANVAS, Context2D, arc, closePath, fillPath, getCanvasElementById, getContext2D, lineTo, moveTo, rect, setStrokeStyle, strokePath)
import Partial.Unsafe (unsafePartial)

renderPath :: forall eff
. Context2D
-> Array Point
-> Eff (canvas :: CANVAS | eff) Unit

renderPath ctx points = fillPath ctx $ do
  p0 <- unsafePartial head points
  moveTo ctx p0.x p0.y
我假设
p0
应该是
{x::Number,y::Number}

此错误显示一个为
{x::Number | t0}
,另一个为
(x::Number,y::Number)
。我一点也不明白。为什么一个使用
{}
而另一个使用
()
。他们之间有什么区别?我哪里做错了


我还需要一个解释和任何更正,因为我对PureScript和函数式编程是一个新的整体,所以我很难理解很多概念。

我不完全确定您为什么会收到那个特定的错误消息,但您的代码有一个问题是这行代码:

p0 <- unsafePartial head points

p0 <- unsafePartial head points
let p0 = unsafePartial (head points)