From: Mart Lubbers Date: Tue, 6 Oct 2015 19:10:42 +0000 (+0200) Subject: update, alleen nog laatste punt' X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=be2a89360ae81b926202c0ee8ec55d38988c9bc1;p=ap2015.git update, alleen nog laatste punt' --- diff --git a/a5/mart/a5.icl b/a5/mart/a5.icl index 7d9ca62..9c5d939 100644 --- a/a5/mart/a5.icl +++ b/a5/mart/a5.icl @@ -1,5 +1,4 @@ module a5 - /* Mart Lubbers s4109503 Charlie Gerhardus s3050009 @@ -17,20 +16,27 @@ derive class iTask Idea, ProtoIdea // generic magic 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