smimou changed the topic of #ocaml to: OCaml 3.08.3 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
lodewijk has joined #ocaml
Skal has quit ["Client exiting"]
smimou has quit ["?"]
dross has left #ocaml []
batdog|gone is now known as batdog
Smerdyakov has joined #ocaml
dan2_ has joined #ocaml
mrsolo has quit [Read error: 104 (Connection reset by peer)]
ulfdoz_ has joined #ocaml
vezenchio has joined #ocaml
batdog is now known as batdog|gone
ulfdoz has quit [Read error: 110 (Connection timed out)]
Herrchen has joined #ocaml
Herrchen_ has quit [Read error: 110 (Connection timed out)]
pnou has quit [Read error: 110 (Connection timed out)]
Boojum is now known as Snark
Smerdyakov has quit []
Smerdyakov has joined #ocaml
Smerdyakov has quit []
Nutssh has joined #ocaml
_shawn has quit [Client Quit]
_shawn has joined #ocaml
whee has quit ["Leaving"]
Submarine has joined #ocaml
<Snark> re
<Snark> is it possible to define a class ['a] foo then instantiate a [int -> int] foo?
<Nutssh> Yup.
<Nutssh> 'a means any type. :)
<Snark> let instance = new [int -> int] foo doesn't work :-)
<Snark> it seems "->" is bad :-)
<Snark> let instance = new foo;; gives: val instance : '_a foo = <obj>
<Snark> the fact that it's a '_a and not a 'a is annoying
<Snark> then when I apply a int -> int -> unit to an instance method that expects a 'a -> unit; I get: This expression has type int -> int -> unit but is here used with type
<Snark> int -> unit
<Nutssh> Parenthesis?
<Nutssh> You're probably being hit by the value restriction. Try 'let instance : <the type> = new foo;; '
<Snark> the value restriction?
<Snark> ah, yes, the '_a
<Nutssh> Why you can't do 'let x = [];'
<Snark> let instance: [int -> int] foo = new foo;; gives, as I said, a syntax error on the '->'
<Nutssh> Parenthesis?
<Nutssh> (int -> int)
<Snark> not better
<Snark> how can I know what restriction is on '_a ?
<Snark> functional types are restricted, as far as I know
<Snark> so perhaps I'm hitting one of those
<Snark> the error message: This expression has type int -> int -> unit but is here used with type int -> unit is intriguing
<Nutssh> I think '_a just means that value restriction applies. What if you do 'type t = int -> int' and do let x : t foo = new foo;;
* Snark tries
<Snark> hmmmm...
<Snark> This expression has type int -> int -> unit but is here used with type (int -> int) -> unit
<Nutssh> There's a type error somewhere else, Perhaps in the user of the class.
* Snark tries to make something small
<Nutssh> Try putting in explicit type declarations.
<Snark> it gives: File "/tmp/test.ml", line 13, characters 21-29:
<Snark> This expression has type int -> int -> unit but is here used with type
<Snark> (int -> int) -> unit
<Nutssh> What is the type of callback?
<Snark> int -> int -> unit
<Snark> and I want it that way
<Nutssh> What is the type of the argument to bar?
<Nutssh> What is the type of the argument to bar, as per its declaration.
<Snark> $ ocamlopt -i test.ml
<Snark> class ['a] foo : object method bar : ('a -> unit) -> unit end
<Snark> val callback : int -> int -> unit
<Snark> val instance : (int -> int) foo
<Snark> (I removed the let _ = instance#bar callback;; to have that)
<Nutssh> I didn't say that. :)
<Nutssh> If 'a = int -> int, then the argument to bar has (int -> int) -> unit.
<Snark> yes
<Nutssh> (int -> int) -> unit != int -> int -> unit == int -> (int -> unit)
<Snark> oh... it goes the other way around!?
<Nutssh> Think of what a curried function means. :)
<Snark> then I'll do: let instance: (int -> int -> unit) foo = new foo;;
<Snark> and I'll be set
<Snark> ah, no
<Snark> I can't :-/
<Snark> I have bar: ('a -> unit) -> unit
<Snark> and baz: 'a -> unit
<Snark> in the real class I would like to write :-/
<Snark> hmmmm...
<Snark> I have to go
<Snark> Nutssh: thanks for your help!
<Snark> syl
<Nutssh> no problem.
Nutssh has quit ["Client exiting"]
<ulfdoz_> re
Submarine has quit ["Leaving"]
Skal has joined #ocaml
smimou has joined #ocaml
Submarine has joined #ocaml
Submarine has quit ["Leaving"]
_shawn has quit [Client Quit]
pango_ has joined #ocaml
pango has quit [Read error: 110 (Connection timed out)]
pattern_ has quit ["..."]
whee has joined #ocaml
ArthurChapel has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
gim has joined #ocaml
ArthurChapel has left #ocaml []
Smerdyakov has joined #ocaml
{|mono|} has joined #ocaml
vezenchio has quit ["\o/ in mochintin namocniuh \o/"]
Submarine has joined #ocaml
pattern_ has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
lodewijk has quit ["[BX] Back wit anutha one of doz BitchX-rockin' beats!"]
Smerdyakov has quit ["library"]
<ulfdoz_> bye
angagon has joined #ocaml
angagon has left #ocaml []
Submarine has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
Snark has left #ocaml []
Submarine has joined #ocaml
Submarine has quit ["Leaving"]
Smerdyakov has quit []
Skal has quit ["Client exiting"]