<araujo>
i don't get how two functions receive the two declarations
<vodka-goo>
you may understand better if I write it another way, without hiding the reference c'est
<vodka-goo>
let c = ref 0
<vodka-goo>
let f1 () = c := 0
<vodka-goo>
let new_s () = c := !c+1 ; s^(string of int !c)
<vodka-goo>
s/f1/reset_s/
<vodka-goo>
it's just the same
<vodka-goo>
I'm afraid it doesn't help much...
<vodka-goo>
are you just surprised by the fact that functions are usual values that can be assignated ?
<araujo>
No, i get that part.
<araujo>
what i didn't know is that i coudl do this:
<araujo>
# let (var1, var2) =
<araujo>
let c = 4
<araujo>
and x = 8 in (c,x);;
<araujo>
as a way to declare several variables at once
<vodka-goo>
patterns are not only for matching, but also in let bindings, yes
<araujo>
that's cool
<vodka-goo>
yes
<vodka-goo>
but the "good" way of hiding values is to use modules/interfaces
<araujo>
oh, well, i still don't get that far yet :-)
<vodka-goo>
forget what I said, that kind of trick is useful
<araujo>
yeah, it looks like that... it is sort of a way to share enviroment between several closures...
<araujo>
So, what i am doing is something like:
<araujo>
# let (var1, var2) = (8,9);;
<smimou>
yes
<Snark>
re
p has joined #ocaml
_JusSx__ has quit [Read error: 104 (Connection reset by peer)]
<araujo>
mexico p ?
Submarine has quit ["Leaving"]
<TeXitoi>
araujo: mx is mexico, yes
<TeXitoi>
but it can be a hacked machine... ;-)
<araujo>
yeah, i know, hah
* araujo
just happy of not being the only south-american in here
* TeXitoi
have leaved 1 year in mexico
<araujo>
you lived there?
<TeXitoi>
yes
<araujo>
what city?
<TeXitoi>
Toluca
_JusSx___ has joined #ocaml
* araujo
should visit mx someday
<TeXitoi>
but I've traveled a little bit ;-)
* araujo
knows a few people from there
<araujo>
i see :-)
Zaius has joined #ocaml
<Zaius>
hi everyone;; i did the following and got no satisfying result:
<Zaius>
type t = A | B
<Zaius>
let f = function A -> "A" | B -> "B"
<Zaius>
type s = A | B
<Zaius>
let _ = print_string ( f A )
<Zaius>
...has type s but is here used with type t
<Zaius>
why is it that i can't unify types t and s?
<araujo>
mmm.. it's not a problem that you use same values for different types?
<ulfdoz_>
Zaius: Because of identical constructor.
<Zaius>
can i force coercion of A to any type of s or t?
<Zaius>
now my type t is part of lablgl and is quite reasonable, but i don't want to refer to it
<mflux>
zaius, well, the answer would be 'because'. maybe you want to use variants?
<mflux>
just because they are structurally equivalent doesn't mean they would be otherwise..
<mflux>
and even if the symbols have the same names, it doesn't mean they are the same ;)
<ulfdoz_>
In the interpreter, the definition of s hides t.
<mflux>
it hides it in the compiler too?
<ulfdoz_>
mflux: Don't know, haven't testet.
<Zaius>
but if they are structurally equivalent, then i dont find any usafety in coercing them. and if i force the coercion myself then i suppose i know that they are equivalent semantically too
<mflux>
well..
<mflux>
you could use Obj.magic, but that's dark magic.
<mflux>
why don't you just do type s = t?
<ulfdoz_>
Zaius: The reason for the typing error could be avoided by defining f after defining s. But I don't know if this is, what you want.
<mflux>
zaius, if it said type s = B | A, do you still think it should 'just work'?
<mflux>
zaius, or was your suggestion that explicit casting would be required?
TeXitoi has quit [Read error: 104 (Connection reset by peer)]
TeXitoi has joined #ocaml
<mflux>
(which you can do now with a conversion function - writing it would be tricky if the definitions weren't in their own modules though)
<Zaius>
conversion function?
<mflux>
from 'A' to another 'A'
<mflux>
I think structural equality in ocaml is considered only with classes
<Zaius>
ah, that would require referring to the original A as well
<mflux>
you could convert A to a number before and then again the number to A afterwards ;)
<mflux>
or you could define the types in their own modules
<mflux>
maybe I'm not seeing the real use of what you're attempting to do
<Zaius>
what i try to do is: avoid using Glut.some_t in my code.
<mflux>
type t = Glut.some_t ?
<Zaius>
how could i do the conversion with Obj.magic? is sounds ... interesting :)
<mflux>
hmh
<mflux>
well, it's your code..
<mflux>
(Obj.magic value :> type)
<mflux>
that makes no checks whatsoever
<Zaius>
hmm... it works indeed. very dangerous indeed
<Zaius>
type t = A | B
<Zaius>
let f = function A -> "A" | B -> "B"
<Zaius>
type s = B | A
<Zaius>
let _ = print_string ( f (Obj.magic A :> t) )
<Zaius>
it now prints a "B"
<Zaius>
thank you for your help
<Snark>
a "B"?
<ulfdoz_>
What about type glut_wrapper = Wrap of Glut.some_t?
<ulfdoz_>
You should then be able to get the value of correct type by constructor patterns.
pango has joined #ocaml
<Snark>
good night
Snark has left #ocaml []
_JusSx___ has quit ["leaving"]
__DL__ has left #ocaml []
Submarine has joined #ocaml
Bonedigger has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
vodka-goo has quit []
Bonedigger has quit [Remote closed the connection]
cjohnson has quit [Remote closed the connection]
vezenchio has quit [""Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule—and bot]
<ulfdoz_>
cya
Gueben has quit ["plouf"]
Submarine has quit ["Leaving"]
angagon has quit [Read error: 110 (Connection timed out)]