copy` has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #ocaml
whisperedcigar has joined #ocaml
zv has quit [Ping timeout: 256 seconds]
sh0t has joined #ocaml
zv has joined #ocaml
brunoro has joined #ocaml
brunoro has quit [Ping timeout: 260 seconds]
patronus_ has quit [Ping timeout: 244 seconds]
Simn has joined #ocaml
jg_ has quit [Ping timeout: 244 seconds]
argent_smith has joined #ocaml
iyy has quit [Quit: leaving]
iyy has joined #ocaml
ggole has joined #ocaml
sh0t has quit [Remote host closed the connection]
fraggle_ has quit [Ping timeout: 260 seconds]
rand__ has joined #ocaml
brunoro has joined #ocaml
fraggle_ has joined #ocaml
AlexDenisov has joined #ocaml
brunoro has quit [Ping timeout: 250 seconds]
djellemah has quit [Quit: Leaving]
teiresias has quit [Quit: quitting]
jg_ has joined #ocaml
<argent_smith>
btw is there any OCaml extraverts? I mean, some chat/forum where the people share algos/ideas in OCaml rather than pinging the collective mind for bugs solving? ;)
<Onemorenickname>
argtest is expected to be of type [`G of 'a], but I can't see why
<Onemorenickname>
i got that, it's because filter has type 'a -> 'a
<Onemorenickname>
so it unifies the input and output types
<Onemorenickname>
even though i expected a refinement through the filter
<Onemorenickname>
how can i "enforce" a type then ? like a cast
<jnavila>
Onemorenickname: why do you enforce the type of filter_g?
ethnopes has joined #ocaml
<Onemorenickname>
jnavila, i need a [`G of 'a] list for the rest of my code
<jnavila>
Onemorenickname: I understand, but the match in filter_g will "make the cast" for you
<ggole>
The return type of List.filter is the same type as the argument, so you aren't going to be able to refine that way
<Onemorenickname>
jnavila, no, it does not
<Onemorenickname>
ggole : how can i cast the result then ?
<ggole>
There's also another issue which you might not be aware of: because of the type of filter, ocaml will *unify* the types [> `G of 'a] and [`G of 'a], resulting in [`G of 'a]
<ggole>
In short, you need to write the loop yourself
<ggole>
(Or apply a refinement function after the fact.)
<Onemorenickname>
ggole, yep, that's what i understood
<Onemorenickname>
(<Onemorenickname> i got that, it's because filter has type 'a -> 'a
<Onemorenickname>
<Onemorenickname> so it unifies the input and output types)
<Onemorenickname>
but, there are no way to cast in ocaml ? akin to the admit in coq ?
<ggole>
There are subtyping coercions
<ggole>
Or you could use something unsafe, but I wouldn't do that.
<Onemorenickname>
what are the "unsafe" alternative ?
<ggole>
Obj.magic, basicaly
<ggole>
Don't use it
<Onemorenickname>
why so ? it looks like that's the right function for what i need
brunoro has joined #ocaml
<flux>
basically you never want to end up in a situation where your code crashes to segmentation fault and then find that there is an instance of Obj.magic in it.
<ggole>
There are no guarantees about its behaviour
<ggole>
Another is to fuse the refinement and filtering
<ggole>
Basically, reimplmenting List.filter
<Onemorenickname>
ggole : but isn't it silly to either reimplement List.filter, or go again through the list to typecheck something we know to be true statically ?
<Onemorenickname>
(i've done so with map, because I did not know about obj.magic, but it's bad code)
<ggole>
1) not if you need a more precise type than List.filter can provide 2) not if you don't want to reimplement List.filter
<ggole>
Unfortunately if you want both you are left unsatisfied.
<Onemorenickname>
i see
<Onemorenickname>
because i don't want to reimplement list.filter for every refinements types i need
<ggole>
Hmm. You could write filter_map, which might be more usable.
brunoro has quit [Ping timeout: 250 seconds]
<ggole>
This is a function of type ('a -> 'b option) -> 'a list -> 'b list
<ggole>
The differing type variables provide the ability to do some refinement, which is not possible with List.filter
<ggole>
It's not in the stdlib, but isn't hard to define.
<Onemorenickname>
ggole, that's a nice alternative
<Onemorenickname>
i was using "map" to do the refinement
<Onemorenickname>
but i did not think about merging it with filter through an option tyoe
<ggole>
It's a bit annoying to have to do what is essentially manual fusion to work around limitations in the language
<ggole>
But, that's programming for you.
<Onemorenickname>
Ha ha :D
<Onemorenickname>
ofc it's annoying, but once you know how to do that in a modular and readable way, that's good enough
<Onemorenickname>
thanks for the code sample !
<ggole>
np
<Onemorenickname>
sometimes i'm like "i'm going to write code in f* or idris and seriously learn them", but so far, i'm sticking with ocaml
<Onemorenickname>
hm, i need to write something like the inverse type of what i had just done
<Onemorenickname>
but i don't know how to express it
<Onemorenickname>
it's basically [anything|`G of 'a] list -> [same_anything] list
<ggole>
Sounds like you could use a subtyping coercion for that
<ggole>
If i understand right
<Onemorenickname>
let f be that function
TarVanimelde has quit [Quit: Leaving]
<Onemorenickname>
if i apply to f the argument arg:[`A|`G] list, I want to get something of type [`A] list, and if i apply to f the argument arg:[`B|`C|`G] list, I want to get something of type [`A|`B] list
<ggole>
Hmm, I think that would be trouble
<ggole>
There's a row variable in polymorphic variants, which it seems you want to use, but you can't name it in OCaml :(
<Onemorenickname>
oh.
<Onemorenickname>
hm, with an other type ?
<ggole>
Ideally you would be able to say something like ['r | `G] list -> ['r] list
<Onemorenickname>
like, type 'a 'b withg = ['a | `G of 'b];; and f: ('a 'b withg) list -> 'a ?
<Onemorenickname>
but i get a syntax error, and i don't know why
<ggole>
Yeah, you can't put type variables there
<ggole>
I'm not quite sure what the reasons for the limitation are, but it's quite annoying.
<Onemorenickname>
hm
<Onemorenickname>
well, what i wanted to do won't work if i can't do that
<Onemorenickname>
i will have to make x versions of the function
<Onemorenickname>
omg
<Onemorenickname>
# type ('a,'b) withpcon = ['a | `Pcon of ('b * 'b)];;
<Onemorenickname>
Error: The type 'a is not a polymorphic variant type
<Onemorenickname>
let rec pcon_to_lst (arg: ['a | `Pcon of ('b * 'b)] list): ('a list) = match arg with
<Onemorenickname>
-> "'a is not a polymorphic variant type" :'(
<ggole>
Yep.
<Onemorenickname>
it looks like i won't be able to do that
<Onemorenickname>
and there are no intersection type in ocaml
<Onemorenickname>
so i will have to rewrite the function
<Onemorenickname>
...
<ggole>
It really seems like you want row polymorphic sum types, and polymorphic variants just aren't that.
<Onemorenickname>
(i don't know what are row polymorphic sum types)
<ggole>
What you're going for here, basically :)
<Onemorenickname>
Polymorphic variants with intersection ?
zpe has joined #ocaml
<ggole>
If you have a sum type A | B | 'c, or a record type { a : int; b : float; 'c }, where 'c is a variable that stands for the rest of the things in the record/sum, the variable is usually called a row variable
<Onemorenickname>
i see
<Onemorenickname>
what i want is indeed polymorphic sum types
silver has joined #ocaml
<Onemorenickname>
but is not that the same as polymorphic variant ? as sum are the same as variant ?
<ggole>
Yeah
<ggole>
But OCaml has this annoying limitation in that you can't name the row variable
<Onemorenickname>
and there are no canonical workaround to that ?
<Onemorenickname>
(it sounds so silly when you put it that way)
<ggole>
Not really
<Onemorenickname>
hm
<Onemorenickname>
by the way, how do you know about this limitation ?
<Onemorenickname>
because the error message only says that it's not a polymorphic variant type
<ggole>
I've tried much the same thing in the past
<Onemorenickname>
i can understand it, it's a universal quantification, and there exists types which are not polymorphic variant type
<Onemorenickname>
but in "let rec pcon_to_lst (ghost: [>`X] as 'a) (arg: ['a | `Pcon of ('b * 'b)] list): ('a list) = match arg with
<Onemorenickname>
", 'a is indeed a polymorphic variant type
<Onemorenickname>
i see, and what did you do finally ?
<ggole>
Gave up and used regular variants
<ggole>
I was trying to get some kind of refinement effect where you could say "this constructor can't happen"
<Onemorenickname>
(if i use regular variant, i'm f... up : too many intermediary syntaxes :'(, i guess i'll repeat my code)
<ggole>
But it wasn't worth it.
<Onemorenickname>
i understand
<Onemorenickname>
but i'm working with formula transformations
<Onemorenickname>
and that kind of guarantee is worth it : it's the point of my code basically ha ha
<ggole>
Yeah, avoiding impossible cases is great where you can do it cleanly
<Onemorenickname>
thank you for your help :)
<ggole>
No worries
jnavila has quit [Remote host closed the connection]
Sim_n has joined #ocaml
brunoro has joined #ocaml
gjaldon has joined #ocaml
Simn has quit [Ping timeout: 260 seconds]
jg_ has quit [Ping timeout: 268 seconds]
brunoro has quit [Ping timeout: 250 seconds]
<Onemorenickname>
ggole,
brunoro has joined #ocaml
<Onemorenickname>
there are no variable for row polymorphic types, so be it, i have to do multiple type definitions
<Onemorenickname>
there are no intersection types nor overloading, so be it, i have to do multiple FUNCTION definitions
<Onemorenickname>
but, the worst : the type inference for the case match is broken
<Onemorenickname>
ggole, my problem is that these will be different for each function definitions
<Onemorenickname>
aka : i can't only copy-paste, i will have to rewrite each function, for each type that my variable in the row polymorphic variant could take in my program
<Onemorenickname>
this is good design.
<ggole>
Yep. If you can have many of those, it doesn't really work well.
<Onemorenickname>
i just got a one-page-long error with 6 "as-types" defined
<Onemorenickname>
I guess I'll continue coding tomorrow
gjaldon has quit [Remote host closed the connection]
dmi3y has joined #ocaml
dmi3y has left #ocaml [#ocaml]
dmi3y has joined #ocaml
dmi3y has quit [Client Quit]
dmi3y has joined #ocaml
dmi3y has quit [Client Quit]
djellemah has joined #ocaml
malc_ has joined #ocaml
Onemorenickname has quit [Read error: Connection reset by peer]
Onemorenickname has joined #ocaml
gjaldon has joined #ocaml
brunoro has joined #ocaml
brunoro has quit [Ping timeout: 252 seconds]
tane has quit [Quit: Leaving]
jg_ has joined #ocaml
redsteg has joined #ocaml
gjaldon has quit [Remote host closed the connection]
gjaldon has joined #ocaml
malc_ has quit [Remote host closed the connection]
tane has joined #ocaml
TarVanimelde has joined #ocaml
redsteg has quit [Quit: WeeChat 1.5]
Ravana has quit [Quit: Goodbye for now!]
Ravana has joined #ocaml
gjaldon has quit []
slash^ has quit [Read error: Connection reset by peer]
d0nn1e has quit [Ping timeout: 256 seconds]
<Onemorenickname>
hi people
minn has quit [Ping timeout: 260 seconds]
<Onemorenickname>
is there any performance downside when using polymorphic variant type ? (compared to classic variant types)
d0nn1e has joined #ocaml
minn has joined #ocaml
wxfdglm has quit [Ping timeout: 260 seconds]
jg_ has quit [Quit: Leaving]
<Drup>
yes, it's a little bit slower
<Drup>
and a little bit bigger in memory
<Onemorenickname>
Drup : where can i see why ?
<Drup>
only significant if it's right in the hotloop, doesn't matter otherwise
<Drup>
I'm not sure it's really specified in the documentation :/
<Onemorenickname>
Drup, oh, I see. How do you know it so ?
<Drup>
eh, the memory representation ._.
<Drup>
If you are curious, you can use the "inspect" package to look at it
wxfdglm has joined #ocaml
<Onemorenickname>
Drup : No canonical doc I guess ? :'(
jnavila has joined #ocaml
rgrinberg has joined #ocaml
TarVanimelde has quit [Read error: Connection reset by peer]
<Onemorenickname>
in my pattern matching, i match all values required
madroach has quit [Ping timeout: 250 seconds]
madroach has joined #ocaml
madroach has quit [Ping timeout: 260 seconds]
madroach has joined #ocaml
octachron has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
<smondet>
Onemorenickname: it seems you have one extra level of "_ list": to_tokenize is itself a list and your function takes a list of to_tokenize (hence a list of lists).
Onemorenickname has quit [Read error: Connection reset by peer]
Onemorenickname has joined #ocaml
madroach has joined #ocaml
madroach has quit [Ping timeout: 260 seconds]
madroach has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
Onemorenickname has quit [Read error: Connection reset by peer]
zpe has quit [Remote host closed the connection]
madroach has quit [Read error: Connection reset by peer]
Onemorenickname has joined #ocaml
whisperedcigar has quit [Ping timeout: 245 seconds]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
tane has quit [Quit: Leaving]
redsteg has joined #ocaml
whisperedcigar has joined #ocaml
madroach has joined #ocaml
rgrinberg has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
dmi3y has quit [Quit: dmi3y]
brunoro has joined #ocaml
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
mfp has joined #ocaml
octachron has quit [Quit: Leaving]
brunoro has quit [Ping timeout: 256 seconds]
madroach has joined #ocaml
manizzle has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
madroach has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
brunoro has joined #ocaml
madroach has joined #ocaml
brunoro has quit [Ping timeout: 256 seconds]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
redsteg has quit [Ping timeout: 260 seconds]
MercurialAlchemi has quit [Ping timeout: 265 seconds]
madroach has quit [Ping timeout: 264 seconds]
jnavila has joined #ocaml
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
inau has joined #ocaml
madroach has joined #ocaml
inau has left #ocaml [#ocaml]
jnavila has quit [Ping timeout: 260 seconds]
nomicflux has quit [Quit: nomicflux]
Muzer has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
argent_smith has quit [Quit: Leaving.]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
<Algebr>
What does it mean when a external has two names for the linker?
<Algebr>
external foo : unit -> unit = "abc" "cde"
<adrien>
Algebr: bytecode and native code versions
<adrien>
calling conventions differ once there are 5 or more arguments roughly
<Algebr>
ah right right
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
Onemorenickname has quit [Quit: Leaving]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
redsteg has joined #ocaml
struk|desk has quit [Remote host closed the connection]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
rand__ has quit [Quit: leaving]
ethnopes has joined #ocaml
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]