2016-03-24 8 views
0

私はPureScript 0.8.2を使用しています。 PureScriptハロゲンで、component機能は、署名を持っていますPurescriptハロゲンコンポーネント関数:レコードの代わりに間隔のある引数を渡す?

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は、レコードを期待しています。

ui = component render eval 

アム私は2つの異なるcomponentの機能を見て次のようにしかしHalogen Template Projectで、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 
.... 

答えて

0

申し訳ありませんが、テンプレートプロジェクトはまだ更新されていません。念押し有難う!

と仮定すると、あなたのevalrender機能を使用すると、コンポーネント定義をこのように書くために、フィールドの駄洒落を使用することができる範囲にあります。

ui = component { render, eval } 

しかし、はい、レコードが必ず必要になりました。私はすぐにテンプレートプロジェクトを更新します。

+0

ああ、ありがとう!私は、 "powercript-halogen"のニュアンスを理解していないことに気付きました: "bower.json"の "^ 0.5.14"。私はそれが1.0より前の最新バージョンを取り上げると考えましたが、1.0より下のバージョンの場合はそうではありません。 Ref:https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004 – RAbraham

関連する問題