Browse thread
Narrowing the type class parameters with module specification
- Philippe Veber
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Philippe Veber <philippe.veber@g...> |
| Subject: | Narrowing the type class parameters with module specification |
Hi list,
Sorry for my previous message, which I sent by mistake.
I would like to understand why the following is rejected :
# module M :
sig
class x : int -> object method m : int end
end
=
struct
class x _ = object
method m = 42
end
end;;
Error: Signature mismatch:
Modules do not match:
sig class x : 'a -> object method m : int end end
is not included in
sig class x : int -> object method m : int end end
Class declarations do not match:
class x : 'a -> object method m : int end
does not match
class x : int -> object method m : int end
One parameter has type 'a but is expected to have type int
Of course, as soon as one doesn't use classes, everything works just fine :
# module M :
sig
val x : int -> <m : int>
end
=
struct
let x _ = object method m = 42 end
end;;
module M : sig val x : int -> < m : int > end
ph.