<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [clean-list] strictness annotation introduces
type err</title></head><body>
<div>Erik Zuurbier wrote:</div>
<blockquote type="cite" cite><font face="Arial" size="-1"
color="#000000">The following gives a type error
message:</font></blockquote>
<blockquote type="cite" cite>&nbsp;</blockquote>
<blockquote type="cite" cite>splitLine :: ![!Char] -&gt; [String]<br>
splitLine cs<br>
&nbsp;# (frst,rest)&nbsp;= span (\a-&gt;a&lt;&gt;';') cs<br>
&nbsp;# str&nbsp;= {c\\c&lt;-frst}<br>
&nbsp;= case rest of<br>
&nbsp;&nbsp;&nbsp;[]&nbsp;= [str]</blockquote>
<blockquote type="cite" cite>&nbsp;&nbsp;&nbsp;_&nbsp;= [str:splitLine
(drop 1 rest)]</blockquote>
<blockquote type="cite" cite>&nbsp;</blockquote>
<blockquote type="cite" cite>The error messages are:</blockquote>
<blockquote type="cite" cite>&quot;Type error
[tabellen.icl,53,splitLine]:&quot;argument 1 of splitLine&quot; cannot
unify types:<br>
&nbsp;[!Char]<br>
&nbsp;[v20]<br>
Type error [tabellen.icl,51,splitLine]:&quot;argument 2 of span&quot;
cannot unify types:<br>
&nbsp;[Char]<br>
&nbsp;[!Char]<br>
Type error [tabellen.icl,40,procFile]:&quot;argument 1 of splitLine&quot;
cannot unify types:<br>
&nbsp;[!Char]<br>
&nbsp;[v20]&quot;</blockquote>
<blockquote type="cite" cite>&nbsp;</blockquote>
<blockquote type="cite" cite>When I remove the second ! in the type,
the errors disappear. I thought that strictness annotations were not
supposed to introduce type errors.</blockquote>
<div><br></div>
<div>The ! after [ or { in a list or array type is not a strictness
annotation,</div>
<div>but part of the name of the type. [!a] and [a] are different
types</div>
<div>(and so are {!a} and {a}).</div>
<div><br></div>
<div>The compiler does not convert [a] to [!a] (or [!a] to [a]),
because that</div>
<div>would usually be too expensive (but it does for tuples).</div>
<div><br></div>
<div>Rewriting to (using overloaded list constructors):</div>
<div><br></div>
<div>import StdOverloadedList</div>
<div><br>
splitLine :: ![!Char] -&gt; [String]<br>
splitLine cs<br>
&nbsp;# (frst,rest) = Span (\a-&gt;a&lt;&gt;';') cs<br>
&nbsp;# str = {c\\c&lt;-frst}<br>
&nbsp;= case rest of<br>
&nbsp;&nbsp; [|] = [|str]<br>
&nbsp;&nbsp; _ = [|str:splitLine (Drop 1 rest)]<br>
</div>
<div>should have fixed the problem, but it didn't because the
definition of</div>
<div>Span in StdOverloadedList is incorrect. It should be:</div>
<div><br></div>
<div>Span p l :== span l<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>where<br>
<x-tab>&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>span
list=:[|x:xs]<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>| p
x<br>
<x-tab>&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>#
(ys,zs) = span xs<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>=
([|x:ys],zs)<br>
<x-tab>&nbsp; </x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>=
([|],list)<br>
<x-tab>&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>span
[|]<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>=
([|], [|])<br>
</div>
<div>(the |'s were missing). I have fixed this in our development
version.</div>
<div><br></div>
<blockquote type="cite" cite>&nbsp;Is this&nbsp;a disadvantage of the
introduction, a couple of years ago,&nbsp;of specific treatment of
strict lists, spine strict lists etc.? If so, will this disadvantage
be lifted one time?</blockquote>
<div><br></div>
<div>We have no plans to change this. Converting is too expensive
because it</div>
<div>usually means traversing or copying the entire list. Overloading
the</div>
<div>default list type and constructors will cause too much
overloading that</div>
<div>cannot be resolved.</div>
<div><br></div>
<div>Kind regards,</div>
<div><br></div>
<div>John van Groningen</div>
</body>
</html>