[clean-list] understanding list type definition
Rinus Plasmeijer
rinus at cs.ru.nl
Wed Oct 4 11:06:49 MEST 2006
Dear Jigang
Not every error can be covered by syntax rules.
In principle expression like these are allowed.
For instance if you define
:: List a = Cons a (List a) | Nil
then List Bool is a legal type as well as [List Bool]
But, indeed [Int Bool] is not.
The syntax is not wrong, but there is a semantic restriction that a common
type should be of kind *. One cannot apply Int to Bool because Int is of
kind *.
One can apply List to Bool because List is of kind (* -> *) and Bool is of
kind *
such that List Bool is of kind *.
So, shortly, [Int Bool] is syntactically ok, but semantically there is a
type error.
I hope this clarifies things,
Greetings,
Rinus
----- Original Message -----
From: "Jigang Sun" <Jigang.Sun at student.paisley.ac.uk>
To: <clean-list at science.ru.nl>
Sent: Wednesday, October 04, 2006 10:42 AM
Subject: [clean-list] understanding list type definition
> On language report 2.0, page 115,
>
> ListType = [[ListKind] Type [SpineStrictness]]
> Type = {BrackType}+
> BrackType = [UniversalQuantVariables] [Strict] [UnqTypeAttrib]
> TypeExpression
>
> Type Expression = TypeVariable // see A.7
> |typeConstructorName
> | (Type)
> | PredefinedType
> | PredefinedTypeConstructor
>
> PredefinedType = BasicType
> | ListType
> | TupleType
> | ArrayType
> | ArrowType
> | PredefType
>
> BasicType = Int
> | Real
> | Char
> | Bool
>
> so a list type [Int Bool] is legal?
>
> Jigang
>
>
> _______________________________________________
> clean-list mailing list
> clean-list at science.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/clean-list
>
More information about the clean-list
mailing list