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.