我正在通過Prompt及其Bind實例中描述的here的定義工作,並試圖弄清楚Purescript會如何顯示。 我正在使用Purescript.Exists作爲存在類型。我確定指標則是: data PromptAskF p r a
= PromptAskF (p a) (a -> Prompt p r)
type PromptAsk p r = Exists (PromptAskF
我跟隨this walkthrough如何繪製到purescript中的HTML畫布。不幸的是,我遇到了讓代碼工作的問題。我按照教程創建了下面的代碼,但它不會編譯: main = do
-- Canvas has type Maybe CanvasElement
canvas <- getCanvasElementById "canvas"
-- Type mism
如果我有一個祖父母,一個孩子的成分和一個孫子成分,祖父母可以請求孩子的狀態嗎?我試過使用「請求」,如here,但是當你請求一個也有自己孩子的孩子的狀態時,類型不匹配。當我請求沒有孩子的孩子的狀態時,指南中的示例正常工作。 的錯誤是: Could not match type
Query
with type
Coproduct (Coproduct Query (Chil
一個回合制遊戲的一種簡單形式可以以功能性的語言作爲被抽象: data Player
= PlayerA
| PlayerB
deriving Show
data Game state move = Game {
start :: state,
turn :: (move, move)
-> state
-> Either P
在我的應用程序中,我想使用類似於關係數據庫索引的結構以類型安全的方式對對象集進行索引。例如,我希望索引基於年齡和名字一組用戶對象: import Data.Map as M
import Data.Set as S
type AgeNameIndex = M.Map Int (M.Map String (S.Set User))
此外,我想有效地完成操作,如在指標union和differ
定義以下簡單的樹形結構 data Tree a = Leaf | Branch (Tree a) a (Tree a)
我試圖定義它Foldable實例後,只定義foldMap和使用foldrDefault和foldlDefault功能: instance treeFoldableInstance :: Foldable Tree where
foldr = foldrDefault