나는이 예제를 https://github.com/slamdata/purescript-halogen/blob/v0.12.0/examples/deep-peek/src/Main.purs#L58 (아래의 관련 부분을 복사)으로 변경하려고하지만, 단지 아이를 들여다보고 싶거나이 경우 peekList
인 손자를 엿보는 대신에. 또한 슬롯 유형을 peekList
에 대한 peek 함수의 매개 변수로 유지하려고합니다.Purescript Halogen DeepPeek Child of Grandchild
peek :: forall a. H.ChildF ListSlot ListQueryP a -> H.ParentDSL State (ListStateP g) Query ListQueryP g ListSlot Unit
peek = coproduct peekList peekTicker <<< H.runChildF
peekList :: forall a. ListQuery a -> H.ParentDSL State (ListStateP g) Query ListQueryP g ListSlot Unit
peekList _ =
-- we're not actually interested in peeking on the list.
-- instead of defining a function like this, an alternative would be to use
-- `(const (pure unit))` in place of `peekList` in the `coproduct` function
pure unit
peekTicker :: forall a. H.ChildF TickSlot TickQuery a -> H.ParentDSL State (ListStateP g) Query ListQueryP g ListSlot Unit
peekTicker (H.ChildF _ (Tick _)) = H.modify (\st -> { count: st.count + 1 })
peekTicker _ = pure unit
실제로 슬롯 매개 변수를 잃지 않고 peekList
을 (를) 들여다 볼 수 있습니까?
나는 H.runChildF
제거 시도했다 :
peek = coproduct peekList (const (pure unit))
을 다음 peekList
다시 슬롯 매개 변수 추가 :
peekList :: forall a. H.ChildF ListSlot ListQuery a -> H.ParentDSL State (ListStateP g) Query ListQueryP g ListSlot Unit
그러나 peek
에서 나는 오류를 "형식과 일치 할 수 없습니다 유형 Coproduct (ChildF ListSlot ListQuery)로 유형 ChildF ListSlot을 일치 시키려고 시도하는 동안 유형 Coproduct가있는 ChildF "
peek
대신 peekList
을 사용하려고하면 유형 ChildF ListSlot (Coproduct ListQuery (ChildF TickSlot TickQuery))과 유형이 일치하는 동안 ListQuery 유형의 유형 Coproduct ListQuery (ChildF TickSlot TickQuery)과 일치하는 오류가 발생합니다. ListSlot ListQuery "
감사합니다. 감사합니다.
이 답변이 맞지만, 할로겐에 'peek' 메커니즘이 더 이상 존재하지 않는다는 사실에 주목할 가치가 있습니다! (v1.0.0 이상) –
@gb. 예, 2 주 전에 업데이트 된 할로겐/purescript-routing 예제가 없었기 때문에 0.12.0을 사용하기로 결정했습니다. 지금은 있지만 너무 멀어요. – sportanova