Commit cfd7cf9b authored by Bas Lijnse's avatar Bas Lijnse

Added rough outline of a "Getting started with iTasks tutorial" for the current iTasks system.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@951 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent dbf87446
\documentclass[a4paper,11pt]{article}
\title{Getting started with iTasks}
\author{Bas Lijnse}
\usepackage{clean}
\begin{document}
\maketitle
\section{Introduction}
So you have heard something about the iTask system and want to know how you can use to build a workflow support system? Then this tutorial is the right place to start. This document will walk you step-by-step through the specification of a simple example system. Because iTasks is built on top of the Clean programming language, it helps if you have some prior experience with Clean, or with related functional languages like Haskell, but it is not necessary for this tutorial. So let's just dive right in, shall we?
\section{Setting up}
- first module + project
\begin{CleanCodeN}
module CoffeeTime
import iTasks
Start :: *World -> *World
Start world = startEngine [] world
\end{CleanCodeN}
- use iTasks environment
- compile and run
- do setup process
- make 3 users
\section{It's Coffeetime!}
- very simple: showMessage "it's coffeetime!"
- what would the workflow be? let's sketch it out: "ask everyone their orders", "argue who should get it", "actually get the drinks"
- code sketch "showMessage" >>| showInstruction "ask" >>| showInstruction "who needs to get it" >>| showInstruction "get drinks"
\section{Who wants what?}
- define a task for asking someone what he wants (Task String) enterChoice
- add possibility for not wanting anything: requestConfirmation and Task (Maybe String)
- we need users, add a step to the main workflow with a lambda getUserNames
- we want to assign the task to everyone
\section{Merging the orders}
- make a function that uses
- show those orders to the
\section{A fair assignment}
- define a task that randomly selects a user from the orders
- assign the "get drinks task" to that user
\section{Conclusions}
\appendix
\newpage
\section{The complete source code}
This is it. A complete workflow support system for co\"ordinating a core process of many organizations in just over forty lines of code.
\begin{CleanCodeN}
module CoffeeTime
import iTasks
Start :: *World -> *World
Start world = startEngine [workflow "Coffee time" coffeeTime] world
coffeeTime :: Task Void
coffeeTime
= getUserNames
>>= \users ->
collectOrders users
>>= \orders ->
determineWhoGoes (orderlist users orders)
>>= \victim ->
goGetCoffee victim (orderlist users orders)
where
orderlist users orders
= [(user, fromJust order) \\ user <- users & order <- orders | isJust order]
collectOrders :: [UserName] -> Task [Maybe String]
collectOrders users = allTasks [u @: ("Coffee time!",getOrder) \\ u <- users]
getOrder :: Task (Maybe String)
getOrder
= requestConfirmation "It is coffee time, do you want something?"
>>= \yes -> if yes
(enterChoice "What do you want" ["Coffee","Tea","Chocolate"]
>>= \choice -> return (Just choice)
)
(return Nothing)
determineWhoGoes :: [(UserName,String)] -> Task UserName
determineWhoGoes orders = randomChoice [user \\ (user,_) <- orders]
goGetCoffee :: UserName [(UserName,String)] -> Task Void
goGetCoffee user orders
= user @:
("Get coffee", showInstructionAbout
"Coffee orders"
"You have been chosen to get the following drinks"
orders
)
\end{CleanCodeN}
\end{document}
\ No newline at end of file
\usepackage{listings}
\lstdefinelanguage{Clean}{
alsoletter={ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_`1234567890},
alsoletter={~!@\#$\%^\&*-+=?<>:|\\.},
morekeywords={generic,implementation,definition,dynamic,module,import,from,where,in,of,case,let,infix,infixr,infixl,class,instance,with,if,derive},
sensitive=true,
morecomment=[l]{//},
morecomment=[n]{/*}{*/},
morestring=[b]",
morestring=[b]',
emptylines=1,
basicstyle=\small,
identifierstyle=\small\ttfamily,
commentstyle=\itshape,
keywordstyle=\bfseries,
stringstyle=\ttfamily,
numbers=none,
showstringspaces=false,
basewidth=0.45em,
columns=[c]fixed,
keepspaces=true,
breaklines=false,
tabsize=4,
texcl=true,
escapeinside={(\#}{\#)},
literate= %
% Basic Clean constructs
{\\}{{$\lambda\:$}}1
{A.}{{$\forall\;\,$}}1
{E.}{{$\exist\;\,$}}1
{>}{{$>$}}1
{<=}{{$\leq$}}1
{>=}{{$\geq$}}1
{<>}{{$\neq$}}1
{->}{{$\rightarrow$}}2
{<-}{{$\leftarrow$}}1
{=}{{$=$}}1
{~}{{$\sim$}}1
% {\#}{{$\sharp$}}1
{\{|}{{$\{\!|\!$}}1
{|\}}{{$\!|\!\}$}}1
{:=}{{$:=$}}2
{==}{{$==$}}2
{++}{{$+\!\!+$}}2
{+++}{{$+\!\!\!\!+\!\!\!\!+$}}2
{:==}{{$:==$}}3
{\{|*|\}}{{$\{\!|\!\!\star\!\!|\!\}$}}3
%
% Basic iTask constructs
{>||>}{{$\triangleright\triangleright$}}2
{>>=}{{\texttt{>>=}}}3
{>>|}{{\texttt{>>|}}}3
{?>>}{{\texttt{?>>}}}3
{!>>}{{\texttt{!>>}}}3
{-||-}{{\texttt{-||-}}}4
{.||.}{{\texttt{.||.}}}4
{.&&.}{{\texttt{.\&\&.}}}4
}
\newcommand{\CleanInline}[1]{\lstinline[language=Clean]#1}
\newcommand{\CI}[1]{\CleanInline{#1}}
\lstdefinestyle{numbers}{numbers=right, stepnumber=1, numberstyle=\tiny, numbersep=-5pt}
\lstnewenvironment{CleanCode}{\lstset{language=Clean}}{}
\lstnewenvironment{CleanCodeN}{\lstset{language=Clean,style=numbers}}{}
\lstnewenvironment{CleanCodeB}{\lstset{language=Clean,frame=single}}{}
\lstnewenvironment{CleanCodeNB}{\lstset{language=Clean,style=numbers,frame=single}}{}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment