From fc558d332870918bdb32e636ac6ba3a584aa6eaa Mon Sep 17 00:00:00 2001 From: Steffen Michels Date: Wed, 13 Sep 2017 16:30:25 +0200 Subject: [PATCH] made basic examples compile with recent editor API changes & fixed some imports --- Examples/BasicAPIExamples.icl | 10 +++++----- Libraries/iTasks/Extensions/Currency.icl | 12 ++++++------ Libraries/iTasks/WF/Combinators/Core.icl | 3 ++- Libraries/iTasks/WF/Combinators/Overloaded.icl | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Examples/BasicAPIExamples.icl b/Examples/BasicAPIExamples.icl index 8f747e5fd..e1bce48a2 100644 --- a/Examples/BasicAPIExamples.icl +++ b/Examples/BasicAPIExamples.icl @@ -204,11 +204,11 @@ viewStoredPersons = viewSharedInformation "These are the currently stored person notes :: Task String notes = withShared "" - (\note -> viewSharedInformation "view on note" [ViewUsing id (textView 'DM'.newMap)] note + (\note -> viewSharedInformation "view on note" [ViewUsing id textView] note -||- - updateSharedInformation "edit shared note 1" [UpdateUsing id (const id) (textArea 'DM'.newMap)] note + updateSharedInformation "edit shared note 1" [UpdateUsing id (const id) textArea] note -||- - updateSharedInformation "edit shared note 2" [UpdateUsing id (const id) (textArea 'DM'.newMap)] note + updateSharedInformation "edit shared note 2" [UpdateUsing id (const id) textArea] note ) linesPar :: Task (Maybe String) @@ -229,7 +229,7 @@ where lineE state = updateSharedInformation ("Lines","Edit lines") [listEditor] state - noteEditor = UpdateUsing id (const id) (textArea 'DM'.newMap) + noteEditor = UpdateUsing id (const id) textArea listEditor = UpdateAs (split "\n") (\_ l -> join "\n" l) browseAndViewGoogleMap :: Task GoogleMap @@ -486,7 +486,7 @@ editWithStatistics editFile :: String (Shared String) (SharedTaskList ()) -> Task () editFile fileName sharedFile _ - = updateSharedInformation ("edit " +++ fileName) [UpdateUsing id (const id) (textArea 'DM'.newMap)] sharedFile + = updateSharedInformation ("edit " +++ fileName) [UpdateUsing id (const id) textArea] sharedFile @! () showStatistics sharedFile _ = noStat <<@ InWindow diff --git a/Libraries/iTasks/Extensions/Currency.icl b/Libraries/iTasks/Extensions/Currency.icl index 0a4cc2228..90d25b48a 100644 --- a/Libraries/iTasks/Extensions/Currency.icl +++ b/Libraries/iTasks/Extensions/Currency.icl @@ -8,9 +8,9 @@ import qualified Data.Map as DM gText{|EUR|} _ val = [maybe "" toString val] gEditor{|EUR|} = selectByMode - (comapEditorValue toString (textView 'DM'.newMap)) - (bijectEditorValue (\(EUR v) -> toReal v / 100.0) (\v -> EUR (toInt (100.0 * v))) (withDynamicHintAttributes "amount in EUR" (decimalField 'DM'.newMap))) - (bijectEditorValue (\(EUR v) -> toReal v / 100.0) (\v -> EUR (toInt (100.0 * v))) (withDynamicHintAttributes "amount in EUR" (decimalField 'DM'.newMap))) + (comapEditorValue toString textView) + (bijectEditorValue (\(EUR v) -> toReal v / 100.0) (\v -> EUR (toInt (100.0 * v))) (withDynamicHintAttributes "amount in EUR" decimalField)) + (bijectEditorValue (\(EUR v) -> toReal v / 100.0) (\v -> EUR (toInt (100.0 * v))) (withDynamicHintAttributes "amount in EUR" decimalField)) instance toString EUR where @@ -43,9 +43,9 @@ where gText{|USD|} _ val = [maybe "" toString val] gEditor{|USD|} = selectByMode - (comapEditorValue toString (textView 'DM'.newMap)) - (bijectEditorValue (\(USD v) -> toReal v / 100.0) (\v -> USD (toInt (100.0 * v))) (withDynamicHintAttributes "amount in USD" (decimalField 'DM'.newMap))) - (bijectEditorValue (\(USD v) -> toReal v / 100.0) (\v -> USD (toInt (100.0 * v))) (withDynamicHintAttributes "amount in USD" (decimalField 'DM'.newMap))) + (comapEditorValue toString textView) + (bijectEditorValue (\(USD v) -> toReal v / 100.0) (\v -> USD (toInt (100.0 * v))) (withDynamicHintAttributes "amount in USD" decimalField)) + (bijectEditorValue (\(USD v) -> toReal v / 100.0) (\v -> USD (toInt (100.0 * v))) (withDynamicHintAttributes "amount in USD" decimalField)) instance toString USD where diff --git a/Libraries/iTasks/WF/Combinators/Core.icl b/Libraries/iTasks/WF/Combinators/Core.icl index ec4f4b095..6c7930b34 100644 --- a/Libraries/iTasks/WF/Combinators/Core.icl +++ b/Libraries/iTasks/WF/Combinators/Core.icl @@ -22,6 +22,7 @@ import qualified Data.Queue as DQ import Data.Maybe, Data.Either, Data.Error import Text.JSON +from Data.Functor import <$> derive gEq ParallelTaskChange @@ -526,7 +527,7 @@ evalParallelTasks listId taskTrees event evalOpts conts completed [{ParallelTask //Decode value value # mbValue = case encValue of NoValue = Just NoValue - Value json stable = fmap (\dec -> Value dec stable) (fromJSON json) + Value json stable = (\dec -> Value dec stable) <$> fromJSON json //TODO: use global tasktime to be able to compare event times between instances # evalInfo = {TaskEvalInfo|lastEvent=0,removedTasks=[],refreshSensitive=True} = maybe (ExceptionResult (exception "Could not decode task value of detached task")) diff --git a/Libraries/iTasks/WF/Combinators/Overloaded.icl b/Libraries/iTasks/WF/Combinators/Overloaded.icl index 96d7717a4..201c924f6 100644 --- a/Libraries/iTasks/WF/Combinators/Overloaded.icl +++ b/Libraries/iTasks/WF/Combinators/Overloaded.icl @@ -4,14 +4,14 @@ import iTasks.WF.Definition import iTasks.WF.Tasks.Core import iTasks.WF.Combinators.Core import iTasks.WF.Combinators.Common -import Data.Maybe, Data.Either, Data.List +import Data.Maybe, Data.Either, Data.List, Data.Functor import iTasks.Internal.Serialization instance Functor Task where fmap f x = transform (fmap f) x instance TApplicative Task where - (<#>) tf ta = tf >>= \f -> fmap f ta + (<#>) tf ta = tf >>= \f -> f <$> ta return x = treturn x instance TMonad Task where -- GitLab