|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
strictness annotation introduces type errorThe following gives a type error message:
splitLine :: ![!Char] -> [String]
splitLine cs # (frst,rest) = span (\a->a<>';') cs # str = {c\\c<-frst} = case rest of [] = [str] _ = [str:splitLine (drop 1 rest)] The error messages are:
"Type error [tabellen.icl,53,splitLine]:"argument 1 of splitLine" cannot unify types:
[!Char] [v20] Type error [tabellen.icl,51,splitLine]:"argument 2 of span" cannot unify types: [Char] [!Char] Type error [tabellen.icl,40,procFile]:"argument 1 of splitLine" cannot unify types: [!Char] [v20]" When I remove the second ! in the type, the errors disappear. I thought that strictness annotations were not supposed to introduce type errors. Is this a disadvantage of the introduction, a couple of years ago, of specific treatment of strict lists, spine strict lists etc.? If so, will this disadvantage be lifted one time?
_______________________________________________ clean-list mailing list clean-list@... http://mailman.science.ru.nl/mailman/listinfo/clean-list |
|
|
Re: strictness annotation introduces type errorErik Zuurbier wrote:
The following gives a type error message: splitLine :: ![!Char] -> [String] _ = [str:splitLine (drop 1 rest)] The error messages are: "Type error [tabellen.icl,53,splitLine]:"argument 1 of splitLine" cannot unify types: When I remove the second ! in the type, the errors disappear. I thought that strictness annotations were not supposed to introduce type errors. The ! after [ or { in a list or array type is not a strictness
annotation,
but part of the name of the type. [!a] and [a] are different
types
(and so are {!a} and {a}).
The compiler does not convert [a] to [!a] (or [!a] to [a]),
because that
would usually be too expensive (but it does for tuples).
Rewriting to (using overloaded list constructors):
import StdOverloadedList
splitLine :: ![!Char] -> [String] splitLine cs # (frst,rest) = Span (\a->a<>';') cs # str = {c\\c<-frst} = case rest of [|] = [|str] _ = [|str:splitLine (Drop 1 rest)] should have fixed the problem, but it didn't because the
definition of
Span in StdOverloadedList is incorrect. It should be:
Span p l :== span l
(the |'s were missing). I have fixed this in our development
version.
Is this a disadvantage of the introduction, a couple of years ago, of specific treatment of strict lists, spine strict lists etc.? If so, will this disadvantage be lifted one time? We have no plans to change this. Converting is too expensive
because it
usually means traversing or copying the entire list. Overloading
the
default list type and constructors will cause too much
overloading that
cannot be resolved.
Kind regards,
John van Groningen
_______________________________________________ clean-list mailing list clean-list@... http://mailman.science.ru.nl/mailman/listinfo/clean-list |
| Free embeddable forum powered by Nabble | Forum Help |