[clean-list] Synonym types
Alan Hutchinson
alanh@dcs.kcl.ac.uk
Wed, 1 Oct 2003 22:49:47 +0100
The code I want to write will be much simpler if the types in it
can be abbreviated as synonym types. The plan is to declare
a function class with lots of instances, one for each type of
control occurring in a graphical interface. The alternative would be
to write long explicit types of ObjectIO Controls.
The Clean compiler does not pass my code. The problem seems
to lie in structures like the types in the following:
module testSyn2
import StdEnv
Start = testFn
:: SynTypeA a b :== (a,b)
:: Constr t1 t2 a b = C (t1 a b) (t2 a b)
:: SynTypeB a b :== Constr SynTypeA SynTypeA a b
testFn :: SynTypeA Int String
testFn
= (3,"It works.")
This generates the error report
Error [testSyn2.icl,11,SynTypeB]: SynTypeA used with wrong arity
twice.
If the type definition of SynTypeB is commented out
then it compiles and runs as expected.
Seeming reason:
The parameters t1 and t2 in the definition of Constr
have to be names of algebraic types, not synonym names.
The Clean 2 Report
says that each argument after "Constr" in the definition
of SynTypeB can be a Type
which may be a BrackType, which may be a TypeExpression,
which can be a TypeConstructorName
which can be the first symbol in any TypeLhs, such as
the symbol
SynTypeA
in the above synonym type definition of SynTypeA.
Have I got this right?
is there a way round it?
--
Alan Hutchinson
Department of Computer Science
King's College London
Strand
London
WC2R 2LS
alanh@dcs.kcl.ac.uk