From be2a89360ae81b926202c0ee8ec55d38988c9bc1 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Tue, 6 Oct 2015 21:10:42 +0200 Subject: [PATCH] update, alleen nog laatste punt' --- a5/mart/a5.icl | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) 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 -- 2.20.1