Browse thread
Typing problems when using LablGTK
[
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: | Maxence <max@s...> |
| Subject: | Re: Typing problems when using LablGTK |
Just add explicit type for the table parameter of your mini function :
let mini (table : GPack.table) : unit =
GButton.button ~label:"mini"
~packing:(table#attach ~left:3 ~top:3 ~expand:`BOTH) ();
()
> What have I misunderstood?
I think you didn't misunderstood anything. I was surprised too, the
first time :-)
take a look at the example below :
class context () =
object
method get_string ?(default="great!") message =
(* this function could display a message and an
entry widget to make the user type in some text.
The entry would contain the default text when
the window appears. for the example, we
just return the default text.*)
print_string message;
default
end
let f ctx = ctx#get_string "how do you feel ?"
let ctx = new context ()
let feeling = f (ctx :> <get_string : string -> string>)
ocaml complains about the coercion of ctx :
This expression cannot be coerced to type < get_string : string ->
string >;
it has type context = < get_string : ?default:string -> string -> string
>
but is here used with type < get_string : string -> string >
The question is : why is this coercion not allowed ?
Maxence Guesdon