| 1 |
(* --------------------------- Ident syntax tests -------------------------- *) |
| 2 |
(* ------------------------------------------------------------------------- *) |
| 3 |
(* ------------------------------------------------------------------------- *) |
| 4 |
|
| 5 |
module M = struct type t = <| f : nat |> end |
| 6 |
let _ = <| M .f = 1 |> |
| 7 |
|
| 8 |
-------------------------------------------------------------------------------- |
| 9 |
File "test.lem", line 8, character 12 to line 8, character 15 |
| 10 |
Type error: illegal whitespace in identifier: M .f |
| 11 |
================================================================================ |
| 12 |
module M = struct module N = struct type t = <| f : nat |> end end |
| 13 |
let _ = <| M .N.f = 1 |> |
| 14 |
|
| 15 |
-------------------------------------------------------------------------------- |
| 16 |
File "test.lem", line 4, character 12 to line 4, character 17 |
| 17 |
Type error: illegal whitespace in identifier: M .N.f |
| 18 |
================================================================================ |
| 19 |
module M = struct module N = struct type t = <| f : nat |> end end |
| 20 |
let _ = <| M. N.f = 1 |> |
| 21 |
|
| 22 |
-------------------------------------------------------------------------------- |
| 23 |
File "test.lem", line 4, character 12 to line 4, character 17 |
| 24 |
Type error: illegal whitespace in identifier: M. N.f |
| 25 |
================================================================================ |
| 26 |
module M = struct module N = struct type t = <| f : nat |> end end |
| 27 |
let _ = <| M.N .f = 1 |> |
| 28 |
|
| 29 |
-------------------------------------------------------------------------------- |
| 30 |
File "test.lem", line 4, character 12 to line 4, character 17 |
| 31 |
Type error: illegal whitespace in identifier: M.N .f |
| 32 |
================================================================================ |
| 33 |
module M = struct module N = struct type t = <| f : nat |> end end |
| 34 |
let _ = <| M.N. f = 1 |> |
| 35 |
|
| 36 |
-------------------------------------------------------------------------------- |
| 37 |
File "test.lem", line 4, character 12 to line 4, character 17 |
| 38 |
Type error: illegal whitespace in identifier: M.N. f |
| 39 |
================================================================================ |
| 40 |
module M = struct let x = (1 : nat) end |
| 41 |
let _ = M .x |
| 42 |
|
| 43 |
-------------------------------------------------------------------------------- |
| 44 |
File "test.lem", line 4, character 9 to line 4, character 12 |
| 45 |
Type error: illegal whitespace in identifier: M .x |
| 46 |
================================================================================ |
| 47 |
module M = struct module N = struct let x = (1 : nat) end end |
| 48 |
let _ = M .N.x |
| 49 |
|
| 50 |
-------------------------------------------------------------------------------- |
| 51 |
File "test.lem", line 4, character 9 to line 4, character 14 |
| 52 |
Type error: illegal whitespace in identifier: M .N.x |
| 53 |
================================================================================ |
| 54 |
module M = struct module N = struct let x = (1 : nat) end end |
| 55 |
let _ = M. N.x |
| 56 |
|
| 57 |
-------------------------------------------------------------------------------- |
| 58 |
File "test.lem", line 4, character 9 to line 4, character 14 |
| 59 |
Type error: illegal whitespace in identifier: M. N.x |
| 60 |
================================================================================ |
| 61 |
module M = struct module N = struct let x = (1 : nat) end end |
| 62 |
let _ = M.N .x |
| 63 |
|
| 64 |
-------------------------------------------------------------------------------- |
| 65 |
File "test.lem", line 4, character 9 to line 4, character 14 |
| 66 |
Type error: illegal whitespace in identifier: M.N .x |
| 67 |
================================================================================ |
| 68 |
module M = struct module N = struct let x = (1 : nat) end end |
| 69 |
let _ = M.N. x |
| 70 |
|
| 71 |
|
| 72 |
-------------------------------------------------------------------------------- |
| 73 |
File "test.lem", line 4, character 9 to line 4, character 14 |
| 74 |
Type error: illegal whitespace in identifier: M.N. x |
| 75 |
================================================================================ |
| 76 |
(* --------------------------- Type tests ---------------------------------- *) |
| 77 |
(* ------------------------------------------------------------------------- *) |
| 78 |
(* ------------------------------------------------------------------------- *) |
| 79 |
|
| 80 |
type t = u |
| 81 |
|
| 82 |
-------------------------------------------------------------------------------- |
| 83 |
File "test.lem", line 7, character 10 to line 7, character 10 |
| 84 |
Type error: unbound type constructor: u |
| 85 |
================================================================================ |
| 86 |
type t = nat nat |
| 87 |
|
| 88 |
-------------------------------------------------------------------------------- |
| 89 |
File "test.lem", line 3, character 10 to line 3, character 16 |
| 90 |
Type error: type constructor expected 0 type arguments, given 1: nat |
| 91 |
================================================================================ |
| 92 |
type t 'a = c of 'a |
| 93 |
type u = t |
| 94 |
|
| 95 |
-------------------------------------------------------------------------------- |
| 96 |
File "test.lem", line 4, character 10 to line 4, character 10 |
| 97 |
Type error: type constructor expected 1 type arguments, given 0: t |
| 98 |
================================================================================ |
| 99 |
class (c 'a) val f : 'a end |
| 100 |
type t = c |
| 101 |
|
| 102 |
-------------------------------------------------------------------------------- |
| 103 |
File "test.lem", line 4, character 10 to line 4, character 10 |
| 104 |
Type error: type class used as type constructor: c |
| 105 |
================================================================================ |
| 106 |
(* ------------------------ Pattern tests ---------------------------------- *) |
| 107 |
(* ------------------------------------------------------------------------- *) |
| 108 |
(* ------------------------------------------------------------------------- *) |
| 109 |
|
| 110 |
type x = | X |
| 111 |
let f (X a) = (1 : nat) |
| 112 |
|
| 113 |
-------------------------------------------------------------------------------- |
| 114 |
File "test.lem", line 8, character 8 to line 8, character 8 |
| 115 |
Type error: constructor pattern expected 0 arguments, given 1: X |
| 116 |
================================================================================ |
| 117 |
type x = | X of bool |
| 118 |
let f (X a b) = (1 : nat) |
| 119 |
|
| 120 |
-------------------------------------------------------------------------------- |
| 121 |
File "test.lem", line 4, character 8 to line 4, character 8 |
| 122 |
Type error: constructor pattern expected 1 arguments, given 2: X |
| 123 |
================================================================================ |
| 124 |
module M = struct type t = | Y end |
| 125 |
let f (M.X y) = 1 |
| 126 |
|
| 127 |
-------------------------------------------------------------------------------- |
| 128 |
File "test.lem", line 4, character 10 to line 4, character 10 |
| 129 |
Type error: non-constructor pattern has a module path: M.X |
| 130 |
================================================================================ |
| 131 |
let f (M.X y) = (1 : nat) |
| 132 |
|
| 133 |
-------------------------------------------------------------------------------- |
| 134 |
File "test.lem", line 3, character 10 to line 3, character 10 |
| 135 |
Type error: unknown module: M |
| 136 |
================================================================================ |
| 137 |
type t = <| X : nat |> |
| 138 |
let f (X y) = (1 : nat) |
| 139 |
|
| 140 |
-------------------------------------------------------------------------------- |
| 141 |
File "test.lem", line 4, character 8 to line 4, character 8 |
| 142 |
Type error: non-constructor pattern given arguments: X |
| 143 |
================================================================================ |
| 144 |
let f (X y) = 1 |
| 145 |
|
| 146 |
-------------------------------------------------------------------------------- |
| 147 |
File "test.lem", line 3, character 8 to line 3, character 8 |
| 148 |
Type error: non-constructor pattern given arguments: X |
| 149 |
================================================================================ |
| 150 |
type t = | X of nat |
| 151 |
let f (_ as X) = match 1 with | (X 1) -> 1 end |
| 152 |
|
| 153 |
-------------------------------------------------------------------------------- |
| 154 |
File "test.lem", line 4, character 34 to line 4, character 34 |
| 155 |
Type error: non-constructor pattern given arguments: X |
| 156 |
================================================================================ |
| 157 |
let f <| fld = (1:nat) |> = (1:nat) |
| 158 |
|
| 159 |
-------------------------------------------------------------------------------- |
| 160 |
File "test.lem", line 3, character 10 to line 3, character 12 |
| 161 |
Type error: unbound field name: fld |
| 162 |
================================================================================ |
| 163 |
type t = | fld |
| 164 |
let f <| fld = (1:nat) |> = (1:nat) |
| 165 |
|
| 166 |
-------------------------------------------------------------------------------- |
| 167 |
File "test.lem", line 4, character 10 to line 4, character 12 |
| 168 |
Type error: constructor name used as a field name: fld |
| 169 |
================================================================================ |
| 170 |
let fld = (1:nat) |
| 171 |
let f <| fld = (1:nat) |> = (1:nat) |
| 172 |
|
| 173 |
-------------------------------------------------------------------------------- |
| 174 |
File "test.lem", line 4, character 10 to line 4, character 12 |
| 175 |
Type error: top level variable binding used as a field name: fld |
| 176 |
================================================================================ |
| 177 |
class (c 'a) val fld : nat end |
| 178 |
let f <| fld = (1:nat) |> = (1:nat) |
| 179 |
|
| 180 |
-------------------------------------------------------------------------------- |
| 181 |
File "test.lem", line 4, character 10 to line 4, character 12 |
| 182 |
Type error: method name used as a field name: fld |
| 183 |
================================================================================ |
| 184 |
type t = <| fld : bool |> |
| 185 |
let f <| fld = true; fld2 = false |> = 0 |
| 186 |
|
| 187 |
-------------------------------------------------------------------------------- |
| 188 |
File "test.lem", line 4, character 22 to line 4, character 25 |
| 189 |
Type error: unbound field name: fld2 |
| 190 |
================================================================================ |
| 191 |
type t = <| fld : bool |> |
| 192 |
let f <| fld = true; fld = true |> = 0 |
| 193 |
|
| 194 |
-------------------------------------------------------------------------------- |
| 195 |
File "test.lem", line 4, character 22 to line 4, character 24 |
| 196 |
Type error: duplicate field name: fld |
| 197 |
================================================================================ |
| 198 |
let f (x,x) = 1 |
| 199 |
|
| 200 |
-------------------------------------------------------------------------------- |
| 201 |
File "test.lem", line 3, character 10 to line 3, character 10 |
| 202 |
Type error: duplicate binding: x |
| 203 |
================================================================================ |
| 204 |
(* ------------------------ Expression tests ------------------------------- *) |
| 205 |
(* ------------------------------------------------------------------------- *) |
| 206 |
(* ------------------------------------------------------------------------- *) |
| 207 |
|
| 208 |
let _ = x |
| 209 |
|
| 210 |
-------------------------------------------------------------------------------- |
| 211 |
File "test.lem", line 7, character 9 to line 7, character 9 |
| 212 |
Type error: unbound variable: x |
| 213 |
================================================================================ |
| 214 |
let f x = x +++ x |
| 215 |
|
| 216 |
-------------------------------------------------------------------------------- |
| 217 |
File "test.lem", line 3, character 13 to line 3, character 15 |
| 218 |
Type error: unbound variable: +++ |
| 219 |
================================================================================ |
| 220 |
let _ = M.x |
| 221 |
|
| 222 |
-------------------------------------------------------------------------------- |
| 223 |
File "test.lem", line 3, character 9 to line 3, character 9 |
| 224 |
Type error: unbound module name or variable: M |
| 225 |
================================================================================ |
| 226 |
module M = struct let y = (10:nat) end |
| 227 |
let _ = M.x |
| 228 |
|
| 229 |
-------------------------------------------------------------------------------- |
| 230 |
File "test.lem", line 4, character 11 to line 4, character 11 |
| 231 |
Type error: unbound variable: M.x |
| 232 |
================================================================================ |
| 233 |
module M = struct let y = (10:nat) end |
| 234 |
let _ = M.N.x |
| 235 |
|
| 236 |
-------------------------------------------------------------------------------- |
| 237 |
File "test.lem", line 4, character 11 to line 4, character 11 |
| 238 |
Type error: unbound module name or variable: M.N |
| 239 |
================================================================================ |
| 240 |
type t = <| x : bool |> |
| 241 |
let _ = x |
| 242 |
|
| 243 |
-------------------------------------------------------------------------------- |
| 244 |
File "test.lem", line 4, character 9 to line 4, character 9 |
| 245 |
Type error: unbound variable: x |
| 246 |
================================================================================ |
| 247 |
let _ = fun x x -> x |
| 248 |
|
| 249 |
-------------------------------------------------------------------------------- |
| 250 |
File "test.lem", line 3, character 13 to line 3, character 13 |
| 251 |
Type error: duplicate binding: x |
| 252 |
================================================================================ |
| 253 |
let _ = <| fld = (1:nat) |> |
| 254 |
|
| 255 |
-------------------------------------------------------------------------------- |
| 256 |
File "test.lem", line 3, character 12 to line 3, character 14 |
| 257 |
Type error: unbound field name: fld |
| 258 |
================================================================================ |
| 259 |
type t = | fld |
| 260 |
let _ = <| fld = (1:nat) |> |
| 261 |
|
| 262 |
-------------------------------------------------------------------------------- |
| 263 |
File "test.lem", line 4, character 12 to line 4, character 14 |
| 264 |
Type error: constructor name used as a field name: fld |
| 265 |
================================================================================ |
| 266 |
let fld = (1 : nat) |
| 267 |
let _ = <| fld = (1:nat) |> |
| 268 |
|
| 269 |
-------------------------------------------------------------------------------- |
| 270 |
File "test.lem", line 4, character 12 to line 4, character 14 |
| 271 |
Type error: top level variable binding used as a field name: fld |
| 272 |
================================================================================ |
| 273 |
type t = <| fld : bool |> |
| 274 |
let _ = <| fld = true; fld2 = false |> |
| 275 |
|
| 276 |
-------------------------------------------------------------------------------- |
| 277 |
File "test.lem", line 4, character 24 to line 4, character 27 |
| 278 |
Type error: unbound field name: fld2 |
| 279 |
================================================================================ |
| 280 |
type t = <| fld : bool |> |
| 281 |
let _ = <| fld = true; fld = true |> |
| 282 |
|
| 283 |
-------------------------------------------------------------------------------- |
| 284 |
File "test.lem", line 4, character 24 to line 4, character 26 |
| 285 |
Type error: duplicate field name: fld |
| 286 |
================================================================================ |
| 287 |
type t = <| fld1 : bool; fld2 : bool |> |
| 288 |
let _ = <| fld1 = true |> |
| 289 |
|
| 290 |
-------------------------------------------------------------------------------- |
| 291 |
File "test.lem", line 4, character 9 to line 4, character 25 |
| 292 |
Type error: missing field: fld2 |
| 293 |
================================================================================ |
| 294 |
let _ = |
| 295 |
let x = x in |
| 296 |
x |
| 297 |
|
| 298 |
-------------------------------------------------------------------------------- |
| 299 |
File "test.lem", line 4, character 11 to line 4, character 11 |
| 300 |
Type error: unbound variable: x |
| 301 |
================================================================================ |
| 302 |
let _ = |
| 303 |
let f x = f x in |
| 304 |
f |
| 305 |
|
| 306 |
-------------------------------------------------------------------------------- |
| 307 |
File "test.lem", line 4, character 13 to line 4, character 13 |
| 308 |
Type error: unbound variable: f |
| 309 |
================================================================================ |
| 310 |
let _ = |
| 311 |
let f x = 1 in |
| 312 |
x |
| 313 |
|
| 314 |
-------------------------------------------------------------------------------- |
| 315 |
File "test.lem", line 5, character 5 to line 5, character 5 |
| 316 |
Type error: unbound variable: x |
| 317 |
================================================================================ |
| 318 |
let _ = { x | forall y | x } |
| 319 |
|
| 320 |
-------------------------------------------------------------------------------- |
| 321 |
File "test.lem", line 3, character 11 to line 3, character 11 |
| 322 |
Type error: unbound variable: x |
| 323 |
================================================================================ |
| 324 |
let _ = { x | forall (x IN x) | x } |
| 325 |
|
| 326 |
-------------------------------------------------------------------------------- |
| 327 |
File "test.lem", line 3, character 28 to line 3, character 28 |
| 328 |
Type error: unbound variable: x |
| 329 |
================================================================================ |
| 330 |
let _ = { x | forall (x IN {}) (x IN {}) | x } |
| 331 |
|
| 332 |
-------------------------------------------------------------------------------- |
| 333 |
File "test.lem", line 3, character 33 to line 3, character 33 |
| 334 |
Type error: duplicate binding: x |
| 335 |
================================================================================ |
| 336 |
let _ = [ x | forall (x IN {}) | x ] |
| 337 |
|
| 338 |
-------------------------------------------------------------------------------- |
| 339 |
File "test.lem", line 3, character 23 to line 3, character 23 |
| 340 |
Type error: set-restricted quantifier in list comprehension: |
| 341 |
================================================================================ |
| 342 |
let _ = [ x | forall x | x ] |
| 343 |
|
| 344 |
-------------------------------------------------------------------------------- |
| 345 |
File "test.lem", line 3, character 22 to line 3, character 22 |
| 346 |
Type error: unrestricted quantifier in list comprehension: x |
| 347 |
================================================================================ |
| 348 |
let _ = forall (x IN x). true |
| 349 |
|
| 350 |
-------------------------------------------------------------------------------- |
| 351 |
File "test.lem", line 3, character 22 to line 3, character 22 |
| 352 |
Type error: unbound variable: x |
| 353 |
================================================================================ |
| 354 |
let _ = forall (x IN {}) (x IN {}). true |
| 355 |
|
| 356 |
-------------------------------------------------------------------------------- |
| 357 |
File "test.lem", line 3, character 27 to line 3, character 27 |
| 358 |
Type error: duplicate binding: x |
| 359 |
================================================================================ |
| 360 |
|
| 361 |
(* ---------------------------- Do notation tests -------------------------- *) |
| 362 |
(* ------------------------------------------------------------------------- *) |
| 363 |
(* ------------------------------------------------------------------------- *) |
| 364 |
|
| 365 |
let _ = |
| 366 |
do M |
| 367 |
in |
| 368 |
[(4 : nat)] |
| 369 |
end |
| 370 |
|
| 371 |
-------------------------------------------------------------------------------- |
| 372 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 373 |
Type error: unknown module: M |
| 374 |
================================================================================ |
| 375 |
module M = struct |
| 376 |
type x = nat |
| 377 |
end |
| 378 |
let _ = |
| 379 |
do M |
| 380 |
in |
| 381 |
Nothing |
| 382 |
end |
| 383 |
|
| 384 |
-------------------------------------------------------------------------------- |
| 385 |
File "test.lem", line 7, character 6 to line 7, character 6 |
| 386 |
Type error: monad module missing type t: M |
| 387 |
================================================================================ |
| 388 |
module M = struct |
| 389 |
type t 'a = maybe 'a |
| 390 |
end |
| 391 |
let _ = |
| 392 |
do M |
| 393 |
in |
| 394 |
Nothing |
| 395 |
end |
| 396 |
|
| 397 |
-------------------------------------------------------------------------------- |
| 398 |
File "test.lem", line 7, character 6 to line 7, character 6 |
| 399 |
Type error: monad module missing return: Test.M |
| 400 |
================================================================================ |
| 401 |
module M = struct |
| 402 |
type t 'a = maybe 'a |
| 403 |
let return x = Just x |
| 404 |
end |
| 405 |
let _ = |
| 406 |
do M |
| 407 |
in |
| 408 |
Nothing |
| 409 |
end |
| 410 |
|
| 411 |
-------------------------------------------------------------------------------- |
| 412 |
File "test.lem", line 8, character 6 to line 8, character 6 |
| 413 |
Type error: monad module missing bind: Test.M |
| 414 |
================================================================================ |
| 415 |
module M = struct |
| 416 |
type t 'a = maybe 'a |
| 417 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 418 |
end |
| 419 |
let _ = |
| 420 |
do M |
| 421 |
in |
| 422 |
Nothing |
| 423 |
end |
| 424 |
|
| 425 |
-------------------------------------------------------------------------------- |
| 426 |
File "test.lem", line 8, character 6 to line 8, character 6 |
| 427 |
Type error: monad module missing return: Test.M |
| 428 |
================================================================================ |
| 429 |
module M = struct |
| 430 |
let return x = Just x |
| 431 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 432 |
end |
| 433 |
let _ = |
| 434 |
do M |
| 435 |
in |
| 436 |
Nothing |
| 437 |
end |
| 438 |
|
| 439 |
-------------------------------------------------------------------------------- |
| 440 |
File "test.lem", line 8, character 6 to line 8, character 6 |
| 441 |
Type error: monad module missing type t: M |
| 442 |
================================================================================ |
| 443 |
module M = struct |
| 444 |
type t 'a = return of 'a |
| 445 |
val bind : forall 'a 'b. t 'a -> ('a -> t 'b) -> t 'b |
| 446 |
let bind x f = match x with return y -> f y end |
| 447 |
end |
| 448 |
let _ = |
| 449 |
do M |
| 450 |
in |
| 451 |
M.return (1 : nat) |
| 452 |
end |
| 453 |
|
| 454 |
-------------------------------------------------------------------------------- |
| 455 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 456 |
Type error: monad module return bound to constructor: Test.M |
| 457 |
================================================================================ |
| 458 |
module M = struct |
| 459 |
type t 'a = maybe 'a |
| 460 |
let return x = Just x |
| 461 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 462 |
end |
| 463 |
let _ = |
| 464 |
do M |
| 465 |
x <- (1 : nat); |
| 466 |
in |
| 467 |
Nothing |
| 468 |
end |
| 469 |
|
| 470 |
-------------------------------------------------------------------------------- |
| 471 |
File "test.lem", line 10, character 10 to line 10, character 18 |
| 472 |
Type error: type mismatch: do expression |
| 473 |
nat |
| 474 |
and |
| 475 |
Maybe.maybe _ |
| 476 |
================================================================================ |
| 477 |
module M = struct |
| 478 |
type t 'a = maybe 'a |
| 479 |
let return x = x |
| 480 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 481 |
end |
| 482 |
let _ = |
| 483 |
do M |
| 484 |
in |
| 485 |
Nothing |
| 486 |
end |
| 487 |
|
| 488 |
-------------------------------------------------------------------------------- |
| 489 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 490 |
Type error: type mismatch: do/return |
| 491 |
'a |
| 492 |
and |
| 493 |
Maybe.maybe 'a |
| 494 |
================================================================================ |
| 495 |
module M = struct |
| 496 |
type t 'a = maybe 'a |
| 497 |
let return x = Just x |
| 498 |
let bind x y = match x with Nothing -> Nothing | Just x -> x end |
| 499 |
end |
| 500 |
let _ = |
| 501 |
do M |
| 502 |
in |
| 503 |
Nothing |
| 504 |
end |
| 505 |
|
| 506 |
-------------------------------------------------------------------------------- |
| 507 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 508 |
Type error: type mismatch: do/>>= |
| 509 |
Maybe.maybe 'a |
| 510 |
and |
| 511 |
'b |
| 512 |
================================================================================ |
| 513 |
module M = struct |
| 514 |
type t 'a = maybe 'a |
| 515 |
let return x = Just x |
| 516 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 517 |
end |
| 518 |
let _ = |
| 519 |
do M |
| 520 |
in |
| 521 |
(1 : nat) |
| 522 |
end |
| 523 |
|
| 524 |
-------------------------------------------------------------------------------- |
| 525 |
File "test.lem", line 9, character 3 to line 12, character 3 |
| 526 |
Type error: type mismatch: do expression |
| 527 |
nat |
| 528 |
and |
| 529 |
Maybe.maybe _ |
| 530 |
================================================================================ |
| 531 |
module M = struct |
| 532 |
type t = maybe nat |
| 533 |
let return x = Just x |
| 534 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 535 |
end |
| 536 |
let _ = |
| 537 |
do M |
| 538 |
in |
| 539 |
Nothing |
| 540 |
end |
| 541 |
|
| 542 |
-------------------------------------------------------------------------------- |
| 543 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 544 |
Type error: monad type constructor with 0 parameters: Test.M.t |
| 545 |
================================================================================ |
| 546 |
module M = struct |
| 547 |
type t 'a 'b = maybe 'a |
| 548 |
let return x = Just x |
| 549 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 550 |
end |
| 551 |
let _ = |
| 552 |
do M |
| 553 |
in |
| 554 |
Nothing |
| 555 |
end |
| 556 |
|
| 557 |
-------------------------------------------------------------------------------- |
| 558 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 559 |
Type error: monad type constructor with 2 parameters: Test.M.t |
| 560 |
================================================================================ |
| 561 |
module M = struct |
| 562 |
type t 'a = maybe 'a |
| 563 |
let return (x,y) = Just x |
| 564 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 565 |
end |
| 566 |
let _ = |
| 567 |
do M |
| 568 |
in |
| 569 |
Nothing |
| 570 |
end |
| 571 |
|
| 572 |
-------------------------------------------------------------------------------- |
| 573 |
File "test.lem", line 9, character 6 to line 9, character 6 |
| 574 |
Type error: monad return function with 2 type parameters: Test.M |
| 575 |
================================================================================ |
| 576 |
module M = struct |
| 577 |
type t 'a = maybe 'a |
| 578 |
let return x = Just x |
| 579 |
val bind : forall 'a. t 'a -> ('a -> t 'a) -> t 'a |
| 580 |
let bind x y = match x with Nothing -> Nothing | Just x -> y x end |
| 581 |
end |
| 582 |
let _ = |
| 583 |
do M |
| 584 |
in |
| 585 |
Nothing |
| 586 |
end |
| 587 |
|
| 588 |
-------------------------------------------------------------------------------- |
| 589 |
File "test.lem", line 10, character 6 to line 10, character 6 |
| 590 |
Type error: monad >>= function with 1 type parameters: Test.M |
| 591 |
================================================================================ |
| 592 |
|
| 593 |
(* ------------------------ Type definition tests -------------------------- *) |
| 594 |
(* ------------------------------------------------------------------------- *) |
| 595 |
(* ------------------------------------------------------------------------- *) |
| 596 |
|
| 597 |
type t = nat and t = bool |
| 598 |
|
| 599 |
-------------------------------------------------------------------------------- |
| 600 |
File "test.lem", line 8, character 18 to line 8, character 18 |
| 601 |
Type error: duplicate type constructor definition: t |
| 602 |
================================================================================ |
| 603 |
type t = nat |
| 604 |
type t = nat |
| 605 |
|
| 606 |
-------------------------------------------------------------------------------- |
| 607 |
File "test.lem", line 4, character 6 to line 4, character 6 |
| 608 |
Type error: duplicate type constructor definition: t |
| 609 |
================================================================================ |
| 610 |
class (c 'a) val f : 'a end |
| 611 |
type c = nat |
| 612 |
|
| 613 |
-------------------------------------------------------------------------------- |
| 614 |
File "test.lem", line 4, character 6 to line 4, character 6 |
| 615 |
Type error: type constructor already defined as a type class: c |
| 616 |
================================================================================ |
| 617 |
type t 'a 'a = nat |
| 618 |
|
| 619 |
-------------------------------------------------------------------------------- |
| 620 |
File "test.lem", line 3, character 8 to line 3, character 9 |
| 621 |
Type error: duplicate type variable: 'a |
| 622 |
================================================================================ |
| 623 |
type t = <| f : bool; f : bool |> |
| 624 |
|
| 625 |
-------------------------------------------------------------------------------- |
| 626 |
File "test.lem", line 3, character 23 to line 3, character 23 |
| 627 |
Type error: duplicate field name definition: f |
| 628 |
================================================================================ |
| 629 |
type t = <| f : bool |> |
| 630 |
type u = <| f : bool |> |
| 631 |
|
| 632 |
-------------------------------------------------------------------------------- |
| 633 |
File "test.lem", line 4, character 13 to line 4, character 13 |
| 634 |
Type error: duplicate field name definition: f |
| 635 |
================================================================================ |
| 636 |
type t = <| f : bool |> and u = <| f : bool |> |
| 637 |
|
| 638 |
-------------------------------------------------------------------------------- |
| 639 |
File "test.lem", line 3, character 36 to line 3, character 36 |
| 640 |
Type error: duplicate field name definition: f |
| 641 |
================================================================================ |
| 642 |
type t = u and u = bool |
| 643 |
|
| 644 |
-------------------------------------------------------------------------------- |
| 645 |
File "test.lem", line 3, character 10 to line 3, character 10 |
| 646 |
Type error: unbound type constructor: u |
| 647 |
================================================================================ |
| 648 |
type t = | C | C |
| 649 |
|
| 650 |
-------------------------------------------------------------------------------- |
| 651 |
File "test.lem", line 3, character 16 to line 3, character 16 |
| 652 |
Type error: duplicate constructor definition: C |
| 653 |
================================================================================ |
| 654 |
type t = | C and u = | C |
| 655 |
|
| 656 |
-------------------------------------------------------------------------------- |
| 657 |
File "test.lem", line 3, character 24 to line 3, character 24 |
| 658 |
Type error: duplicate constructor definition: C |
| 659 |
================================================================================ |
| 660 |
type t = | C |
| 661 |
type u = | C |
| 662 |
|
| 663 |
-------------------------------------------------------------------------------- |
| 664 |
File "test.lem", line 4, character 12 to line 4, character 12 |
| 665 |
Type error: duplicate constructor definition: C |
| 666 |
================================================================================ |
| 667 |
let C = (1:nat) |
| 668 |
type u = | C |
| 669 |
|
| 670 |
-------------------------------------------------------------------------------- |
| 671 |
File "test.lem", line 4, character 12 to line 4, character 12 |
| 672 |
Type error: constructor already defined as a top-level variable binding: C |
| 673 |
================================================================================ |
| 674 |
class (c 'a) val C : nat end |
| 675 |
type u = | C |
| 676 |
|
| 677 |
-------------------------------------------------------------------------------- |
| 678 |
File "test.lem", line 4, character 12 to line 4, character 12 |
| 679 |
Type error: constructor already defined as a class method: C |
| 680 |
================================================================================ |
| 681 |
type u 'a = 'a and t = list 'a |
| 682 |
|
| 683 |
-------------------------------------------------------------------------------- |
| 684 |
File "test.lem", line 3, character 29 to line 3, character 30 |
| 685 |
Type error: unbound type variable: 'a |
| 686 |
================================================================================ |
| 687 |
type u 'a = 'a and t = C of 'a |
| 688 |
|
| 689 |
-------------------------------------------------------------------------------- |
| 690 |
File "test.lem", line 3, character 29 to line 3, character 30 |
| 691 |
Type error: unbound type variable: 'a |
| 692 |
================================================================================ |
| 693 |
type u 'a = 'a and t = <| f : 'a |> |
| 694 |
|
| 695 |
-------------------------------------------------------------------------------- |
| 696 |
File "test.lem", line 3, character 31 to line 3, character 32 |
| 697 |
Type error: unbound type variable: 'a |
| 698 |
================================================================================ |
| 699 |
type t 'a |
| 700 |
type u 'b = t |
| 701 |
|
| 702 |
-------------------------------------------------------------------------------- |
| 703 |
File "test.lem", line 4, character 13 to line 4, character 13 |
| 704 |
Type error: type constructor expected 1 type arguments, given 0: t |
| 705 |
================================================================================ |
| 706 |
type t |
| 707 |
type u 'b = t 'b |
| 708 |
|
| 709 |
-------------------------------------------------------------------------------- |
| 710 |
File "test.lem", line 4, character 13 to line 4, character 16 |
| 711 |
Type error: type constructor expected 0 type arguments, given 1: t |
| 712 |
================================================================================ |
| 713 |
type t 'a 'b |
| 714 |
type u 'b = t 'b |
| 715 |
|
| 716 |
-------------------------------------------------------------------------------- |
| 717 |
File "test.lem", line 4, character 13 to line 4, character 16 |
| 718 |
Type error: type constructor expected 2 type arguments, given 1: t |
| 719 |
================================================================================ |
| 720 |
type t = _ |
| 721 |
|
| 722 |
-------------------------------------------------------------------------------- |
| 723 |
File "test.lem", line 3, character 10 to line 3, character 10 |
| 724 |
Type error: anonymous types not permitted here: _ |
| 725 |
================================================================================ |
| 726 |
type t = C of _ |
| 727 |
|
| 728 |
-------------------------------------------------------------------------------- |
| 729 |
File "test.lem", line 3, character 15 to line 3, character 15 |
| 730 |
Type error: anonymous types not permitted here: _ |
| 731 |
================================================================================ |
| 732 |
|
| 733 |
(* ------------------------ Value definition tests ------------------------- *) |
| 734 |
(* ------------------------------------------------------------------------- *) |
| 735 |
(* ------------------------------------------------------------------------- *) |
| 736 |
|
| 737 |
(* Has a type error, unless not using any backends (except for tex) *) |
| 738 |
val x : nat |
| 739 |
let _ = x |
| 740 |
|
| 741 |
-------------------------------------------------------------------------------- |
| 742 |
File "test.lem", line 10, character 9 to line 10, character 9 |
| 743 |
Type error: unbound variable for targets {hol;ocaml}: x |
| 744 |
================================================================================ |
| 745 |
val x : 'a |
| 746 |
|
| 747 |
-------------------------------------------------------------------------------- |
| 748 |
File "test.lem", line 3, character 9 to line 3, character 10 |
| 749 |
Type error: unbound type variable: 'a |
| 750 |
================================================================================ |
| 751 |
val x : forall 'a 'b 'a. nat |
| 752 |
|
| 753 |
-------------------------------------------------------------------------------- |
| 754 |
File "test.lem", line 3, character 16 to line 3, character 17 |
| 755 |
Type error: duplicate type variable: 'a |
| 756 |
================================================================================ |
| 757 |
val x : _ |
| 758 |
|
| 759 |
-------------------------------------------------------------------------------- |
| 760 |
File "test.lem", line 3, character 9 to line 3, character 9 |
| 761 |
Type error: anonymous types not permitted here: _ |
| 762 |
================================================================================ |
| 763 |
val x : forall 'a. c 'a => nat |
| 764 |
|
| 765 |
-------------------------------------------------------------------------------- |
| 766 |
File "test.lem", line 3, character 20 to line 3, character 20 |
| 767 |
Type error: unbound type class: c |
| 768 |
================================================================================ |
| 769 |
class (c 'a) val f : nat end |
| 770 |
val x : forall 'a. c 'b => nat |
| 771 |
|
| 772 |
-------------------------------------------------------------------------------- |
| 773 |
File "test.lem", line 4, character 22 to line 4, character 23 |
| 774 |
Type error: unbound type variable: 'b |
| 775 |
================================================================================ |
| 776 |
val x : nat |
| 777 |
val x : nat |
| 778 |
|
| 779 |
-------------------------------------------------------------------------------- |
| 780 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 781 |
Type error: specified variable already defined as a top-level variable binding: x |
| 782 |
================================================================================ |
| 783 |
type t = |x |
| 784 |
val x : nat |
| 785 |
|
| 786 |
-------------------------------------------------------------------------------- |
| 787 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 788 |
Type error: specified variable already defined as a constructor: x |
| 789 |
================================================================================ |
| 790 |
class (c 'a) val x : nat end |
| 791 |
val x : nat |
| 792 |
|
| 793 |
-------------------------------------------------------------------------------- |
| 794 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 795 |
Type error: specified variable already defined as a class method: x |
| 796 |
================================================================================ |
| 797 |
let x = (10 : nat) |
| 798 |
val x : nat |
| 799 |
|
| 800 |
-------------------------------------------------------------------------------- |
| 801 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 802 |
Type error: specified variable already defined as a top-level variable binding: x |
| 803 |
================================================================================ |
| 804 |
let {hol} x = (10 : nat) |
| 805 |
val x : nat |
| 806 |
|
| 807 |
-------------------------------------------------------------------------------- |
| 808 |
File "test.lem", line 3, character 11 to line 3, character 11 |
| 809 |
Type error: target-specific definition without preceding 'val' specification: x |
| 810 |
================================================================================ |
| 811 |
let x = (1 : nat) |
| 812 |
let x = (2 : nat) |
| 813 |
|
| 814 |
-------------------------------------------------------------------------------- |
| 815 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 816 |
Type error: defined variable 'x' is already defined for all targets |
| 817 |
================================================================================ |
| 818 |
class (c 'a) val x : nat end |
| 819 |
let x = (1 : nat) |
| 820 |
|
| 821 |
-------------------------------------------------------------------------------- |
| 822 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 823 |
Type error: defined variable 'x' is already defined for all targets |
| 824 |
================================================================================ |
| 825 |
type t = |x |
| 826 |
let x y = (1 : nat) |
| 827 |
|
| 828 |
-------------------------------------------------------------------------------- |
| 829 |
File "test.lem", line 4, character 5 to line 4, character 5 |
| 830 |
Type error: constructor pattern expected 0 arguments, given 1: x |
| 831 |
================================================================================ |
| 832 |
val x : nat |
| 833 |
let {hol} x = 1 |
| 834 |
let {isabelle;hol} x = 2 |
| 835 |
|
| 836 |
-------------------------------------------------------------------------------- |
| 837 |
File "test.lem", line 5, character 20 to line 5, character 20 |
| 838 |
Type error: defined variable 'x' is already defined for targets: hol |
| 839 |
================================================================================ |
| 840 |
let {hol} x = 1 |
| 841 |
let x = 2 |
| 842 |
|
| 843 |
-------------------------------------------------------------------------------- |
| 844 |
File "test.lem", line 3, character 11 to line 3, character 11 |
| 845 |
Type error: target-specific definition without preceding 'val' specification: x |
| 846 |
================================================================================ |
| 847 |
let x = (1 : nat) |
| 848 |
let rec y (1 : nat) = (1 : nat) and x (1:nat) = (1:nat) |
| 849 |
|
| 850 |
-------------------------------------------------------------------------------- |
| 851 |
File "test.lem", line 4, character 37 to line 4, character 37 |
| 852 |
Type error: defined variable 'x' is already defined for all targets |
| 853 |
================================================================================ |
| 854 |
let x = (1:nat) |
| 855 |
indreln [ x : forall 'a. 'a -> bool ] arm : forall y. true ==> x y |
| 856 |
|
| 857 |
-------------------------------------------------------------------------------- |
| 858 |
File "test.lem", line 4, character 11 to line 4, character 11 |
| 859 |
Type error: defined variable 'x' is already defined for all targets |
| 860 |
================================================================================ |
| 861 |
val x : nat |
| 862 |
let inline {hol} x = 1 |
| 863 |
let inline {hol} x = 1 |
| 864 |
|
| 865 |
-------------------------------------------------------------------------------- |
| 866 |
File "test.lem", line 5, character 1 to line 5, character 22 |
| 867 |
Type error: a hol target representation for 'Test.x' has already been given at |
| 868 |
File "test.lem", line 4, character 1 to line 4, character 22 |
| 869 |
================================================================================ |
| 870 |
val x : nat |
| 871 |
let {ocaml} x = 1 |
| 872 |
let _ = x |
| 873 |
|
| 874 |
-------------------------------------------------------------------------------- |
| 875 |
File "test.lem", line 5, character 9 to line 5, character 9 |
| 876 |
Type error: unbound variable for targets {hol}: x |
| 877 |
================================================================================ |
| 878 |
val x : nat |
| 879 |
let {ocaml} x = 1 |
| 880 |
let {hol} _ = x |
| 881 |
|
| 882 |
-------------------------------------------------------------------------------- |
| 883 |
File "test.lem", line 5, character 15 to line 5, character 15 |
| 884 |
Type error: unbound variable for targets {hol}: x |
| 885 |
================================================================================ |
| 886 |
val x : nat |
| 887 |
let x = 1 |
| 888 |
let _ = x |
| 889 |
let {hol} x = 1 |
| 890 |
|
| 891 |
-------------------------------------------------------------------------------- |
| 892 |
File "test.lem", line 6, character 11 to line 6, character 11 |
| 893 |
Type error: defined variable 'x' is already defined for targets: hol |
| 894 |
================================================================================ |
| 895 |
(* ------------------------ Modules ---------------------------------------- *) |
| 896 |
(* ------------------------------------------------------------------------- *) |
| 897 |
(* ------------------------------------------------------------------------- *) |
| 898 |
|
| 899 |
module X = struct let y = (1 : nat) end |
| 900 |
module X = struct let z = (1 : nat) end |
| 901 |
|
| 902 |
-------------------------------------------------------------------------------- |
| 903 |
File "test.lem", line 8, character 8 to line 8, character 8 |
| 904 |
Type error: duplicate module definition: X |
| 905 |
================================================================================ |
| 906 |
module X = struct let Y = (1 : nat) end |
| 907 |
module Y = X |
| 908 |
module Y = X |
| 909 |
|
| 910 |
-------------------------------------------------------------------------------- |
| 911 |
File "test.lem", line 5, character 8 to line 5, character 8 |
| 912 |
Type error: duplicate module definition: Y |
| 913 |
================================================================================ |
| 914 |
module X = struct let Y = (1:nat) end |
| 915 |
module Y = struct let Z = (1:nat) end |
| 916 |
module X = Y |
| 917 |
|
| 918 |
-------------------------------------------------------------------------------- |
| 919 |
File "test.lem", line 5, character 8 to line 5, character 8 |
| 920 |
Type error: duplicate module definition: X |
| 921 |
================================================================================ |
| 922 |
module X = Y |
| 923 |
|
| 924 |
-------------------------------------------------------------------------------- |
| 925 |
File "test.lem", line 3, character 12 to line 3, character 12 |
| 926 |
Type error: unknown module: Y |
| 927 |
================================================================================ |
| 928 |
open x |
| 929 |
|
| 930 |
-------------------------------------------------------------------------------- |
| 931 |
File "test.lem", line 3, character 6 to line 3, character 6 |
| 932 |
Type error: unknown module: x |
| 933 |
================================================================================ |
| 934 |
module X = struct let X = (1 : nat) let X = (1 : nat) end |
| 935 |
|
| 936 |
-------------------------------------------------------------------------------- |
| 937 |
File "test.lem", line 3, character 41 to line 3, character 41 |
| 938 |
Type error: defined variable 'X' is already defined for all targets |
| 939 |
================================================================================ |
| 940 |
module X = struct let C = (1 : nat) end |
| 941 |
type t = | C of nat |
| 942 |
open X |
| 943 |
let f (C 1) = (1 : nat) |
| 944 |
|
| 945 |
-------------------------------------------------------------------------------- |
| 946 |
File "test.lem", line 6, character 8 to line 6, character 8 |
| 947 |
Type error: non-constructor pattern given arguments: C |
| 948 |
================================================================================ |
| 949 |
|
| 950 |
(* --------------------------- Type classes -------------------------------- *) |
| 951 |
(* ------------------------------------------------------------------------- *) |
| 952 |
(* ------------------------------------------------------------------------- *) |
| 953 |
|
| 954 |
class (c 'a) val x : 'b end |
| 955 |
|
| 956 |
-------------------------------------------------------------------------------- |
| 957 |
File "test.lem", line 8, character 22 to line 8, character 23 |
| 958 |
Type error: unbound type variable: 'b |
| 959 |
================================================================================ |
| 960 |
class (c 'a) val x : 'a end |
| 961 |
class (c 'a) val y : 'a end |
| 962 |
|
| 963 |
-------------------------------------------------------------------------------- |
| 964 |
File "test.lem", line 4, character 8 to line 4, character 8 |
| 965 |
Type error: duplicate type class definition: c |
| 966 |
================================================================================ |
| 967 |
type c = nat |
| 968 |
class (c 'a) val x : 'a end |
| 969 |
|
| 970 |
-------------------------------------------------------------------------------- |
| 971 |
File "test.lem", line 4, character 8 to line 4, character 8 |
| 972 |
Type error: type class already defined as a type constructor: c |
| 973 |
================================================================================ |
| 974 |
class (c 'a) val x : 'a end |
| 975 |
class (d 'a) val x : 'a end |
| 976 |
|
| 977 |
-------------------------------------------------------------------------------- |
| 978 |
File "test.lem", line 4, character 18 to line 4, character 18 |
| 979 |
Type error: duplicate class method definition: x |
| 980 |
================================================================================ |
| 981 |
class (c 'a) val x : 'a val x : 'a end |
| 982 |
|
| 983 |
-------------------------------------------------------------------------------- |
| 984 |
File "test.lem", line 3, character 29 to line 3, character 29 |
| 985 |
Type error: duplicate class method definition: x |
| 986 |
================================================================================ |
| 987 |
let x = (1:nat) |
| 988 |
class (c 'a) val x : 'a end |
| 989 |
|
| 990 |
-------------------------------------------------------------------------------- |
| 991 |
File "test.lem", line 4, character 18 to line 4, character 18 |
| 992 |
Type error: class method already defined as a top-level variable binding: x |
| 993 |
================================================================================ |
| 994 |
val x : nat |
| 995 |
class (c 'a) val x : 'a end |
| 996 |
|
| 997 |
-------------------------------------------------------------------------------- |
| 998 |
File "test.lem", line 4, character 18 to line 4, character 18 |
| 999 |
Type error: class method already defined as a top-level variable binding: x |
| 1000 |
================================================================================ |
| 1001 |
type t = | x |
| 1002 |
class (c 'a) val x : 'a end |
| 1003 |
|
| 1004 |
-------------------------------------------------------------------------------- |
| 1005 |
File "test.lem", line 4, character 18 to line 4, character 18 |
| 1006 |
Type error: class method already defined as a constructor: x |
| 1007 |
================================================================================ |
| 1008 |
class (c 'a) val x : _ end |
| 1009 |
|
| 1010 |
-------------------------------------------------------------------------------- |
| 1011 |
File "test.lem", line 3, character 22 to line 3, character 22 |
| 1012 |
Type error: anonymous types not permitted here: _ |
| 1013 |
================================================================================ |
| 1014 |
|
| 1015 |
(* --------------------------- Class instances ----------------------------- *) |
| 1016 |
(* ------------------------------------------------------------------------- *) |
| 1017 |
(* ------------------------------------------------------------------------- *) |
| 1018 |
|
| 1019 |
class (c 'a) val y : 'a end |
| 1020 |
instance (c nat) let x = 1 end |
| 1021 |
|
| 1022 |
-------------------------------------------------------------------------------- |
| 1023 |
File "test.lem", line 9, character 22 to line 9, character 22 |
| 1024 |
Type error: instance method not bound to class method: x |
| 1025 |
================================================================================ |
| 1026 |
class (c 'a) val x : 'a end |
| 1027 |
module M = struct let x = (10 : nat) end |
| 1028 |
open M |
| 1029 |
instance (c nat) let x = (10 : nat) end |
| 1030 |
|
| 1031 |
-------------------------------------------------------------------------------- |
| 1032 |
File "test.lem", line 6, character 22 to line 6, character 22 |
| 1033 |
Type error: instance method not bound to class method: x |
| 1034 |
================================================================================ |
| 1035 |
class (d 'a) val x : nat end |
| 1036 |
instance (c nat) let x = 1 end |
| 1037 |
|
| 1038 |
-------------------------------------------------------------------------------- |
| 1039 |
File "test.lem", line 4, character 11 to line 4, character 11 |
| 1040 |
Type error: unbound type class: c |
| 1041 |
================================================================================ |
| 1042 |
class (c 'a) val x : 'a val y : 'a end |
| 1043 |
instance (c nat) let x = 1 end |
| 1044 |
|
| 1045 |
-------------------------------------------------------------------------------- |
| 1046 |
File "test.lem", line 4, character 1 to line 4, character 30 |
| 1047 |
Type error: missing class method: y |
| 1048 |
================================================================================ |
| 1049 |
class (c 'a) val x : 'a end |
| 1050 |
class (d 'a) val y : 'a end |
| 1051 |
instance (c nat) let x = 1 let y = 2 end |
| 1052 |
|
| 1053 |
-------------------------------------------------------------------------------- |
| 1054 |
File "test.lem", line 5, character 32 to line 5, character 32 |
| 1055 |
Type error: unknown class method: y |
| 1056 |
================================================================================ |
| 1057 |
class (c 'a) val x : 'a end |
| 1058 |
type t 'a = list 'a |
| 1059 |
instance (c t nat) let x = [] end |
| 1060 |
|
| 1061 |
-------------------------------------------------------------------------------- |
| 1062 |
File "test.lem", line 5, character 13 to line 5, character 13 |
| 1063 |
Type error: type abbreviation in class instance type: t |
| 1064 |
================================================================================ |
| 1065 |
class (c 'a) val x : 'a end |
| 1066 |
instance (c list nat) let x = [] end |
| 1067 |
|
| 1068 |
-------------------------------------------------------------------------------- |
| 1069 |
File "test.lem", line 4, character 13 to line 4, character 20 |
| 1070 |
Type error: class instance type must be a type constructor applied to type variables: |
| 1071 |
list nat |
| 1072 |
================================================================================ |
| 1073 |
class (c 'a) val x : 'a end |
| 1074 |
instance (c (nat*nat)) let x = (1,1) end |
| 1075 |
|
| 1076 |
-------------------------------------------------------------------------------- |
| 1077 |
File "test.lem", line 4, character 14 to line 4, character 20 |
| 1078 |
Type error: class instance type must be a type constructor applied to type variables: |
| 1079 |
(nat * nat) |
| 1080 |
================================================================================ |
| 1081 |
class (c 'a) val x : 'a end |
| 1082 |
instance forall 'a. c 'a => (c ('a*'a)) let x = (x,x) end |
| 1083 |
|
| 1084 |
-------------------------------------------------------------------------------- |
| 1085 |
File "test.lem", line 4, character 33 to line 4, character 34 |
| 1086 |
Type error: duplicate type variable: 'a |
| 1087 |
================================================================================ |
| 1088 |
class (c 'a) val x : nat end |
| 1089 |
instance (c 'a) let x = 1 end |
| 1090 |
|
| 1091 |
-------------------------------------------------------------------------------- |
| 1092 |
File "test.lem", line 4, character 13 to line 4, character 14 |
| 1093 |
Type error: unbound type variable: 'a |
| 1094 |
================================================================================ |
| 1095 |
class (c 'a) val x : nat end |
| 1096 |
instance forall 'a. c 'b => (c 'a) let x = 1 end |
| 1097 |
|
| 1098 |
-------------------------------------------------------------------------------- |
| 1099 |
File "test.lem", line 4, character 23 to line 4, character 24 |
| 1100 |
Type error: unbound type variable: 'b |
| 1101 |
================================================================================ |
| 1102 |
class (c 'a) val x : nat end |
| 1103 |
instance forall 'a. d 'd => (c 'a) let x = 1 end |
| 1104 |
|
| 1105 |
-------------------------------------------------------------------------------- |
| 1106 |
File "test.lem", line 4, character 21 to line 4, character 21 |
| 1107 |
Type error: unbound type class: d |
| 1108 |
================================================================================ |
| 1109 |
class (c 'a) val x : nat end |
| 1110 |
instance forall 'a 'b. (c 'a) let x = 1 end |
| 1111 |
|
| 1112 |
-------------------------------------------------------------------------------- |
| 1113 |
File "test.lem", line 4, character 1 to line 4, character 43 |
| 1114 |
Type error: instance type does not use all type variables: {'b} |
| 1115 |
================================================================================ |
| 1116 |
class (c 'a) val x : 'a end |
| 1117 |
instance (c nat) let x = 1 let x = 1 end |
| 1118 |
|
| 1119 |
-------------------------------------------------------------------------------- |
| 1120 |
File "test.lem", line 4, character 32 to line 4, character 32 |
| 1121 |
Type error: duplicate definition in an instance: x |
| 1122 |
================================================================================ |
| 1123 |
class (d 'a) val x : nat end |
| 1124 |
type c = nat |
| 1125 |
instance (c nat) let x = 10 end |
| 1126 |
|
| 1127 |
-------------------------------------------------------------------------------- |
| 1128 |
File "test.lem", line 5, character 11 to line 5, character 11 |
| 1129 |
Type error: type constructor used as type class: c |
| 1130 |
================================================================================ |
| 1131 |
class (c 'a) val x : nat end |
| 1132 |
instance (c nat) let {hol} x = 10 end |
| 1133 |
|
| 1134 |
-------------------------------------------------------------------------------- |
| 1135 |
File "test.lem", line 4, character 18 to line 4, character 33 |
| 1136 |
Type error: instance method must not be target specific |
| 1137 |
================================================================================ |
| 1138 |
class (c 'a) val x : nat end |
| 1139 |
instance forall 'a 'a. (c 'a) let x = 10 end |
| 1140 |
|
| 1141 |
-------------------------------------------------------------------------------- |
| 1142 |
File "test.lem", line 4, character 17 to line 4, character 18 |
| 1143 |
Type error: duplicate type variable: 'a |
| 1144 |
================================================================================ |
| 1145 |
class (c 'a) val x : 'a end |
| 1146 |
instance forall 'a. c 'a => (c 'a list) let x = x end |
| 1147 |
instance forall 'b. c 'b => (c 'b list) let x = x end |
| 1148 |
|
| 1149 |
-------------------------------------------------------------------------------- |
| 1150 |
File "test.lem", line 4, character 34: |
| 1151 |
Syntax error |
| 1152 |
================================================================================ |
| 1153 |
|
| 1154 |
(* ------------------------ Class constraints ------------------------------ *) |
| 1155 |
(* ------------------------------------------------------------------------- *) |
| 1156 |
(* ------------------------------------------------------------------------- *) |
| 1157 |
|
| 1158 |
class (c 'a) val x : 'a end |
| 1159 |
let _ = x::[(4:nat)] |
| 1160 |
|
| 1161 |
-------------------------------------------------------------------------------- |
| 1162 |
File "test.lem", line 9, character 1 to line 9, character 20 |
| 1163 |
Type error: unsatisfied type class constraint: |
| 1164 |
(Test.c nat) |
| 1165 |
================================================================================ |
| 1166 |
(* TODO: error message should include (test.c 'a list) *) |
| 1167 |
class (c 'a) val x : 'a end |
| 1168 |
class (d 'a) val y : 'a val z : list 'a end |
| 1169 |
default_instance forall 'a. (d 'a) let y = x let z = x end |
| 1170 |
|
| 1171 |
-------------------------------------------------------------------------------- |
| 1172 |
File "test.lem", line 6, character 36 to line 6, character 54 |
| 1173 |
Type error: unsatisfied type class constraint: |
| 1174 |
(Test.c 'a) |
| 1175 |
================================================================================ |
| 1176 |
class (c 'a) val x : 'a end |
| 1177 |
class (d 'a) val y : 'a end |
| 1178 |
instance forall 'a 'b. c 'a , d 'b => (c ('a*'b)) let x = (x, y) end |
| 1179 |
val a : nat |
| 1180 |
let a = match x with (a,b) -> (1 : nat) end |
| 1181 |
|
| 1182 |
-------------------------------------------------------------------------------- |
| 1183 |
File "test.lem", line 7, character 1 to line 7, character 43 |
| 1184 |
Type error: unsatisfied type class constraints: |
| 1185 |
(Test.c 'b) |
| 1186 |
and |
| 1187 |
(Test.d 'a) |
| 1188 |
================================================================================ |
| 1189 |
class (c 'a) val x : 'a end |
| 1190 |
class (d 'a) val y : 'a end |
| 1191 |
instance forall 'a 'b. c 'a, d 'b => (c ('a*'b)) let x = (x, y) end |
| 1192 |
val a : forall 'a. 'a -> nat |
| 1193 |
let inline {hol} a y = match x with (a,b) -> 1 end |
| 1194 |
|
| 1195 |
-------------------------------------------------------------------------------- |
| 1196 |
File "test.lem", line 7, character 1 to line 7, character 50 |
| 1197 |
Type error: unsatisfied type class constraints: |
| 1198 |
(Test.c 'b) |
| 1199 |
and |
| 1200 |
(Test.d 'a) |
| 1201 |
================================================================================ |
| 1202 |
|
| 1203 |
(* ------------------------ Type Mismatches -------------------------------- *) |
| 1204 |
(* ------------------------------------------------------------------------- *) |
| 1205 |
(* ------------------------------------------------------------------------- *) |
| 1206 |
|
| 1207 |
let f (1 : bool) = (1 : nat) |
| 1208 |
|
| 1209 |
-------------------------------------------------------------------------------- |
| 1210 |
File "test.lem", line 8, character 7 to line 8, character 16 |
| 1211 |
Type error: type mismatch: type-annotated pattern |
| 1212 |
bool |
| 1213 |
and |
| 1214 |
nat |
| 1215 |
================================================================================ |
| 1216 |
type x = | X of bool |
| 1217 |
let f (X 1) = (1 : nat) |
| 1218 |
|
| 1219 |
-------------------------------------------------------------------------------- |
| 1220 |
File "test.lem", line 4, character 8 to line 4, character 8 |
| 1221 |
Type error: type mismatch: constructor pattern |
| 1222 |
bool |
| 1223 |
and |
| 1224 |
nat |
| 1225 |
================================================================================ |
| 1226 |
type t = <| fld : bool |> |
| 1227 |
let f <| fld = 1 |> = (1 : nat) |
| 1228 |
|
| 1229 |
-------------------------------------------------------------------------------- |
| 1230 |
File "test.lem", line 4, character 10 to line 4, character 16 |
| 1231 |
Type error: type mismatch: field pattern |
| 1232 |
bool |
| 1233 |
and |
| 1234 |
nat |
| 1235 |
================================================================================ |
| 1236 |
let f [1;true] = (1 : nat) |
| 1237 |
|
| 1238 |
-------------------------------------------------------------------------------- |
| 1239 |
File "test.lem", line 3, character 7 to line 3, character 14 |
| 1240 |
Type error: type mismatch: list pattern |
| 1241 |
nat |
| 1242 |
and |
| 1243 |
bool |
| 1244 |
================================================================================ |
| 1245 |
let f (1::[true]) = (1 : nat) |
| 1246 |
|
| 1247 |
-------------------------------------------------------------------------------- |
| 1248 |
File "test.lem", line 3, character 8 to line 3, character 16 |
| 1249 |
Type error: type mismatch: :: pattern |
| 1250 |
nat |
| 1251 |
and |
| 1252 |
bool |
| 1253 |
================================================================================ |
| 1254 |
let x = true |
| 1255 |
let _ = x + (1 : nat) |
| 1256 |
|
| 1257 |
-------------------------------------------------------------------------------- |
| 1258 |
File "test.lem", line 4, character 9 to line 4, character 21 |
| 1259 |
Type error: type mismatch: infix expression |
| 1260 |
nat |
| 1261 |
and |
| 1262 |
bool |
| 1263 |
================================================================================ |
| 1264 |
let f (x : bool) = x + 1 |
| 1265 |
|
| 1266 |
-------------------------------------------------------------------------------- |
| 1267 |
File "test.lem", line 3, character 1 to line 3, character 24 |
| 1268 |
Type error: unsatisfied type class constraint: |
| 1269 |
(Num.NumAdd bool) |
| 1270 |
================================================================================ |
| 1271 |
type t = | X |
| 1272 |
let _ = X (1 : nat) |
| 1273 |
|
| 1274 |
-------------------------------------------------------------------------------- |
| 1275 |
File "test.lem", line 4, character 9 to line 4, character 19 |
| 1276 |
Type error: type mismatch: application expression |
| 1277 |
nat -> _ |
| 1278 |
and |
| 1279 |
Test.t |
| 1280 |
================================================================================ |
| 1281 |
type t = | X of bool |
| 1282 |
let _ = X (1 : nat) |
| 1283 |
|
| 1284 |
-------------------------------------------------------------------------------- |
| 1285 |
File "test.lem", line 4, character 9 to line 4, character 19 |
| 1286 |
Type error: type mismatch: application expression |
| 1287 |
nat |
| 1288 |
and |
| 1289 |
bool |
| 1290 |
================================================================================ |
| 1291 |
type t = | X of bool |
| 1292 |
let _ = X true (1 : nat) |
| 1293 |
|
| 1294 |
-------------------------------------------------------------------------------- |
| 1295 |
File "test.lem", line 4, character 9 to line 4, character 24 |
| 1296 |
Type error: type mismatch: application expression |
| 1297 |
nat -> _ |
| 1298 |
and |
| 1299 |
Test.t |
| 1300 |
================================================================================ |
| 1301 |
let _ = fun (x : bool) -> x + (1 : nat) |
| 1302 |
|
| 1303 |
-------------------------------------------------------------------------------- |
| 1304 |
File "test.lem", line 3, character 27 to line 3, character 39 |
| 1305 |
Type error: type mismatch: infix expression |
| 1306 |
nat |
| 1307 |
and |
| 1308 |
bool |
| 1309 |
================================================================================ |
| 1310 |
type x = | X of bool |
| 1311 |
let _ = fun (X x) -> x + (1 : nat) |
| 1312 |
|
| 1313 |
-------------------------------------------------------------------------------- |
| 1314 |
File "test.lem", line 4, character 22 to line 4, character 34 |
| 1315 |
Type error: type mismatch: infix expression |
| 1316 |
nat |
| 1317 |
and |
| 1318 |
bool |
| 1319 |
================================================================================ |
| 1320 |
type x = <| fld : bool |> |
| 1321 |
let _ = fun <| fld = x |> -> x + (1 : nat) |
| 1322 |
|
| 1323 |
-------------------------------------------------------------------------------- |
| 1324 |
File "test.lem", line 4, character 30 to line 4, character 42 |
| 1325 |
Type error: type mismatch: infix expression |
| 1326 |
nat |
| 1327 |
and |
| 1328 |
bool |
| 1329 |
================================================================================ |
| 1330 |
let _ = function | true -> 1 | (1 : nat) -> (1 : nat) end |
| 1331 |
|
| 1332 |
-------------------------------------------------------------------------------- |
| 1333 |
File "test.lem", line 3, character 9 to line 3, character 57 |
| 1334 |
Type error: type mismatch: function expression |
| 1335 |
bool |
| 1336 |
and |
| 1337 |
nat |
| 1338 |
================================================================================ |
| 1339 |
let _ = function | _ -> 1 | _ -> true end |
| 1340 |
|
| 1341 |
-------------------------------------------------------------------------------- |
| 1342 |
File "test.lem", line 3, character 1 to line 3, character 41 |
| 1343 |
Type error: unsatisfied type class constraint: |
| 1344 |
(Num.Numeral bool) |
| 1345 |
================================================================================ |
| 1346 |
let _ = (1 : nat) (2 : nat) |
| 1347 |
|
| 1348 |
-------------------------------------------------------------------------------- |
| 1349 |
File "test.lem", line 3, character 9 to line 3, character 27 |
| 1350 |
Type error: type mismatch: application expression |
| 1351 |
nat -> _ |
| 1352 |
and |
| 1353 |
nat |
| 1354 |
================================================================================ |
| 1355 |
let _ = (fun (1:nat) -> (1:nat)) true |
| 1356 |
|
| 1357 |
-------------------------------------------------------------------------------- |
| 1358 |
File "test.lem", line 3, character 9 to line 3, character 37 |
| 1359 |
Type error: type mismatch: application expression |
| 1360 |
bool |
| 1361 |
and |
| 1362 |
nat |
| 1363 |
================================================================================ |
| 1364 |
let _ = (function | 1 -> (1 : nat) end) true |
| 1365 |
|
| 1366 |
-------------------------------------------------------------------------------- |
| 1367 |
File "test.lem", line 3, character 9 to line 3, character 44 |
| 1368 |
Type error: type mismatch: application expression |
| 1369 |
bool |
| 1370 |
and |
| 1371 |
nat |
| 1372 |
================================================================================ |
| 1373 |
let _ = (fun x -> x) (1 : nat) (2 : nat) |
| 1374 |
|
| 1375 |
-------------------------------------------------------------------------------- |
| 1376 |
File "test.lem", line 3, character 9 to line 3, character 40 |
| 1377 |
Type error: type mismatch: application expression |
| 1378 |
nat -> _ |
| 1379 |
and |
| 1380 |
nat |
| 1381 |
================================================================================ |
| 1382 |
let _ = true + (1 : nat) |
| 1383 |
|
| 1384 |
|
| 1385 |
-------------------------------------------------------------------------------- |
| 1386 |
File "test.lem", line 3, character 9 to line 3, character 24 |
| 1387 |
Type error: type mismatch: infix expression |
| 1388 |
nat |
| 1389 |
and |
| 1390 |
bool |
| 1391 |
================================================================================ |
| 1392 |
type t5 [name = "nv*"] = NV of bool | NVC of nat |
| 1393 |
let test17 = fun (x : t5) -> x |
| 1394 |
|
| 1395 |
-------------------------------------------------------------------------------- |
| 1396 |
File "test.lem", line 4, character 19 to line 4, character 19 |
| 1397 |
Type error: variables with type Test.t5 are restricted to names matching the regular expression nv*: x |
| 1398 |
================================================================================ |
| 1399 |
type t5 [nme = "nv*"] = NV of bool | NVC of nat |
| 1400 |
|
| 1401 |
-------------------------------------------------------------------------------- |
| 1402 |
File "test.lem", line 3, character 10 to line 3, character 12 |
| 1403 |
Type error: Type name restrictions must begin with 'name': nme |
| 1404 |
================================================================================ |
| 1405 |
type t5 = NV of bool | NVC of nat |
| 1406 |
type t6 [name = "nv*"] = t5 |
| 1407 |
-------------------------------------------------------------------------------- |
| 1408 |
File "test.lem", line 4, character 6 to line 4, character 7 |
| 1409 |
Type error: Type abbreviations may not restrict identifier names: t6 |
| 1410 |
================================================================================ |
| 1411 |
type ctype [name = ".+_ty$\\|ty[0-9 ']*$"] = | Void |
| 1412 |
let f (foo_ty : ctype) (ty2 : ctype) = true |
| 1413 |
let g (x : ctype) = false |
| 1414 |
-------------------------------------------------------------------------------- |
| 1415 |
File "test.lem", line 5, character 8 to line 5, character 8 |
| 1416 |
Type error: variables with type Test.ctype are restricted to names matching the regular expression .+_ty$\|ty[0-9 ']*$: x |
| 1417 |
================================================================================ |