Listing~\ref{lst:sdsio}. In this way the assignment is the same for every
assignable entity.
-\begin{lstlisting}[%
+\begin{lstlisting}[language=Clean,%
label={lst:sdsio},caption={Input/Output classes}]
:: DigitalPin = D0 | D1 | D2 | D3 | D4 | D5 |D6 | D7 | D8 | D9 | D10 | D11 | D12 | D13
-:: AnalogPin = A0 | A1 | A2 | A3 | A4 | A5
+:: AnalogPin = A0 | A1 | A2 | A3 | A4 | A5
:: UserLED = LED1 | LED2 | LED3
class dIO v where dIO :: DigitalPin -> v Bool Upd
class aIO v where aIO :: AnalogPin -> v Int Upd
class analogRead v where
- analogRead :: AnalogPin -> v Int Expr
- analogWrite :: AnalogPin (v Int p) -> v Int Expr
+ analogRead :: AnalogPin -> v Int Expr
+ analogWrite :: AnalogPin (v Int p) -> v Int Expr
class digitalRead v where
- digitalRead :: DigitalPin -> v Bin Expr
- digitalWrite :: DigitalPin (v Bool p) -> v Int Expr
+ digitalRead :: DigitalPin -> v Bin Expr
+ digitalWrite :: DigitalPin (v Bool p) -> v Int Expr
:: UserLED = LED1 | LED2 | LED3
class userLed v where
- ledOn :: (v UserLED q) -> (v () Stmt)
- ledOff :: (v UserLED q) -> (v () Stmt)
+ ledOn :: (v UserLED q) -> (v () Stmt)
+ ledOff :: (v UserLED q) -> (v () Stmt)
class assign v where
- (=.) infixr 2 :: (v t Upd) (v t p) -> v t Expr | ...
+ (=.) infixr 2 :: (v t Upd) (v t p) -> v t Expr | ...
\end{lstlisting}
One way of storing data in \gls{mTask}-\glspl{Task} is using \glspl{SDS}.
-\glspl{SDS} serve as variables in \gls{mTask} and maintain their value across
-executions. \glspl{SDS} can be used by multiple \glspl{Task} and can be used
-to share data. The classes associated with \glspl{SDS} are listed in
+\glspl{SDS} serve as global variables in \gls{mTask} and maintain their value
+across executions. \glspl{SDS} can be used by multiple \glspl{Task} and can be
+used to share data. The classes associated with \glspl{SDS} are listed in
Listing~\ref{lst:sdsclass}. The \CI{Main} type is introduced to box an
\gls{mTask} and make it recognizable by the type system by separating programs
-and decorations such as \glspl{SDS}.
+and decorations such as \glspl{SDS}. The type signature is complex and uses
+infix type constructors and therefore, an implementation example is also given.
-\begin{lstlisting}[%
+\begin{lstlisting}[language=Clean,%
label={lst:sdsclass},caption={\glspl{SDS} in \gls{mTask}}]
:: In a b = In infix 0 a b
:: Main a = {main :: a}
class sds v where
- sds :: ((v t Upd)->In t (Main (v c s))) -> (Main (v c s)) | ...
+ sds :: ((v t Upd) -> In t (Main (v c s))) -> (Main (v c s)) | ...
+
+sdsExample :: Main (v Int Stmt)
+sdsExample = sds \x.0 In
+ {main= x =. x +. lit 42 }
\end{lstlisting}