structure CommonUpdate = struct open AppType open DrawMessage open FileMessage open InputMessage open UpdateMessage fun getSaveSquaresMsg (model: app_type) = let val {canvasWidth, canvasHeight, squares, ...} = model val str = CollisionTree.toSaveString (squares, canvasWidth, canvasHeight) val msg = SAVE_SQUARES str in (model, [FILE msg]) end fun getLoadSquaresMsg model = (model, [FILE LOAD_SQUARES]) fun getExportSquaresMsg (model: app_type) = let val {squares, canvasWidth, canvasHeight, ...} = model val exportString = CollisionTree.toExportString (squares, canvasWidth, canvasHeight) val msg = EXPORT_SQUARES exportString in (model, [FILE msg]) end (* unimplemented *) fun useSquaresInNormalMode (model, squares) = (model, []) fun squaresLoadError model = (model, []) end