Demitar has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
kinners has quit [Read error: 110 (Connection timed out)]
Revision17 has quit [Remote closed the connection]
mrsolo has quit [Read error: 104 (Connection reset by peer)]
pnou_ has quit ["zou"]
Revision17 has joined #ocaml
ptolomy has joined #ocaml
sethk has joined #ocaml
Demitar has quit [Connection timed out]
Demitar has joined #ocaml
ellism has joined #ocaml
<ellism>
I have what I think is a very basic question. If a function has type (int -> int) -> int is that the same as just int -> int -> int? I don't understand what the parens mean here.
<Nutssh>
ellism, they're different. a -> a -> a is a -> (a -> a)
<Nutssh>
So its a -> (a -> a) VS (a -> a) -> a
<sethk>
ok, but what is the semantic significance of that?
<ellism>
Nutssh: How do I read (int -> int) -> int?
<Nutssh>
It takes a function from ints to ints and returns an integer... Eg... let f fn = fn 0
<sethk>
the other one takes an integer and returns a function int -> int?
<Nutssh>
Versus a -> (a -> a) which is that, and one such function might be let f ii = (fun x -> ii*x)
<ellism>
Nutssh: So let f fn = fn 0 is of type (int -> 'a) -> 'a. How would I force (int -> int) -> int ?
<Nutssh>
Force the type with an explicit declaration. let f fn : int = fn 0 OR let f (fn:(int -> int)) = fn 0
<ellism>
Ahh, allright. I could also say something like let f fn: = 0 + fn 0;; correct?
<Nutssh>
That works too.
<ellism>
so (int -> bool) -> (bool -> int) means the function takes one argument, which is a function from ints to bools and returns a function from bools to ints?
<Nutssh>
Yes.
pango_ has joined #ocaml
<ellism>
I'm confunsed on how I would return a function of the type (bool -> int). I'd have to build one, but when I try I the type usually looks like (bool -> int) -> int or something. I'm just trying to make some arbitrary function that has the type (int -> bool) -> (bool -> int) ...
ax has quit [Remote closed the connection]
<ellism>
or is that the same as (int -> bool) -> bool -> int?
<sethk>
fun f a b = f
pango has quit [Read error: 110 (Connection timed out)]
<ellism>
What does the underscore in a type statement mean if there is a type like '_a?
<sethk>
anything
<sethk>
like .
<ellism>
How does that differ from 'a ?
<sethk>
'a is a type variable
<sethk>
means type a _ 'a is what you would see
<ellism>
I don't quite understand that last line?
<mfurr>
ellism: _'a is monomorphic(but not completely inferred), whereas 'a is polymorphic
<Smerdyakov>
Those type variables with underscores don't really exist in the OCaml language.
<Smerdyakov>
They are just used in internal algorithms, and may be printed to help you understand why those algorithms fail.
<ellism>
So I have this function uncurry let uncurry f (x ,y) == f x y;; which is of type ('a -> 'b -> 'c) -> 'a * 'b -> 'c and then I have let compose f g = fun x -> f(g(x) which is of type ('a -> 'b) -> )'
<ellism>
er... type ('a -> 'b) -> (' c -> a ) -> 'c -> 'b
<ellism>
But if I do uncurry compose all the types are of the form '_a, '_b, etc. I don't really understand what this means.