我用的是PureScript 0.8.2。在PureScript Halogen中,component函数具有以下签名:
component :: forall s f g. ComponentSpec s f g -> Component s f g哪里
-- | A spec for a component.
type ComponentSpec s f g =
{ render :: s -> ComponentHTML f
, eval :: Natural f (ComponentDSL s f g)
}因此,component期望有一个记录。但是在卤素模板项目中,component的名称如下:
ui = component render eval我看的是两个不同的component函数吗?还是用空格分隔的参数被转换成记录?因此,我在psci中尝试了以下内容
> type Point = { x :: Int, y :: Int }
> let
addP :: Point -> Int
addP p = p.x + p.y
> addP {x: 4, y: 5 }
9
> addP 4 5
Error found:
in module $PSCI
at line 1, column 1 - line 1, column 8
Could not match type
{ x :: Int
, y :: Int
}
with type
Int
....发布于 2016-03-24 17:15:45
对不起,模板项目还没有更新。谢谢你的提醒!
假设您的eval和render函数在作用域中,您可以使用字段双关语以这种方式编写组件定义:
ui = component { render, eval }但是是的,现在总是需要一份记录。我将立即更新模板项目。
https://stackoverflow.com/questions/36199580
复制相似问题