<commit_before>%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../report"
%%% End:

We have been inspired by many other languages when designing and implementing Kite, most notably the Glasgow Haskell Compiler (GHC)\footnote{\url{http://www.haskell.org/ghc}}.


\subsection{Syntax and semantics}
In this section we will describe how to use the different features of Kite and how they work, i.e.\ the syntax and semantics of the language.

\subsubsection{Basic types and declarations}
Basic declaration of the variables in Kite, types are inferred by the analyzer:

\begin{kite}
one = 1
two = 2.0
truth = True
list = [1, 2, 3, 4]
char = 'a'
pair = (1, 'a')
\end{kite}

Functional languages often make extensive use of lists, which is indeed also the case for Kite. A list is an ordered array of items that can be transformed in many different ways. We use a common short-hand method for describing a list of things, using square brackets \code{[\ ]}. For instance, a \code{List(Int)} (pronounced ``List of Ints'') is denoted \code{[Int]} and a list of a type variables $a$ is \code{[a]}. Lists can be nested, allowing \code{List(List(Int))} denoted \code{[[Int]]}.

The pair type is also abbreviated using \code{( , )}, for instance the type \code{Pair(Int, Bool)} is written \code{(Int, Bool)}

Strings are represented as syntactic sugar for lists of characters. For
instance, \code{['f', 'o', 'o']} has the sugared version \code{"foo"}. This will be discussed later.

Basic arithmetic operators:
\begin{kite}
1 + 1  ----> 2
10 % 2 ----> 0
\end{kite}

\begin{table}[H]
  \centering
  \begin{tabular}{ll}
    \textbf{Operation} & \textbf{Meaning}   \\ \hline
    $\code{x + y}$     & Addition         \\ \hline
    $\code{x - y}$     & Subtraction        \\ \hline
    $\code{x * y}$     & Multiplication     \\ \hline
    $\code{x / y}$     & Division           \\ \hline
    $\code{x**y}$      & Exponentiation     \\ \hline
    $\code{x \% m}$    & Remainder of x / y \\ \hline
  \end{tabular}
  \caption{Basic arithmetic operators in Kite}
\label{tbl:kite-design-arith-op}
\end{table}

Basic boolean operators:
\begin{kite}
1 < 2  ----> True
1 == 2 ----> False
\end{kite}

\begin{table}[H]
  \centering
  \begin{tabular}{ll}
    \textbf{Operation} & \textbf{Meaning} \\ \hline
    $\code{==}$ & Equal                   \\ \hline
    $\code{/=}$ & Not equal               \\ \hline
    $\code{<=}$ & Less than or equal than \\ \hline
    $\code{>=}$ & Greater than or equal   \\ \hline
    $\code{<}$  & Less than               \\ \hline
    $\code{>}$  & Greater than            \\ \hline
  \end{tabular}
  \caption{Basic boolean operators in Kite}
\label{tbl:kite-disign-bool-op}
\end{table}

\subsubsection{Function application}
\label{sec:kite-design-func-app}
The most general form of application is as follows:
\begin{kite}
func(arg1, ..., argN)
\end{kite}

Where the function \code{func}, having an arity of $n$, is applied to \emph{n} arguments.

A concrete example hereof is the application of \code{union}, which has an arity of 2, to two lists:
\begin{kite}
union([1,2],[2,3]) ----> [1,2,3]
\end{kite}

Besides this form of application, it is also possible to use infix operators. The application of these is described in section \ref{sec:kite-design-sugar} and the declaration of these is described in the following section.

Furthermore, Kite also allows for partial application, which is described in section \ref{sec:kite-design-partial-app}.




\subsubsection{Function declaration}
\label{sec:func-decl}
Every function in Kite is declared as an anonymous function:

\begin{kite}
|param1, ..., paramN| -> {
  expr1
  ...
  exprN
}
\end{kite}

A function (lambda expression) is defined as a list of arguments and a block. A block is defined as a list of expressions optionally separated by \code{;}, where it is implicit that the last expression is returned as the result of the functions. A block introduces a new lexical scope, capturing its parent scope.

There are no named functions in Kite, but lambda expressions can be bound to identifers. A function is declared as follows:

\begin{kite}
name :: ArgType -> ... -> ReturnType
name = |arg1, ..., argN| -> { ... }
\end{kite}

Example of a valid function declaration in Kite, taking one parameter of the type \code{Int} and returning an \code{Int}:

\begin{kite}
foo :: Int -> Int
foo = |a| -> {
  a + 1
}
\end{kite}


Another type of function declaration is the declaration of \emph{infix operators}. This is generally done as follows:
\begin{kite}
{name} :: ArgType1 -> ArgType2 -> ReturnType
{name} = | arg1 , arg2| -> { ... }
\end{kite}

And a specific example is our implementation of the conjunction of boolean expressions:

\begin{kite}
{&&} :: Bool -> Bool -> Bool
{&&} = |l, r| -> {
  if l then r else False
}
\end{kite}

Finally, a runnable program must \emph{always} include the \code{main} function of type \code{Void -> a}, which will be used as the entry point for execution:

\begin{kite}
main = |Void| -> { ... }
\end{kite}

In order to use the preprocessor to include another code file, use the \code{\#include} keyword:
\begin{kite}
#include "foo.kite"
\end{kite}<commit_msg>Fixed some refs in impl<commit_after>%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../report"
%%% End:

We have been inspired by many other languages when designing and implementing Kite, most notably the Glasgow Haskell Compiler (GHC)\footnote{\url{http://www.haskell.org/ghc}}.


\subsection{Syntax and semantics}
In this section we will describe how to use the different features of Kite and how they work, i.e.\ the syntax and semantics of the language.

\subsubsection{Basic types and declarations}
Basic declaration of the variables in Kite, types are inferred by the analyzer:

\begin{kite}
one = 1
two = 2.0
truth = True
list = [1, 2, 3, 4]
char = 'a'
pair = (1, 'a')
\end{kite}

Functional languages often make extensive use of lists, which is indeed also the case for Kite. A list is an ordered array of items that can be transformed in many different ways. We use a common short-hand method for describing a list of things, using square brackets \code{[\ ]}. For instance, a \code{List(Int)} (pronounced ``List of Ints'') is denoted \code{[Int]} and a list of a type variables $a$ is \code{[a]}. Lists can be nested, allowing \code{List(List(Int))} denoted \code{[[Int]]}.

The pair type is also abbreviated using \code{( , )}, for instance the type \code{Pair(Int, Bool)} is written \code{(Int, Bool)}

Strings are represented as syntactic sugar for lists of characters. For
instance, \code{['f', 'o', 'o']} has the sugared version \code{"foo"}. This will be discussed later.

Basic arithmetic operators:
\begin{kite}
1 + 1  ----> 2
10 % 2 ----> 0
\end{kite}

\begin{table}[H]
  \centering
  \begin{tabular}{ll}
    \textbf{Operation} & \textbf{Meaning}   \\ \hline
    $\code{x + y}$     & Addition         \\ \hline
    $\code{x - y}$     & Subtraction        \\ \hline
    $\code{x * y}$     & Multiplication     \\ \hline
    $\code{x / y}$     & Division           \\ \hline
    $\code{x**y}$      & Exponentiation     \\ \hline
    $\code{x \% m}$    & Remainder of x / y \\ \hline
  \end{tabular}
  \caption{Basic arithmetic operators in Kite}
\label{tbl:kite-design-arith-op}
\end{table}

Basic boolean operators:
\begin{kite}
1 < 2  ----> True
1 == 2 ----> False
\end{kite}

\begin{table}[H]
  \centering
  \begin{tabular}{ll}
    \textbf{Operation} & \textbf{Meaning} \\ \hline
    $\code{==}$ & Equal                   \\ \hline
    $\code{/=}$ & Not equal               \\ \hline
    $\code{<=}$ & Less than or equal than \\ \hline
    $\code{>=}$ & Greater than or equal   \\ \hline
    $\code{<}$  & Less than               \\ \hline
    $\code{>}$  & Greater than            \\ \hline
  \end{tabular}
  \caption{Basic boolean operators in Kite}
\label{tbl:kite-disign-bool-op}
\end{table}

\subsubsection{Function application}
\label{sec:kite-design-func-app}
The most general form of application is as follows:
\begin{kite}
func (arg1, ..., argN)
\end{kite}

Where the function \code{func}, having an arity of $n$, is applied to \emph{n} arguments.

A concrete example hereof is the application of \code{union}, which has an arity of 2, to two lists:
\begin{kite}
union ([1,2],[2,3]) ----> [1,2,3]
\end{kite}

Besides this form of application, it is also possible to use infix operators. The application of these is described in section~\ref{sec:kite-design-sugar} and the declaration of these is described in the following section.

Furthermore, Kite also allows for partial application, which is described in section~\ref{sec:kite-design-partial-app}.

\subsubsection{Function declaration}
\label{sec:func-decl}
Every function in Kite is declared as an anonymous function:

\begin{kite}
|param1, ..., paramN| -> {
  expr1
  ...
  exprN
}
\end{kite}

A function (lambda expression) is defined as a list of arguments and a block. A block is defined as a list of expressions optionally separated by \code{;}, where it is implicit that the last expression is returned as the result of the functions. A block introduces a new lexical scope, capturing its parent scope.

There are no named functions in Kite, but lambda expressions can be bound to identifers. A function is declared as follows:

\begin{kite}
name :: ArgType -> ... -> ReturnType
name = |arg1, ..., argN| -> { ... }
\end{kite}

Example of a valid function declaration in Kite, taking one parameter of the type \code{Int} and returning an \code{Int}:

\begin{kite}
foo :: Int -> Int
foo = |a| -> {
  a + 1
}
\end{kite}

Another type of function declaration is the declaration of \emph{infix operators}. This is generally done as follows:
\begin{kite}
{name} :: ArgType1 -> ArgType2 -> ReturnType
{name} = |arg1 , arg2| -> { ... }
\end{kite}

And a specific example is our implementation of the conjunction of boolean expressions:
\begin{kite}
{&&} :: Bool -> Bool -> Bool
{&&} = |l, r| -> {
  if l then r else False
}
\end{kite}

Finally, a runnable program must \emph{always} include the \code{main} function of type \code{Void -> a}, which will be used as the entry point for execution:

\begin{kite}
main = |Void| -> { ... }
\end{kite}

In order to use the preprocessor to include another code file, use the \code{\#include} keyword:
\begin{kite}
#include "foo.kite"
\end{kite}
{'fraction_non_alphanumeric': 0.13625821414766137, 'fraction_numerical': 0.006957866254348666, 'mean_word_length': 3.225806451612903, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1055754', 'n_tokens_mistral': 3352, 'n_tokens_neox': 3237, 'n_words': 1289}