0

我在 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
....
4

1 回答 1

0

抱歉,模板项目尚未更新。感谢您的提醒!

假设您的evalrender函数在范围内,您可以使用字段双关语以这种方式编写组件定义:

ui = component { render, eval }

但是,是的,现在总是需要记录。我将立即更新模板项目。

于 2016-03-24T17:15:45.637 回答