Haudegen has quit [Remote host closed the connection]
DomTorr_ has joined #ocaml
DomTorr has quit [Ping timeout: 244 seconds]
silver has quit [Read error: Connection reset by peer]
unyu has quit [Quit: Fix config.]
unyu has joined #ocaml
lostman has joined #ocaml
mfp has quit [Ping timeout: 268 seconds]
Redfoxmoon has quit [Ping timeout: 258 seconds]
Redfoxmoon has joined #ocaml
gravicappa has joined #ocaml
oni-on-ion has joined #ocaml
jao has quit [Ping timeout: 255 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
<oni-on-ion>
does anyone know what 'with' operator/keyword does ?
<oni-on-ion>
cant find any info about it
<oni-on-ion>
oh; maybe it is record-update syntax ? that would be beautiful
<Fardale>
it can be
ShalokShalom has joined #ocaml
<Fardale>
{r with x = 2} it is a new reccord same as r but with the field x equal to 2
<oni-on-ion>
cool. thats perfect =) thanks !
oni_on_ion has joined #ocaml
oni-on-ion has quit [Ping timeout: 258 seconds]
oni_on_ion has left #ocaml [#ocaml]
oni-on-ion has joined #ocaml
ggole has joined #ocaml
Birdface has joined #ocaml
Intensitea has quit [Remote host closed the connection]
ShalokShalom has quit [Remote host closed the connection]
Redfoxmoon has quit [Changing host]
Redfoxmoon has joined #ocaml
barockobamo has joined #ocaml
zolk3ri has joined #ocaml
sz0 has joined #ocaml
Birdface has quit [Remote host closed the connection]
Birdface has joined #ocaml
kakadu has joined #ocaml
silver_ has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
kakadu has joined #ocaml
kakadu has quit [Client Quit]
kakadu has joined #ocaml
dhil has joined #ocaml
orbifx has joined #ocaml
mfp has joined #ocaml
Birdface has quit [Ping timeout: 248 seconds]
Birdface has joined #ocaml
jbrown has quit [Ping timeout: 252 seconds]
Haudegen has joined #ocaml
barockobamo has quit [Ping timeout: 252 seconds]
Birdface has quit [Ping timeout: 255 seconds]
zolk3ri has quit [Ping timeout: 256 seconds]
sagax has quit [Ping timeout: 246 seconds]
sagax has joined #ocaml
ShalokShalom has joined #ocaml
zolk3ri has joined #ocaml
ehirdoy has quit [Ping timeout: 264 seconds]
emias has quit [Quit: WeeChat 2.3]
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
gareppa has joined #ocaml
dhil has quit [Ping timeout: 258 seconds]
Redfoxmoon has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
Redfoxmoon has joined #ocaml
Haudegen has quit [Remote host closed the connection]
gareppa has quit [Remote host closed the connection]
jaar has joined #ocaml
orbifx has quit [Quit: WeeChat 2.4]
emias has joined #ocaml
dhil has joined #ocaml
Bahman has joined #ocaml
freyr69 has joined #ocaml
barockobamo has joined #ocaml
AtumT has joined #ocaml
Haudegen has joined #ocaml
dhil has quit [Ping timeout: 252 seconds]
ohama has quit [Disconnected by services]
ohama has joined #ocaml
ygrek has joined #ocaml
ShalokShalom has quit [Remote host closed the connection]
ShalokShalom has joined #ocaml
ShalokShalom has quit [Remote host closed the connection]
spew has joined #ocaml
oni_on_ion has joined #ocaml
oni-on-ion has quit [Ping timeout: 246 seconds]
pierpal has quit [Ping timeout: 258 seconds]
<cemerick>
I've defined what I'd hope is a union of two other polymorphic variant types, `type idxt = [ t | mark ]`. However, existing code that was only operating over values of type `t` are now complaining e.g. "This expression has type t but an expression was expected of type idxt The first variant type does not allow tag(s) `Char, `Line".
<cemerick>
What might I be doing wrong here?
<kakadu>
you can try to fix types in your code by replacing type `t` with `[> t]` a.k.a. open vresion of t
<kakadu>
i.e. t or something else
jao has joined #ocaml
jao is now known as Guest17069
<octachron>
or maybe [< idxt]
<cemerick>
kakadu: yeah, I tried both `<` and `>`, but got the error "A type variable is unbound in this type declaration. In type `[> idxt ]` as 'a the variable 'a is unbound"
Bahman has quit [Ping timeout: 258 seconds]
<kakadu>
yes `or something else` means that it adds a row variable for representing `something else`
* cemerick
goes to re-re-reread the poly variant section in the manual
<ggole>
If you need to coerce a value of type t to idxt, you can use (expr :> idxt)
oni_on_ion has quit [Read error: Connection timed out]
oni_on_ion has joined #ocaml
<cemerick>
ggole: YES thank you
barockobamo has quit [Ping timeout: 252 seconds]
<cemerick>
yup, I remember not quite grokking coercions the last time I read through that bit of the manual.
<cemerick>
What might be an example where explicit coercion is helpful, i.e. where widening a value's type is undesirable?
<ggole>
You'll need coercions whenever an expression has a non-polymorphic type, but you want to treat it as a subtype
<ggole>
eg, if you annotate a function as returning a t it will not have a polymorphic type
<octachron>
cemerick, the open polymorphic variants are generally more useful in type annotations. You may have a non-optimally annotated function somewhere
FreeBirdLjj has joined #ocaml
dhil has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 258 seconds]
<cemerick>
octachron: that's an easy thing to assume
barockobamo has joined #ocaml
<octachron>
? it is hard to be more specific without seeing the code
<cemerick>
octachron: what I meant was, I'm sure you're right about there being suboptimal stuff in my codebase :-)
<cemerick>
is there an analogous operation for widening the type of derived modules, then? e.g. if I have `t Set.t` and `idxt Set.t`, I would like to treat the former as the latter, but the compiler disagrees
<octachron>
one point that might help you, annotating a function argument with the type `t` or `idxt` means that you want exactly this type and you often lose some of the advantages of polymorphic variants by doing so.
<octachron>
You can use explicit coercion too (x :> idxt Set.t)
FreeBirdLjj has joined #ocaml
<cemerick>
octachron: yeah, I tried that, but without joy. Let me put together a simple example
powerbit has quit [Read error: Connection reset by peer]
<cemerick>
octachron: maybe it's not expressible, but the relationship exists, and there are some corners where the compiler recognizes it, e.g. `B.Set.add_seq sb @@ (A.Set.to_seq sa :> B.t Sequence.t)` works just fine
<cemerick>
Drup: by "dependent-ish", you mean e.g. `+'a` types?
<Drup>
No, that's just variance, that's completely unreleated
dhil has joined #ocaml
ohama has quit [Read error: Connection reset by peer]
ohama has joined #ocaml
freyr69 has quit [Remote host closed the connection]
two_wheels has joined #ocaml
Haudegen has quit [Remote host closed the connection]
Redfoxmoon has quit [Changing host]
Redfoxmoon has joined #ocaml
ziyourenxiang has quit [Ping timeout: 246 seconds]
jaar has quit [Quit: Leaving]
dhil has quit [Ping timeout: 245 seconds]
ShalokShalom has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
ShalokShalom has quit [Remote host closed the connection]
silver_ is now known as silver
ravenousmoose has joined #ocaml
JimmyRcom has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
tianon has quit [Ping timeout: 246 seconds]
Serpent7776 has joined #ocaml
Haudegen has joined #ocaml
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
jbrown has joined #ocaml
jnavila has joined #ocaml
Niamkik has joined #ocaml
Redfoxmoon has quit [Ping timeout: 250 seconds]
Redfoxmoon has joined #ocaml
kakadu has quit [Remote host closed the connection]
tianon has joined #ocaml
tane has joined #ocaml
ale64bit has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
oni-on-ion has joined #ocaml
Jesin has quit [Quit: Leaving]
AtumT_ has joined #ocaml
AtumT has quit [Ping timeout: 246 seconds]
Jesin has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
pierpal has quit [Ping timeout: 245 seconds]
kakadu has joined #ocaml
AtumT has joined #ocaml
pierpal has joined #ocaml
AtumT_ has quit [Ping timeout: 246 seconds]
Redfoxmoon has quit [Changing host]
Redfoxmoon has joined #ocaml
jnavila has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
okuu has joined #ocaml
madroach has joined #ocaml
gravicappa has quit [Ping timeout: 258 seconds]
ale64bit has quit [Ping timeout: 250 seconds]
okuu has quit [Remote host closed the connection]
<cemerick>
so I _think_ what I'm trying to do is reasonable, but I just don't grok yet how variance works here
<cemerick>
I fiddled with the declarations in DumbSet a bunch, but couldn't get the compiler to budge. Meanwhile, List.t has no declared variance, so I don't know why the concat example is happy.
<def`>
If a type is not opaque, the compiler will infer the variance based on its definition.
<def`>
So it infers +'a for 'a list
<def`>
Because 'a DumbSet(_).t is opaque, 'a is considered invariant.
<cemerick>
def`: even if I specify it as `type +'a t`?
<cemerick>
I mean, obviously so, given that things aren't working as I'd like :-P
<def`>
If you specify +'a t it will be covariant :)
<def`>
(Though during coercion, the compiler will check that the definition is indeed covariant, you can't make any thing covariant by just adding annotation :P)
zolk3ri has quit [Remote host closed the connection]
<def`>
A.t is a sub-type of B.t, and 'a list is covariant in 'a, so A.t list is a sub-type of B.t list
<def`>
If 'a list was contravariant in 'a, B.t list would be a sub-type of A.t list.
<cemerick>
Correct, and I believe I understand that
<def`>
If 'a list was invariant, B.t list would not be related to A.t list :)
<def`>
There are two other problems with your definitions:
<def`>
A.Set.t = Dumbset(A.T).t and B.Set.t = Dumbset(B.T).t are two, unrelated, opaque types
<def`>
So you cannot coerce one into the other.
<def`>
Second, in the DumbSet interface you see that t has an 'a parameter, but it is never mentioned elsewhere, neither in the implementation nor in the signatures.
<cemerick>
def`: unrelated, because DumbSet is a functor?
ale64bit has joined #ocaml
ShalokShalom has joined #ocaml
ggole has quit [Quit: Leaving]
sonologico has quit [Remote host closed the connection]
<octachron>
cemerick, unrelated because they are abstract types (outside of the functor).
sonologico has joined #ocaml
two_wheels has quit [Remote host closed the connection]
sonologico has quit [Remote host closed the connection]
sonologico has joined #ocaml
sonologico has quit [Remote host closed the connection]
ale64bit has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
kakadu has quit [Remote host closed the connection]
two_wheels has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kakadu has joined #ocaml
tane has quit [Quit: Leaving]
ShalokShalom has quit [Remote host closed the connection]
jnavila has quit [Remote host closed the connection]
kakadu has quit [Remote host closed the connection]
two_wheels has quit [Remote host closed the connection]
TheLemonMan has joined #ocaml
TheLemonMan has quit [Client Quit]
ohama has quit [Read error: Connection reset by peer]
silver_ has joined #ocaml
silver has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Quit: leaving]
ohama has joined #ocaml
pierpal has quit [Ping timeout: 258 seconds]
<oni-on-ion>
ocaml is wonderful =)
spew has quit [Quit: Connection closed for inactivity]
Redfoxmoon has quit [Read error: Connection reset by peer]