@@ -133,18 +133,27 @@ typeTransType1 (TypeTrans [] _) = unitTypeOpenTerm
133
133
typeTransType1 (TypeTrans [tp] _) = tp
134
134
typeTransType1 _ = error (" typeTransType1" ++ nlPrettyCallStack callStack)
135
135
136
- -- | Build the tuple type @#(T1, T2, ... Tn-1, Tn)@ of @n@ types.
136
+ -- | Build the tuple type @#(T1, T2, ... Tn-1, Tn)@ of @n@ types, with
137
+ -- the special case that 0 types maps to the unit type @#()@ (and 1
138
+ -- type just maps to itself).
137
139
tupleOfTypes :: [OpenTerm ] -> OpenTerm
140
+ tupleOfTypes [] = unitTypeOpenTerm
141
+ tupleOfTypes [tp] = tp
138
142
tupleOfTypes tps = tupleTypeOpenTerm tps
139
143
140
- -- | Build the tuple @(t1, t2, ..., tn-1, tn)@ of @n@ terms.
144
+ -- | Build the tuple @(t1, t2, ..., tn-1, tn)@ of @n@ terms, with the
145
+ -- special case that 0 types maps to the unit value @()@ (and 1 value
146
+ -- just maps to itself).
141
147
tupleOfTerms :: [OpenTerm ] -> OpenTerm
148
+ tupleOfTerms [] = unitOpenTerm
149
+ tupleOfTerms [t] = t
142
150
tupleOfTerms ts = tupleOpenTerm ts
143
151
144
152
-- | Project the @i@th element from a term of type @'tupleOfTypes' tps@. Note
145
153
-- that this requires knowing the length of @tps@.
146
154
projTupleOfTypes :: [OpenTerm ] -> Integer -> OpenTerm -> OpenTerm
147
155
projTupleOfTypes tps i tup
156
+ | i == 0 && length tps == 1 = tup
148
157
| i < toInteger (length tps) = projTupleOpenTerm i tup
149
158
| otherwise = error " projTupleOfTypes: invalid tuple index"
150
159
0 commit comments