6 \frametitle{\textsc{SPLS
}}
7 \begin{block
}{Features
}
9 \item Implementation language:
10 Clean (
{\tiny\url{http://clean.cs.ru.nl
}})
12 \item State transformer monad
\pause%
14 :: Gamma :== (Map String Type,
[String
])
15 :: Env a :== StateT Gamma (Either SemError) a
17 \item Preferably we want to have an
\CI{Either
} monad transformer
18 but clean does not have that
\ldots
23 \begin{frame
}[fragile
]
24 \frametitle{Grammar changes
}
27 \item Function type:
\pause%
29 <FunType> ::= <VoidType>
['->' <FunType>
]
30 <VoidType> ::= <Void> | Type
34 append(l1, l2) ::
[t
] ->
[t
] ->
[t
] {
38 \pause\item We check in the semantic analysis that
\CI{Void
} is only in
40 \pause\item This is for future higher-order functions
44 \begin{frame
}[fragile
]
45 \frametitle{What do we analyze exactly?
}
47 :: Pos =
{line :: Int, col :: Int
}
48 :: SemOutput :== Either
[SemError
] (AST, Gamma)
50 = ParseError Pos String // Post-parse errors
51 | UnifyError Pos Type Type // Unification
52 | FieldSelectorError Pos Type FieldSelector // hd, tail, fst, snd
53 | OperatorError Pos Op2 Type // 'a' ==
5
54 | UndeclaredVariableError Pos String // Variable ordering
57 sem :: AST -> SemOutput
61 \begin{frame
}[fragile
]
64 \begin{block
}{Scoping?
}
65 Local variables get a new name and are changed in the function body.
69 Does matter for variables, not for functions.
72 \item Note that this means that
\texttt{ones=
1:ones
} is
77 \begin{block
}{Mutual recursion?
}
81 \begin{block
}{Higher order functions?
}
82 Would be an interesting idea for assignment
4
86 \begin{frame
}[fragile
]
87 \frametitle{Mutual Recursion
}
89 \item Mutual recursion is allowed and type checked, however inference is
93 flip(n, l) :: Int ->
[Int
] ->
[Int
] {
94 if( n <=
0 )
{return l;
}
95 else
{return flop(n-
1,
0:l);
}
98 flop(n, l) :: Int ->
[Int
] ->
[Int
] {
103 \item Completely typed specifications are checked correctly.
107 \begin{frame
}[fragile
]
108 \frametitle{Mutual Recursion
}
110 \item Mutual recursion is allowed and type checked, however inference is
113 flip(n, l) :: Int ->
[Int
] ->
[Int
] {
114 if( n <=
0 )
{return l;
}
115 else
{return flop(n-
1,
0:l);
}
118 flop(n, l) :: Int ->
[Int
] -> Bool
{
123 \item It is also correctly determined that
\texttt{Bool
} and the return
124 type of
\texttt{flop(n,l)
} don't match.
128 \begin{frame
}[fragile
]
129 \frametitle{Mutual Recursion
}
131 \item Mutual recursion is allowed and type checked, however inference is
136 if( n <=
0 )
{return l;
}
137 else
{return flop(n-
1,
0:l);
}
148 \begin{frame
}[fragile
]
149 \frametitle{Mutual Recursion
}
151 \item Mutual recursion is allowed and type checked, however inference is
154 flip(n, l) :: Int ->
[Int
] -> vTqhp
{
155 if( n <=
0 )
{return l;
}
156 else
{return flop(n-
1,
0:l);
}
159 flop(n, l) :: Int ->
[Int
] -> HSWdn
{
163 \item However when no type information is given at all our algorithm
164 fails to correctly infer the result type of the two function.
168 % - Can functions that are defined later in a file call earlier defined functions?
169 % - Can local variables be defined in terms of other local variables?
170 % - How do you deal with assignments?
171 % - Tell us if and how you include the value restriction.
172 %- How do you deal with recursion?
173 %- How do you deal with multiple recursion?
174 %- If you forbid multiple recursion, how do you do so?
175 % - Does your language support higher-order functions?
176 % - How do you deal with polymorphism?
177 % - How do you deal with overloading?
178 % - How does the absence/presence of type signatures influence your type