module a5
-
/*
Mart Lubbers s4109503
Charlie Gerhardus s3050009
ideas :: Shared [Idea]
ideas = sharedStore "Ideas" []
-addNewIdea :: Task [Idea]
-addNewIdea = enterInformation "New idea" [EnterWith ideaLens]
- >>* [OnAction ActionOk (hasValue (\v -> return v))]
+storeIdea :: Name ProtoIdea -> Idea
+storeIdea n x=:{ProtoIdea | idea,details} =
+ {Idea | user=n, idea=idea, details=details, number=42}
+
+addNewIdea :: Name -> Task [Idea]
+addNewIdea name = enterInformation "Add new idea" [EnterWith (storeIdea name)]
+ >>* [OnAction ActionOk (hasValue (\v.return v))]
>>= \n.upd (\is.[n:is]) ideas
- where
- ideaLens :: ProtoIdea -> Idea
- ideaLens p = {idea=p.idea, user="Mart", number=42}
-
-mainTask = forever (
- addNewIdea
- -||
- enterChoiceWithShared "Idea" [] ideas
- )
+viewList = (enterChoiceWithShared "Idea collection" [] ideas)
+ >&^ viewSharedInformation "Selected idea" []
+
+mainTask = enterInformation "What is your username?" []
+ >>= \name.forever (
+ (addNewIdea name -|| viewList)
+// >>* [OnAction ActionOk (always (return (get ideas)))]
+// OnAction (Action "Delete All" [ActionIcon "delete"]) (always (upd (\_.[]) ideas))
+//// OnAction (Action "Delete" [ActionIcon "delete"]) (always (return Void)),
+//// OnAction (Action "Like" [ActionIcon "like"]) (always (return Void))
+// ]
+ )
Start :: *World -> *World
Start world = startEngine mainTask world