From: Mart Lubbers Date: Sun, 18 Jun 2017 08:58:38 +0000 (+0200) Subject: fix and elaborate upon parametric lenses X-Git-Tag: hand-in~78 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=66de2590bcb4046b92ea54bcd3e55b38208be17b;p=msc-thesis1617.git fix and elaborate upon parametric lenses --- diff --git a/introduction.tex b/introduction.tex index 62bbb9f..8d5de43 100644 --- a/introduction.tex +++ b/introduction.tex @@ -24,7 +24,7 @@ like sequence, parallel and conditional \glspl{Task} can be modelled using combinators. \gls{iTasks} has been proven to be useful in many fields of operation such as -incident management~~\cite{lijnse_top_2013}. Interfaces are automatically +incident management~\cite{lijnse_top_2013}. Interfaces are automatically generated for the types of data which makes rapid development possible. \Glspl{Task} in the \gls{iTasks} system are modelled after real life workflow tasks but the modelling is applied on a very high level. Therefore it is @@ -42,7 +42,7 @@ This forces a fixed logic in the device that is set at compile time. Many small \gls{IoT} devices have limited processing power but can still contain decision making. Oortgiese et al.\ lifted \gls{iTasks} from a single server model to a distributed server architecture that is also runnable on small -devices such as those powered by \acrshort{ARM}~~\cite{% +devices such as those powered by \acrshort{ARM}~\cite{% oortgiese_distributed_2017}. However, this is limited to fairly high performance devices that are equipped with high speed communication channels. Devices in \gls{IoT} often have only \gls{LTN} communication with low bandwidth diff --git a/methods.top.tex b/methods.top.tex index e83b6b7..aefa35d 100644 --- a/methods.top.tex +++ b/methods.top.tex @@ -164,7 +164,7 @@ of the resource. When this happens, all waiting \glspl{Task} looking at the resource are notified of the update. However, it may be the case that \glspl{Task} were only looking at parts of the structure that was not updated. To solve this problem, parametric lenses were -introduced~~\cite{domoszlai_parametric_2014}. +introduced~\cite{domoszlai_parametric_2014}. Parametric lenses add a type variable to the \gls{SDS} that is in the current library functions fixed to the void type (i.e. \CI{()}). When a \gls{SDS} @@ -173,17 +173,32 @@ predicate. This notification predicate is a function \CI{p -> Bool} where \CI{p} is the parametric lens type. This allows programmers to create a big \gls{SDS}, and have \glspl{Task} only look at parts of the big \gls{SDS}. This technique is used in the current system in memory shares. The \CI{IWorld} -contains a map that is accessible through an \gls{SDS}. While all data is +contains a map that is accessible through a \gls{SDS}. While all data is stored in the map, only \glspl{Task} looking at a specific entry are notified when the structure is updated. The type of the parametric lens is the key in the map. Functionality for setting parameters is added in the system. The most important -function is the \CI{sdsFocus} function. This function is listed in -Listing~\ref{lst:focus} and allows the programmer to fix the parametric lens to -a specific value. +functions are the \CI{sdsFocus} and the \CI{sdsLens} function. These functions +are listed in Listing~\ref{lst:focus}. \CI{sdsFocus} allows the programmer to +fix a parametric lens value. \CI{sdsLens} is a kind of \CI{mapReadWrite} +including access to the parametric lens value. This allows the creation of +for example \glspl{SDS} that only read and write to parts of the original +\gls{SDS}. \begin{lstlisting}[label={lst:focus}, caption={Parametric lens functions}] sdsFocus :: p (RWShared p r w) -> RWShared p` r w | iTask p + +:: SDSNotifyPred p :== p -> Bool + +:: SDSLensRead p r rs = SDSRead (p -> rs -> MaybeError TaskException r) + | SDSReadConst (p -> r) +:: SDSLensWrite p w rs ws = SDSWrite (p -> rs -> w -> MaybeError TaskException (Maybe ws)) + | SDSWriteConst (p -> w -> MaybeError TaskException (Maybe ws)) +:: SDSLensNotify p w rs = SDSNotify (p -> rs -> w -> SDSNotifyPred p) + | SDSNotifyConst (p -> w -> SDSNotifyPred p) + +sdsLens :: String (p -> ps) (SDSLensRead p r rs) (SDSLensWrite p w rs ws) (SDSLensNotify p w rs) + (RWShared ps rs ws) -> RWShared p r w | iTask ps \end{lstlisting} diff --git a/results.mtask.tex b/results.mtask.tex index edb3d66..83cc709 100644 --- a/results.mtask.tex +++ b/results.mtask.tex @@ -73,7 +73,7 @@ Therefore the \gls{RWST} is wrapped with a constructor and two phantom type variables are added. This means that the programmer has to unbox the \CI{ByteCode} object to be able to use return values for the monad. Tailor made access functions are used to achieve this with ease. The fresh variable stream -in a compiler using an \gls{RWST} is often put into the \emph{Reader} part of +in a compiler using a \gls{RWST} is often put into the \emph{Reader} part of the monad. However, not all code is compiled immediately and later on the fresh variable stream cannot contain variables that were used before. Therefore this information is put in the state which is kept between compilations. @@ -253,8 +253,8 @@ instance sdspub ByteCode where addSDS sds v s = {s & sdss=[{sds & sdsval=BCValue v}:s.sdss]} \end{lstlisting} -All assignable types compile to an \gls{RWST} that writes one instruction. For -example, using an \gls{SDS} always results in an expression of the form +All assignable types compile to a \gls{RWST} that writes one instruction. For +example, using a \gls{SDS} always results in an expression of the form \CI{sds \x=4 In ...}. The actual \CI{x} is the \gls{RWST} that always writes one \CI{BCSdsFetch} instruction with the correct \gls{SDS} embedded. When the call of the \CI{x} is not a read but an assignment, the instruction will be diff --git a/thesis.pre b/thesis.pre index f785c55..e9a8ce2 100644 --- a/thesis.pre +++ b/thesis.pre @@ -1,16 +1,14 @@ \documentclass[twoside,a4paper,titlepage]{book} -\usepackage[british]{babel} -\usepackage{makeidx} % Index \usepackage{geometry} % Papersize +\usepackage[british]{babel} % Internationalization \usepackage[titletoc]{appendix} % Appendices \usepackage{hyperref} % Hyperlinks \usepackage{booktabs} % Better looking tables \usepackage{todonotes} % Todo's \usepackage{caption} % Captions \usepackage{subcaption} % Subcaptions -\usepackage{lipsum} % dummy text \usepackage{listings} % source code \usepackage{float} % floating images \usepackage{lmodern} % Better teletype fonts diff --git a/thesis.tex b/thesis.tex index 2c89d51..f52913c 100644 --- a/thesis.tex +++ b/thesis.tex @@ -87,6 +87,4 @@ \listofalgorithms% \endgroup -\printindex - \end{document}