xificurC has quit [Remote host closed the connection]
xificurC has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
Erylisia has quit [Read error: Connection reset by peer]
Erylisia has joined #ocaml
xificurC has quit [Remote host closed the connection]
xificurC has joined #ocaml
dubosec has quit [Ping timeout: 250 seconds]
xificurC has quit [Remote host closed the connection]
xificurC has joined #ocaml
larhat has joined #ocaml
xificurC has quit [Ping timeout: 256 seconds]
tsumetai has quit [Ping timeout: 272 seconds]
tsumetai has joined #ocaml
xificurC_ has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
hilquias has quit [Remote host closed the connection]
hilquias has joined #ocaml
xificurC_ has quit [Remote host closed the connection]
larhat has quit [Quit: Leaving.]
xificurC_ has joined #ocaml
nojb has quit [Quit: nojb]
MisaMisa has quit [Remote host closed the connection]
<tobiasBora>
Hello !
xificurC_ has joined #ocaml
<tobiasBora>
I have a problem with Ocamlnet : I would like to send a POST message with some headers (couple list) and a body (string), but the function doesn't have any way to specify a body :
<rgrinberg>
Drup: no luck getting the marks stuff merged? :D
palomer has joined #ocaml
<Drup>
I asked, he said he was going to review
<Drup>
scoop of the day: there are two many things in the opam repository x)
<rgrinberg>
i'm thinking of trying to functorize re again
<rgrinberg>
so trying to gauge his review capacity
<Drup>
functorizing is not technical
<Drup>
I can review it too
<rgrinberg>
i also don't want conflicts with your PR as well :)
<Drup>
bah, that shouldn't be an issue
<Drup>
I don't touch indices
<Drup>
well, except that I change some data types, but you could just use these commits
palomer has quit [Quit: palomer]
<rgrinberg>
yeah it's unlikely your commit will change so i'd just build on top of it
palomer has joined #ocaml
xificurC_ has quit [Remote host closed the connection]
nullcat has joined #ocaml
palomer has quit [Quit: palomer]
<rgrinberg>
i have a dream of parsing a full http request (minus the body) with 1 re
n3ss3s has joined #ocaml
<rgrinberg>
too bad the result won't be useful...
<n3ss3s>
Hello. The subtraction on line 5 is giving me "This expression has type float but an expression was expected of type [ `Deprecated_use_float_module ] ", http://pastebin.com/GUz0jjAi
<n3ss3s>
any hints?
<n3ss3s>
I'm using Jane Street's core
<rgrinberg>
use Float.(-)
dubosec has joined #ocaml
<rgrinberg>
better yet, prepend your if with let open Float in and use - normally
<n3ss3s>
Oh thank god that sounds great, I was about to throw a hissy fit about not being able to subtract two real numbers just by using a -
<n3ss3s>
thx
<Drup>
Float.(1. - 5.) works too
<Drup>
grr, ocamlgraph support for dot attributes is ridiculously outdated
<n3ss3s>
hmm, I'm still getting the same error. It has something to do with passing it to abs_float, because if I use utop to just do a simple subtraction it works
<n3ss3s>
but when I wrap the subtraction in abs_float I get the error
<rgrinberg>
is this what you did? Float.(abs_float (fhd - c1) > abs_float (fhd - c2))
<rgrinberg>
oh that's right
<n3ss3s>
No I did let open Float in let fhd = of_int 5 in abs_float (1.0 - fhd)
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
<Drup>
wow, an error message about modules I never got before !
rgrinberg has joined #ocaml
<Drup>
"Illegal permutation of structure fields"
<Drup>
didn't know that one <3
xificurC_ has quit [Remote host closed the connection]
n3ss3s has joined #ocaml
rgrinberg has quit [Ping timeout: 265 seconds]
hugomg has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
osa1 has quit [Ping timeout: 265 seconds]
rgrinberg has joined #ocaml
xificurC_ has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
<nullcat>
I am using merlin. in .merlin I have "S lib" and in /lib I have A.ml and B.ml. Doing "open A" in B.ml and merlin shows error saying A is unbound...
Erylisia has quit [Quit: Quitte]
<nullcat>
anyone knows why?
<Drup>
where are your build artifacts ?
<nullcat>
"/_build"
<nullcat>
i did "B _build"
<Drup>
replace by "B _build/*"
<nullcat>
in .melrin
<nullcat>
ok let me see
<Drup>
(and compile, ofc)
<nullcat>
oh no more error!
<nullcat>
thanks, Drup!
<dora-molly>
np :P
<nullcat>
...?
<nullcat>
!?
<Drup>
x)
<nullcat>
thanks
<nullcat>
ah a bot??
<Drup>
Is dora-molly a bot ? That's an excellent question.
<nullcat>
thanks, Drup!
<dora-molly>
np :P
<nullcat>
thanks, Drup!
<dora-molly>
…
<Drup>
x)
<nullcat>
....
<nullcat>
thanks, Drup!
<rgrinberg>
I actually want your marks patch now.. :P
<rgrinberg>
functorizing isn't enough
<Drup>
oh ?
<Drup>
for what ?
<nullcat>
not a bot..
<rgrinberg>
quick n dirty scanning of headers for keep alive
<n3ss3s>
Ugh. I'm trying to get the mean of the values of a list of (int, int), but in my fold when I match for (k, v) it expects a match for int, http://pastebin.com/jzTNBdRw
<n3ss3s>
Why is it inferring it to be a list of ints?
<rgrinberg>
not just keep alive actually, also transfer encoding
<Drup>
and you put the mark inside the option and roll with it
<Drup>
yes, that would work just fine.
<rgrinberg>
Drup: yep. this will let me avoid fully parsing headers
<rgrinberg>
and hopefully win bench marks down the road
<Drup>
in this case, though, you don't *need* that
<rgrinberg>
yes you're right BUT even doing this simple-ish stuff on a cstruct
<Drup>
you can put a matching group inside the option (which you know the number) and test if the group was matched
<rgrinberg>
is painful
<rgrinberg>
Drup: oh? but i don't know if keep alive or transfer encoding will come first?
<rgrinberg>
if i had named groups perhaps
<Drup>
ah, yes, that won't work
<Drup>
if it's under a star
<Drup>
that works only outside a star
<rgrinberg>
it should be possible with full blown pcre
<Drup>
and then, POUF, your performances.
<rgrinberg>
yeah..
<rgrinberg>
aargh, if only re had some callback mechanism
<rgrinberg>
it would look like sedlex, i know..
<Drup>
callback ?
<rgrinberg>
yeah, attach a thunk to an re whenever it matches for example
<Drup>
I don't think you can do the kind of path compression re is doing if you have that
<rgrinberg>
why do people write let ... and just to be cute :/
<Drup>
?
<rgrinberg>
when there's no mutual recursion
<nullcat>
the avatar is the reason I ask you
<Drup>
rgrinberg: yes, I know, but what are you making a reference to ?
<Drup>
nullcat: :]
<rgrinberg>
handle_result_frame...
ygrek has quit [Ping timeout: 246 seconds]
<dmbaturin>
What's so cute about let ... and in the first place? :)
<nullcat>
i write "let x = 1 and y = 2 and z = 3 in" just because it can save some typing....
<nullcat>
save six charaters
<Drup>
so precious.
<rgrinberg>
nullcat: please staahp
<flux>
nullcat, I've got an AMAZING trick for you! let x, y, z = 1, 2, 3 in .. ;-)
<rgrinberg>
Drup: did you end up getting rid of all the duplicated exceptions?
<nullcat>
.....
<nullcat>
..........!!
<Drup>
nullcat: and it doesn't even allocate the fake tuple
<nullcat>
I feel dumb
<Drup>
(such compiler)
<nullcat>
yeah...i know
<Drup>
rgrinberg: I don't think I tried more than the last time
<nullcat>
just read internal memory representation last night...
<nullcat>
in RWO
<rgrinberg>
Drup: good candidate >>> exception Lost_connection of exn
<flux>
the problem with using 'and' is that the values cannot depend on each other, unless you use let rec as well. and even then they cannot depend on each other as values.
<Drup>
rgrinberg: please report somewhere durable
<Drup>
(or fix, whichever is faster)
<rgrinberg>
Drup: fixes should go into master no?
<Drup>
that kind, probably, yes
<nullcat>
yep
<rgrinberg>
Drup: but ok, i'll make a ticket
matason has joined #ocaml
<dmbaturin>
Does "lwt x = ... in ..." expect all expressions to return unit?
<Drup>
no
n3ss3s has quit [Ping timeout: 264 seconds]
<rgrinberg>
Drup: so compute_extensions is what basically generates the result right?
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
rgrinberg has quit [Ping timeout: 272 seconds]
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
slash^ has left #ocaml [#ocaml]
slash^ has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
nicoo has quit [Ping timeout: 264 seconds]
wildsebastian has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
contempt has quit [Ping timeout: 246 seconds]
ggole has joined #ocaml
shinnya has joined #ocaml
contempt has joined #ocaml
yakov has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 264 seconds]
dav has quit [Ping timeout: 256 seconds]
dav has joined #ocaml
meteo_ has joined #ocaml
<reynir>
I sometimes use let ... and if there are no dependencies. Then you can read each binding by itself
nopf has quit [Quit: leaving]
wildsebastian has quit [Quit: Konversation terminated!]
<haesbaert>
I keep coming accross this pattern, I want a List.find that returns the value of the variant I match, not the variant itself
<haesbaert>
let v = List.find (function VariantBla x -> true | _ -> false) l
<haesbaert>
match v with VariantBla x -> v | -> failwith "boom"
<haesbaert>
there must be a better way to do it
<haesbaert>
I've tried, this but there is something wrong:
<haesbaert>
let rec findsome f list = match list with | [] -> None | hd :: tl -> match (f hd) with Some x -> x | None -> findsome f tl
luzie has quit [Remote host closed the connection]
luzie has joined #ocaml
nopf has joined #ocaml
djellemah has joined #ocaml
djellemah_ has joined #ocaml
rgrinberg has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
djellemah has quit [Disconnected by services]
djellemah has joined #ocaml
djellemah_ has left #ocaml ["Leaving"]
rgrinberg has quit [Ping timeout: 255 seconds]
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
sdothum has joined #ocaml
Tekilla has quit [Read error: Connection reset by peer]
Tekilla has joined #ocaml
Haudegen has quit [Ping timeout: 272 seconds]
<flux>
soo, what's the best way to have ocamlbuld integrate 'git describe --always --dirty' into a build?
<flux>
haesbaert, I don't quite know what's wrong about your function, but at least its type is quite interesting...
<flux>
val findsome : ('a -> 'b option option) -> 'a list -> 'b option
rwmjones has joined #ocaml
<flux>
debug hint for a polymorphic function: make it non-polymorphic. let rec findsome f (list : int list) = ..
Tekilla has quit [Quit: Quitte]
<flux>
this way the toplevel or compiler will not replace 'a list with (say) 'a list list or ('a list option list list option) ;-)
<ggole>
haesbaert: you can write that one easily enough: val find_by_key : ('a -> 'b option) -> 'a list -> 'b option or val find_by_key : ('a -> 'b) -> ('b -> bool) -> 'a list -> 'b
<ggole>
(I suppose that last one should be find_by_key_exn.)
<haesbaert>
I just found core's find_map, which does that
<nojb>
you can either use the object initializer or just perform the check before creating the object
<nojb>
class maclasse ?arg = match arg with None -> raise Not_found | _ -> object(self) val coucou = "1" end
<nojb>
or
palomer has joined #ocaml
<nojb>
class maclasse ?arg = object(self) val coucou = "1" initializer match arg with None -> raise Not_found | _ -> () end
bjorkintosh has joined #ocaml
javamonn has joined #ocaml
<tobiasBora>
nojb: Great thank you :D
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
javamonn has quit [Remote host closed the connection]
struktured has quit [Ping timeout: 256 seconds]
<tobiasBora>
It's amazing !
<tobiasBora>
How is it possible that let f o = o#name;; can be called on several objects O_o
rgrinberg1 has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 265 seconds]
<Drup>
tobiasBora: that's half the point of objects in OCaml.
lordkryss has joined #ocaml
djellemah_ has quit [Ping timeout: 245 seconds]
darkf has quit [Quit: Leaving]
<tobiasBora>
Well I think I'm going to use objects more often !
<tobiasBora>
The good way to use Map in an object value is to use references ?
Haudegen has joined #ocaml
<ggole>
If you need to change it, probably just use a mutable field
<rgrinberg1>
Drup: up already?
rgrinberg1 is now known as rgrinberg
<Drup>
apparently
<tobiasBora>
ggole: Yes I'm stupid ^^ But I asked the question because it seems pretty strange for me te create a new Dict every time I want to add a single element.
<ggole>
That's the FP way.
* ggole
prefers filthy mutation when it makes sense
sepp2k has quit [Ping timeout: 272 seconds]
<tobiasBora>
And it has the same efficiency has in an imperative programming ?
<ggole>
Efficiency is all over the place, really
<ggole>
Assignments have a cost (write barrier), allocation has a cost, TANSTAAFL
<rgrinberg>
Drup: might merging my comment removal. My cohttp branch is already rebased on top of it and i have a PR coming :)
<tobiasBora>
Ok then it's pretty nice thank you !
<Drup>
I should actually translate them instead ...
<rgrinberg>
that works too
<rgrinberg>
i'll just change my pr for now
n3ss3s has joined #ocaml
osa1 has quit [Ping timeout: 256 seconds]
xificurC_ has quit [Quit: WeeChat 1.1.1]
xificurC has joined #ocaml
<Drup>
rgrinberg: what's the new bound for cohttp ?
<Drup>
still 0.16 or now 0.17 ?
sepp2k has joined #ocaml
<rgrinberg>
0.17
<Drup>
.something ?
<rgrinberg>
i don't think so
Haudegen has quit [Ping timeout: 252 seconds]
<Drup>
rebased, CI should be fixed
<rgrinberg>
> 0.17.0 is fine
<rgrinberg>
Drup: have you read my commits?
<Drup>
yes, I read them, I noticed it was mostly the same as what was done previously
k1000 has quit [Ping timeout: 256 seconds]
<rgrinberg>
do you think we're losing anything of value by not using send?
k1000 has joined #ocaml
<Drup>
I have literally no idea.
<rgrinberg>
i guess we can ask jerome
<Drup>
Add a comment pointing jerome to the specific commit
javamonn has quit [Read error: Connection reset by peer]
javamonn has joined #ocaml
rgrinberg has quit [Ping timeout: 240 seconds]
matason has joined #ocaml
yetone has joined #ocaml
osa1 has quit [Quit: Konversation terminated!]
matason has quit []
<flux>
soo, I suppose it would be merlin's task in future to make sure C-c h works for any module?
Haudegen has quit [Ping timeout: 276 seconds]
yetone has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
freling has quit [Quit: Leaving.]
freling has joined #ocaml
mcc has joined #ocaml
<flux>
awesome, my ocaml program that uses quite a few of ocaml libraries.. maps 2.6 gigabytes of heap. uses 'only' less than 500 megabytes of it (resident).
<flux>
I don't quite understand why :-)
<flux>
bonus: it uses 100% CPU (I'm sure Lwt.t has something to do with this)
<flux>
or maybe not?! 55.09% libc-2.19.so [.] __memmove_ssse3
<flux>
16.38% [kernel] [k] page_fault
<flux>
what...
<flux>
does this mean my puny 'curl' downloader clone is CPU-bound?-o
<Drup>
x)
<adrien>
small allocs?
<flux>
sounds like it
<adrien>
also, page fault sounds like you could easily improve it
<flux>
I guess the 'string' Lwt_stream.t might by of single-byte strings
<flux>
s/by/be/
<adrien>
ocaml is also going to allocate 1.8 times more memory than it needs
<adrien>
it's 1 + ohIforgotthatGCparam
<Drup>
I like the precision.
<mcc>
Hello ocaml humans i have some questions about ocaml-ctypes
<mcc>
does anyone have familiarity with it?
<Drup>
hello mcc
<Drup>
a bit
<mcc>
ok
<adrien>
commit_overhead
<adrien>
:)
<Drup>
working on FFI to C for your language ?
<mcc>
also hi drup sorry i never got back to you on the sedlex stuff if i get back to fixing my unicode i will definitely start with making the sedlex change you proposed
fredyr has joined #ocaml
<Drup>
Sure, no problem
<mcc>
drup: yup! which is why i am looking at ctypes and not quite sure if it is what I want
<Drup>
so, there are currently 3 way to use ctypes
<mcc>
ok
<Drup>
1) dynaminc binding using libffi
<mcc>
maybe what you are about to say will answer my other
<mcc>
question
<Drup>
2) static binding, by mean of C code generation
<mcc>
mm
<Drup>
3) reverse binding (by mean of C code generation too, iirc, I'm not very interested by that one)
<flux>
hmm, I wonder what Cohttp_lwt_body.create_stream : ('a -> Cohttp.Transfer.chunk Lwt.t) -> 'a -> string Lwt_stream.t is for..
<flux>
weren't the GC defaults increased at some point to something more sensible?
rgrinberg has joined #ocaml
<Drup>
I don't think so
<Drup>
mcc: does the answer satisfy you ?
<mcc>
drup: yes, it does. so let me describe to you what i want to do
<mcc>
drup: what i want is for Emily code to be able to reach through and call in to C code. I don't think I care much at all about OCaml being able to call the C code. I am at the point I am trying to write as little OCaml as possible.
<mcc>
(OCaml is nice, but I want to reduce my language's dependency on it)
javamonn has quit [Remote host closed the connection]
<mcc>
so i think i want to dynamic bind, because Emily only understands dynamic bind
javamonn has joined #ocaml
<flux>
I increased GC to 10 megabytes, still 100%. and the data isn't really flowing that fast either.
<flux>
hmm I mean minor heap, and I then lowered it to 1 megabytes, no help
<reynir>
flux: maybe you can use Lwt_stream.fold_s instead of the loop
<mcc>
but, also, it *seems* (?) like the dynamic bind in ctypes is very ocaml linked. that is, it seems like if i used ctypes, i would have to somehow convert the c idioms to ocaml-ctypes idioms, then convert that to some OTHER set of idioms appropriate for Emily
<Drup>
ctypes is certainly ocaml oriented
<mcc>
it looks fantastic if your goal is to write an ocaml application.
<mcc>
anyway, this makes me think i should either not use ctypes and find something which wraps libffi more directly, or else use ctypes to talk to libffi!
Haudegen has joined #ocaml
<Drup>
you can use only the libffi part of ctypes
<Drup>
it's exposed
<mcc>
cool
<mcc>
so maybe i pass through to that and also manually expose bits of clanglib so i can parse c headers
<mcc>
btw to your knowledge is "parse c headers and build a set of ocaml-ctypes dynamic-bind objects" something you're aware has been done
<Drup>
the normal ctypes interface wouldn't work for you anyway
<Drup>
you can create a binding at runtime, but it's strongly typed, your language is dynamically typed (for now ?)
<flux>
reynir, no help. updated source.
<Drup>
you just can't produce the relevant type before binding
Submarine has joined #ocaml
<mcc>
that amkes sense
<Drup>
(no progress on the type system front ? :p)
<mcc>
drup: language is dynamically typed. and once it is non-dynamically typed, it will be, um, actually the code will run in two passes, at compile time code will run which dynamically generates type objects, and then the compiler will make those type objects into static assertions :D
<mcc>
maybe i didn't describe that well
<mcc>
drup: I bought a copy of "Types and Programming Languages"! Maybe I will read it on the plane next week. That is my only progress.
hugomg has joined #ocaml
<Drup>
right, the "type-error-as-runtime-error" trick
<Drup>
I find that cute and funny, similarly to a clever C shell hack
<Drup>
C or shell*
<Drup>
the kind of code "that's interesting, but I don't want to see that ever again"
<ggole>
mcc: what do you mean? You have parts which are typed at some time?
k1000 has quit [Ping timeout: 255 seconds]
<flux>
I wonder if this could be an ocaml problem in general on my system..
k1000 has joined #ocaml
<mcc>
drup: haha
<mcc>
ggole: so, the first pass is that types will just be runtime assertions.
<Drup>
mcc: ghc has an option to do that in haskell
djellemah has quit [Ping timeout: 256 seconds]
<mcc>
ggole: There will be some operator like (x : t) which means "verify x satisfies t"
<ggole>
OK, pretty much like some dynamic languages
<mcc>
ggole: "t" will probably be one of the builtin types, such as "int".
<Drup>
yeah, it's exactly like having TypeOf and a "Type" object
<mcc>
drup: there is no runtime penalty for failing a python type assertion, and in fact and no runtime performance penalty for *checking* a type assertion
<ggole>
mcc: so if the static analysis can't prove that the :s are consistent, it rejects the program?
<mcc>
ggole: i'm trying to preserve gradual typing, so some :s will be marked as "mandatory" (not sure how yet) and some will not.
<mcc>
ggole: but the general idea is, if the static analysis can prove that the :s are *in*consistent, it rejects the program
<Drup>
I think you can come up with a better gradual typing system.
<ggole>
I see. Some Common Lisp impls do similar things.
<mcc>
ggol: if it cannot prove that the :s are consistent (for example, because you passed data from a dynamically-typed section of the code to a statically typed system of the code), it emits a warning, saying, "maybe this call is unsafe"
<mcc>
ggol: and if you are using the compiler, if there are any calls the type checker says "hey, i cannot prove this is safe", it emits a runtime check at that point
<mcc>
ggol: whereas it is able to optimize out runtime checks it can prove never trigger.
<mcc>
ggole: that's encouraging
<Drup>
I think you should only have the "compiler" behavior
<mcc>
drup: what do you see as the downside of it?
<mcc>
drup: so, i have two goals. one, i want it to be possible to make a *really really minimal* interpreter, and have it have the same behavior as the compiler.
<Drup>
it's not as much a downside as an inherent fragility of the system
<mcc>
drup: somebody made most of an Emily interpreter in a week in Javascript. if they had had to write a static type checker that would be more difficult.
matason has joined #ocaml
<Drup>
basically, what you are saying is that your type system is inherently undecidable and you will try to have a best-effort static analyser to remove as much dynamic checking as possible
<Drup>
it's good on paper
<ggole>
mcc: have you looked at Julia? They have a similar sounding arrangement, although the design seems to be tilted towards allowing nice flat representations rather than checking type per se.
<Drup>
but the best effort is usually very fragile
<mcc>
Drup: the other thing I want is I want it to be possible, *in principle*, to create a type object at runtime, and possbly for that type object to be unsound (unprovable). For example I would like to be able to say TypeFrom ^x(x<4) or something.
<mcc>
ggole: Julia is *really* interesting, i tried to run it and had installation problems on this computer. Maybe I should try again on my new computer.
<Drup>
mcc: how is that unsound ?
<mcc>
Drup: Because it's a lambda.
<Drup>
It's just a lambda, what's the problem with it ?
<ggole>
I've been wondering about how to understand what Julia does
<Drup>
mcc: and ? It has a type
<flux>
in fact it did _not_ solve my problem. what's interesting is that _a slowed download source_ caused _increased CPU load_ :-)
<ggole>
Usually I think of dynamic langs as a (large) bunch of operations over a sum type
<ggole>
Which is pretty standard
<ggole>
But the type stuff in Julia seems to throw a bit of a spanner in that model
<mcc>
drup: because Emily has operator overloading, so unless you further specify "x is a number", "x<4" could run arbitrary code :D
<Drup>
mcc: cf my point about undecidable type checking and best effort
<mcc>
Drup: so, my goal is to be able to split my program into two parts, one part which is wholly static, one part which is essentially wholly dynamic
<Drup>
mcc: it's not that it's unsound
<Drup>
it's just that the type system to express it is a fucking nightmare because you didn't think it through before
<mcc>
Maybe I misunderstand what the word "unsound" means in type systems.
<ggole>
Now I'm on to thinking about it as a GADT sum type where one of the possible legs Typed : 'a Type.t * 'a
<Drup>
mcc: that's typeable with typeclasses, for example.
<mcc>
hm, ok
<mcc>
Drup: So my assumption is that I can have there be a *subset* of the type system which is well-formed.
<ggole>
So you can dynamically determine that things are, eg, the right shape, without having all the parts tagged
<mcc>
Drup: Like, maybe, the compiler just throws up its hands, and says, any type which is built from the primitives Number, String, and -> is statically checkable, everything else, I ignore it and do the checks at runtime.
<ggole>
And you can produce witnesses that some checking work has been done in a staging pass that's a lot like compilation
<mcc>
Drup: I don't see why I should limit the user's expression just because I don't know how to prove something is true yet.
<ggole>
It's all entirely dynamic, and yet you get to say quite interesting things.
nojb has quit [Quit: nojb]
<Drup>
mcc: yes, that's the dynamic-language approch to programming
<Drup>
ggole: you are assuming that you can express the type of objects
<mcc>
Drup: Now, probably it would be bad if i picked a way of constructing types which *almost never* is checkable whereas had i asked the user to construct things a slightly different way the same intended types *usually* would be
<ggole>
Drup: why would you not be able to?
Haudegen has quit [Ping timeout: 264 seconds]
<mcc>
Drup: But if I realize later I have done this, I can transition to the latter system by adding new primitive type objects while leaving the old garbage system as a fallback.
<Drup>
ggole: because you can express arbitrary dynamic stuff ?
<mcc>
Drup: What I want is I want to be able to write a program which is part static and part dynamic.
<mcc>
Drup: Before I started working on this project, my status quo was I would write programs which were half C++ and half Lua.
<Drup>
half dynamic and half dynamic ? :D
<mcc>
Drup: Well. If you could give me a safe language which does not require a garbage collector, I would have strongly considered it :P
<Drup>
Rust
<mcc>
Yeah, Rust is *really* interesting.
<Drup>
you say that often :D
<mcc>
It did not exist in 2011 when I built this system.
<Drup>
sure it existed in 2011
javamonn has quit [Remote host closed the connection]
<ggole>
Drup: that's not an obstacle at all
<mcc>
I'm sure a language named "Rust" existed then, but I doubt it was production-ready, and I very much doubt it was the same language which exists under the name "Rust" today :P
<Drup>
ggole: well, it just means that in your Types.t, you have "IDontKnow"
<ggole>
You can use the obvious recursive analysis to construct an existentially wrapped type object that can be used for "type checking"
<Drup>
mcc: indeed
<Drup>
=)
<mcc>
Heh.
<ggole>
When you have two type objects, equality of the type objects witnesses that they are the same shape/type/whatever
<mcc>
Anyway, when I get to the Emily compiler, I will be strongly considering Rust :P
<ggole>
(Otherwise, runtime failure)
<Drup>
ggole: if you have arbitrary operator overloading, how do you type "fun x -> x + a"
<Drup>
you need specific constructs in your type system to handle that
<ggole>
Sure, you need a design
<ggole>
But the basic idea works
<Drup>
and then, given a specific type system, I will be able to give you another example that doesn't work
<mcc>
I would type that as (int -> int) | (float -> float) | (idontknow ->idontknow)
rgrinberg has quit [Ping timeout: 244 seconds]
<mcc>
Drup so imagine that 'knowntype" is a type. or a type adverb or something
<ggole>
Depends on what you mean by "doesn't work"
matason has quit []
<Drup>
"whch type is not representable in your type system"
<mcc>
Drup: I can then say: (fun x -> x + a) : knowntype
<mcc>
Drup: And the compiler throws an error
<mcc>
Drup: Because the type of x -> x + a is not proveable
<ggole>
That's not very interesting. All type systems have limitations.
<ggole>
(Or are unsound.)
<mcc>
Drup: So I go back, and I rewrite it: (fun x : int -> x + a) : knowntype . And now the compiler is happy, because it knows fun x is an int -> int and (int -> int) : knowntype .
<mcc>
maybe that : should be a :> or something. dunno.
<Drup>
ggole: that's why I'm not fond of mcc plans "put whatever I like in the language and wonder about the typing implications later on"
<mcc>
hahaha
<reynir>
mcc: a type system is unsound if something type checks and then fails at runtime (~ when you can prove false)
<ggole>
Well, I was really talking about something else...
<Drup>
for a well designed system, you should choose a set of feature that works well in your type system, not excluding dynamic features
<Drup>
ggole: it's related
<mcc>
reynir: i see
<Drup>
if one of your main features (let's say, by pure luck, operator overloading) is always unsound, then you have an issue
<Drup>
s/unsound/unprovable/
<ggole>
What I was describing isn't unsound (as far as I know). I think I could write it in OCaml, in fact.
<Drup>
you can write it in OCaml because you can describe a sound Types.t
<ggole>
Because GADTs let me talk about shapes safely, and yet dynamically.
<Drup>
which is not necessarily the case for any system.
<mcc>
reynir: and the fact that in the unproveable case i emit a clean check which leads to a well-defined exception handling event (oh, right, i will have to add one of those at some point) would *not* make it "sound", right? Because that's still a runtime failure that was not detected.
<Drup>
mcc yes
<Drup>
the fact that the failure is "clean" and not a nuclear explosion doesn't make it sound :D
moei has joined #ocaml
<mcc>
ggole: okay so— what you are describing, you're basically *not* dynamically typing though, right? you're just saying "create a thing of non-*specified* type, but when i hit 'compile' it will always sort out to a well-defined type because the ocaml compiler is smart". right?
<reynir>
hmm
<Drup>
mcc: note that the unsoundness is wrt to a specific notion of failure
<ggole>
I'm describing fully dynamic typing, extended with a way to talk about parts being typed.
<Drup>
in the case of most type system, it's type mismatch
<mcc>
ok
matason has joined #ocaml
<ggole>
mcc: when I say, "typed", I mean a pair of a type object that describes the shape of the thing, and then the thing itself
<mcc>
ggole: OK. so it's dynamic, but you still could have a code path where you do something different on objects which are "Typed"
<ggole>
Yeah
<mcc>
that is interesting
TheLemonMan has joined #ocaml
<ggole>
When you move from untyped to typed, you establish that the untyped thing has the right shape, and then you don't have any further type checks
<mcc>
Something like that is my goal yeah.
<mcc>
Although… hm. I do see what you're saying.
<ggole>
That's my understanding of how Julia is designed as a dynamic language with typed parts, anyway.
nojb has joined #ocaml
Haudegen has joined #ocaml
<reynir>
mcc: I wouldn't say it makes the type system unsafe as long as it recognizes it might be "bad".
ygrek has joined #ocaml
<mcc>
reynir: which part?
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
nullcat has joined #ocaml
<mcc>
anyway, the language is fairly configurable, so the hope is you can make a compiler-enforced subset of the language which drup and whitequark would not hate, and write any files you produce in it while still using the libraries from my crawling chaos. ^_^
<reynir>
hah, I forgot
<mcc>
heh
ontologiae has joined #ocaml
<Drup>
mcc: heh, no offence, but if I really wanted to use this kind of language, I would use Racket ;)
<Drup>
offense* ? I think.
swgillespie has joined #ocaml
<reynir>
mcc: is ppx_const yours?
matason has quit [Max SendQ exceeded]
matason has joined #ocaml
ygrek has quit [Ping timeout: 250 seconds]
<mcc>
reynir: yes
<mcc>
drup: Racket sounds *great*.
<Drup>
yep
<reynir>
mcc: I think it would be cool if it also worked with match :)
<Drup>
or it's cousin with less parens, Pyret
<mcc>
reynir: yeah! "match" and "option" would be fantastic things to support.
<mcc>
reynir: if you want to give it a shot I'd love to get that pull request ^_^
<mcc>
reynir: the main problem with ppx_const is that ppx_env does not have the ability to detect or force a clean build when one of the envs changes :(
<Drup>
(as a general rule, I'm quite fond of their constract system)
<flux>
so apparently there are at least two ocaml-cohttp issues about GC pressure, though in some other use cases.. perhaps it's not beneficial to add a third one?
<apache2>
Does anyone know how to satisfy ocamlfind / ocamlopt here: ocamlfind: Package `ctypes.foreign.threaded' not found - required by `ctypes.foreign'
<mcc>
reynir: the guide drup just posted is the best bet! it also helps to check out a copy of the Ocaml source, and look at the files in the tree: extension_points.txt ast_helper.ml parsetree.mli
nojb has quit [Quit: nojb]
<mcc>
extension_points.txt is technically the reference guide for the extension points feature, i think
<Drup>
no, it's outdated
<mcc>
Oh.
<Drup>
and it doesn't really present how you write them in practice
<mcc>
Anyway, you'll need those two ml/mli files in order to udnerstand all the Pexp_extension types and everything.
<mcc>
i pretty much wrote ppx_const by looking at the source for ppx_getenv, so maybe that's useful to look at too
<mcc>
i THINK all you need to do
<mcc>
if you want to add match
<Drup>
yeah, knowing the parsetree is quite useful
<reynir>
ok thanks
<mcc>
is edit the single file ppx_const.ml, look at the match which matches with | { pexp_loc = loc; pexp_desc = Pexp_ifthenelse
<Drup>
and ppx_metaquot
<mcc>
and then add a case for Pexp_match
<mcc>
what's ppx_metaquot :O
<Drup>
mcc [%expr ... ]
<Drup>
that's ppx_metaquot
<Drup>
the section "AST quasiquotation" in whitequark's article
<mcc>
hm ok
pyon has quit [Quit: I have irrefutable proof that D < 0. It follows trivially from 2D > 3D, which is obviously true.]
lordkryss has quit [Quit: Connection closed for inactivity]
matason has quit []
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<reynir>
I haven't seen whitequark in here in a while btw
<nullcat>
me too
pyon has joined #ocaml
matason has joined #ocaml
rgrinberg has joined #ocaml
<apache2>
nojb: thnak you!
<mcc>
i see wq on twitter mostly
hilquias has quit [Ping timeout: 250 seconds]
<nullcat>
mcc: are you mcclure111?
<mcc>
nullcat: yes
<nullcat>
good. i remembered i followed you this week
rgrinberg has quit [Ping timeout: 244 seconds]
<reynir>
mcc: would it be ok if I tried to rewrite ppx_const to use ppx_metaquot?
wraithm has quit [Quit: leaving]
The_Mad_Pirate has quit [Remote host closed the connection]
wraithm has joined #ocaml
hilquias has joined #ocaml
<nullcat>
I still remember when i was learning ppx, i asked Drup and whitequark lots of dumb questions...
<Drup>
(you wanted some project to read: lwt and jsoo's ppx should be easy to read and understand)
<nullcat>
wait... whitequark quitted this channel ?...
<nullcat>
can't see his name now..
<Drup>
yeah, he basically rage quited at some point
<reynir>
I just checked my log
<reynir>
it was a camlp4 + oasis rant
<Drup>
yes
<nullcat>
...
<mcc>
reynir: i don't see a problem with that, but can you explain what the advantage is?
<mcc>
reynir: would that change the syntax away from if%const ?
<Drup>
metaquot should be a bit more future proof
<reynir>
No
<reynir>
Oh, I didn't think of that
<reynir>
My reasoning was it would make the coder shorter ;)
<Drup>
if the parsetree changes, it shouldn't matter if you wrote your stuff using metaquot, since it's doing the translation to the parsetree based on OCaml's syntax
<Drup>
and it makes the code cleaner/easier to read, yes
<Drup>
unfortunatly, you can't express everything with it
<reynir>
Oh hm
<Drup>
typically, you can't use it when there is a list of thing involved, like match cases
<reynir>
darn it :)
matason has quit []
<nullcat>
i saw that part of the log... whitequark's rant is indeed bitter
Gama11_ has joined #ocaml
Gama11 has quit [Ping timeout: 244 seconds]
<mcc>
drup: what can't be expressed with it?
<mcc>
wait, if wq left then who is maintaining the log
<ggole>
bot
<Drup>
he left the bot log running
djellemah_ has joined #ocaml
<nullcat>
that's good..
<nullcat>
i missed him, he gave me lots of help...
<nullcat>
s/missed/miss ...
<xificurC>
is there a way to update an array position without accessing it twice? arr.(0) <- arr.(0) + 1
<Drup>
xificurC: "let map_idx f a i = a.(i) <- f a.(i) in map_idx arr 0 ((+) 1)" :D
<ggole>
You could write array_incf
<ggole>
Er, incr. Excuse the lisp.
<Drup>
messed up the order of arguments
<xificurC>
that was an example snippet only. The point was if there is a way to do that *without* accessing the index twice. I guess it doesn't matter though right, array index lookup is constant
<ggole>
You want to avoid the bounds check?
<xificurC>
ggole: nah, I was just thinking of the Hashtbl example I brought up a couple days ago
<xificurC>
I was looking for an update/modify option that takes a function and handles the update with 1 lookup
<Drup>
as much as it makes sense for an Hashtbl, it doesn't for an array
<ggole>
Hmm, arrays are dense so you don't typically have the empty case to worry about.
<ggole>
Just a modify (like Drup wrote) is enough
<Drup>
except if you want atomicity
<Drup>
but it doesn't matter in OCaml at the moment, since you don't have parallelism and concurency is bigger grain
<xificurC>
I think I was really just looking for the correct idiom
<xificurC>
should have asked 'is this idiomatic' I guess..
* xificurC
apologizes and hides in the corner
<ggole>
It's a reasonable question.
<ggole>
I think usually you would just write the a.(i) <- a.(i) + 1, at least in simple cases.
nojb has joined #ocaml
nojb has quit [Client Quit]
<xificurC>
ggole: thanks. 1 more idiom question - I am writing a function that takes a list and should return a subset of it or none if there isn't a subset that satisfies a test. I guess you could say it's a sort of filter. The question - should it return list or list option
<nullcat>
you can say none is "[]"
<nullcat>
i suggest option
<ggole>
I would just return a list
<nullcat>
because a subset can be empty and if none is also represented using "[]", there will be ambiguity, i guess?
<ggole>
Yeah: Some [] doesn't seem to give any useful information
<xificurC>
nullcat: ambiguity won't happen
<nullcat>
because that subset is always non-empty ?
ontologiae has quit [Ping timeout: 272 seconds]
<xificurC>
nullcat: yes
<nullcat>
then list is just fine...
<xificurC>
thank you both
ggole has quit []
swgillespie has joined #ocaml
djellemah_ has quit [Ping timeout: 245 seconds]
asQuirreL has joined #ocaml
mcc has quit [Quit: This computer has gone to sleep]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<reynir>
mcclurmc: I don't think it's too useful for this project, though, since I don't think you can match on both if expressions with and without else clauses
<Drup>
indeed, you can't
<Drup>
well, actually, you can, just by creating two pattern
<Drup>
but you can't do both
rgrinberg has joined #ocaml
<reynir>
Yea
<Drup>
actually, matching against the general form should do
<reynir>
Oh, yea?
<Drup>
yes, it's desugared
<reynir>
awesome
<Drup>
huum, actually no
<Drup>
you can't, sorry, false alarm :)
<Drup>
the parsetree for "if x then ()" and "if x then () else ()" is different
<rgrinberg>
shouldn't there be some ocsigenserver call for doing this already?
swgillespie has joined #ocaml
<Drup>
don't know :/
struktured has joined #ocaml
freling has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 264 seconds]
<companion_cube>
flux: only the online help can help you find in which containers.foo is a module
<companion_cube>
flux: besides, printBox is not utf8 aware but iirc there is a way to set how to compute the length of a string
<rgrinberg>
Drup: is there a better way to spend your sunday then to find out ;)
<companion_cube>
o/ rgrinberg
<rgrinberg>
companion_cube: we're still picking away at this T_T
<companion_cube>
flux: if you need something more ambitious, I think lambda-term is the answer
<Drup>
rgrinberg: grading programming projects because my last class with my students is tomorrow
<Drup>
companion_cube: lambda-term is always the answer :D
<companion_cube>
nah, not for one-liners
<rgrinberg>
Drup: anyhow, i'm gonna use dino's utility for now
<rgrinberg>
one step forward, two step backwards...
<companion_cube>
I didn't read IRC this weekend, what's this about?
<Drup>
companion_cube: ocsigen cohttp
<Drup>
it's not really new
<rgrinberg>
yeah, i think last time i saw you on irc i was busy doing the same thing
<companion_cube>
ah
<struktured>
does anyone happen to know how to inspect the entire error of highlighted row in vim/merlin? It cut off on me, forcing to build to see the problem anyhow.
<jcloud>
try :Errors
<jcloud>
I think that works but I am on my phone right now
<struktured>
that magic worked. thanks!
<jcloud>
cool!
badon has quit [Quit: Leaving]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Gama11_ has quit [Remote host closed the connection]
tane has quit [Quit: Verlassend]
badon has joined #ocaml
<struktured>
ah sweet satifisication, through use of map, bind, and apply infix operators, I have no parentices now in my function implementation :).
<struktured>
take that lisp!
Simn has quit [Quit: Leaving]
<reynir>
:o "true" is not a constant in the ast
<Drup>
reynir: I'm going to blow your mind
<Drup>
type foo = true of bool ;;
<Drup>
true true ;;
<Drup>
struktured: after pointless programming, now paren-less programming :D
struktured has quit [Ping timeout: 264 seconds]
<reynir>
haha wow
<Drup>
I can do worse for you
bjorkintosh has quit [Remote host closed the connection]
<Drup>
type thing = :: of bool list * thing | true ;;
<Drup>
[] :: (true :: []) :: true ;;
<rgrinberg>
Drup: what's this ocsigen_generate module and why does it have cohttp converters
<struktured>
Drup: yeah I was reminded of pointless programming while looking at my code, although I doubt there's any fundamental connection between the two really :)
<Drup>
rgrinberg: well, the first two make sense
<Drup>
the last one, eeh
nullcat_ has joined #ocaml
matason has joined #ocaml
<rgrinberg>
Drup: wtf people catch invalid_argument O_O
<rgrinberg>
Drup: anyway, my 2 pr's should address jerome's 2nd and 3rd check boxes.
<rgrinberg>
let me know how it goes integrating dinosaure's stuff
<Drup>
There is a special kind of hell for this people
<rgrinberg>
i have no idea about that but will have a look if you're struggling
matason has quit [Client Quit]
Algebr has joined #ocaml
<Drup>
right next to people taking in theaters.
<Drup>
these*
<rgrinberg>
i'll address checkbox 4 later since there's way more dead code than just the awake stuff
<Drup>
rgrinberg: nice, thanks
<Drup>
I'll read and merge later on
<rgrinberg>
Drup: yeah, once dinosaure appears (any day for a blue moon now)
<rgrinberg>
we can catch up with him
shinnya has joined #ocaml
<reynir>
Drup: so I guess it's not really possible to match on true in ppx and be sure it's the boolean?
<Drup>
yeah
<Algebr>
It feels like writing modules signatures and is redudant. For example, why do I have write the same things about modules in both the mli and ml
<reynir>
Algebr: Lwt_io_ext.sockaddr_of_dns is from Websocket
<reynir>
(way too late heh)
<Algebr>
Oh thank you! I ended up making the socket itself, which was more annoying.
<Algebr>
rgrinberg: do you use this
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<nullcat_>
say i want to use a number of type definition defined in A.ml in B.ml and C.ml. Is putting those definition in a separate file called "s.ml", and doing "include (module type of S)" better?
<reynir>
I was just playing around with websocket the other day and stumbled upon the same :)
<nullcat_>
or is explicitly writing A.t A.tt A.ttt better?
<Algebr>
It would be nice if the example code in /example actually worked out the box
swgillespie has joined #ocaml
<reynir>
which /example?
<Drup>
nullcat_: I don't understand the question
<nullcat_>
type t = ... type s = ... type z = ... are defined in A.ml
<nullcat_>
B.ml and C.ml need to use these type definition
struktured has quit [Ping timeout: 246 seconds]
<nullcat_>
is there any better way than "open A" or explicitly labeling like "let f x:A.t = ..."
<Drup>
why would you want better ?
<Drup>
I'm not even sure what "better" is
<nullcat_>
um ...
<Algebr>
I found that websocket issue in the source code for websocket
<nullcat_>
never mind...
Cyanure has quit [Remote host closed the connection]
sepp2k has quit [Quit: Leaving.]
badon has quit [Quit: Leaving]
ontologiae has quit [Ping timeout: 264 seconds]
Submarine has quit [Remote host closed the connection]
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 276 seconds]
Tekilla has joined #ocaml
Erylisia has joined #ocaml
m4b has joined #ocaml
<Algebr>
Is it possible to extend records?
<m4b>
I'm having an issue with open polymorphic variants, a string map, and a ref cell; I'm not even sure if what I'm trying to do makes sense, but suppose I have a simple polymorphic variant [ `Name of string ]; now, let's suppose I have a string map SMap = (Map.Make(String); let's also suppose that I add [`Name of string ] objects, but also sometimes [`More of int]; so I want my map to be at least: [> `Name of string] SMap.t; now suppose I
<m4b>
want a ref of this map, is this possible?
Kakadu has quit [Remote host closed the connection]
struktured has joined #ocaml
<Algebr>
why can't I do module Make (S: Foo) : Bar with let something := S.value = struct ... end
ontologiae has joined #ocaml
<Drup>
"let something := .." doesn't mean anything
<Drup>
either change in = or remove the let
<Drup>
actually, a let here doesn't mean anything period, so you'll have to change things
<Drup>
what do you want to express ?
<Algebr>
I have a module which I want to parameterize with a value
<Drup>
that part is fine, I'm wondering about the "with ..." part
<Algebr>
the module has a value that I want to be setting
<Drup>
then do it inside struct ...end
<Algebr>
Then what is the purpose of the thing I was using, the with part
ontologiae has quit [Ping timeout: 264 seconds]
<Drup>
typing constraints
<Algebr>
Why do this
<Drup>
if you want to expose the fact that Bar and Foo share some type equalities, for example
kdef has joined #ocaml
mengu has quit [Remote host closed the connection]
rand000 has quit [Quit: leaving]
<m4b>
so is it correct to say that an open polymorphic variant cannot be the value for a map in a mutable object?
ontologiae has joined #ocaml
<Drup>
m4b: I just re-read your message. I don't see any issue with what you want to do, except that you can't have subtyping
<Drup>
you must fix the type of the content of the reference
<m4b>
Drup: give me a bit to create an example; maybe i'm just incorrectly typing the values
<m4b>
what does the type reference look like then?
ontologiae has quit [Ping timeout: 246 seconds]
<Drup>
Something without < or > in the type
javamonn has joined #ocaml
<m4b>
yea but that's explicitly what i said i required
<m4b>
a polymorphic variant for the value's type in a map can't be a mutable object
<Drup>
Not really, no
<Drup>
you said you wanted to put two things in your map
<Drup>
that's different, you can do that just fine, [ `Name of string | `More of int]
<m4b>
yes, and I said I wanted the type of the map to be [> `Test of int] SMap.t
<m4b>
sorry, [> `Name of string] SMap.t
<Drup>
just use a bigger type of that
<m4b>
?
<Drup>
[ `Name of string | `More of int] SMap.t
<Drup>
you can't mix subtyping with mutability, for very good reasons (it's unsafe almost instantly)
<Drup>
of if you really want to take a reference of something like that
<m4b>
is a polymorphic variant subtyping? I didn't think it was, just open types, as opposed to closed types
<Drup>
it's subtyping, yes
<Drup>
well, it can be :p
<Drup>
if you use variant types with < and >, there is some subtyping involved
<Drup>
if not, then no.
<m4b>
well, i didn't think open types was a form of subtyping, i thought it was closely related, like variants are to records, as polymorphic variants are to objects
<m4b>
in any event, so you're saying it's not possible?
<Drup>
I'm saying you should specify your type correctly
<m4b>
[> Name of string] SMap.t is a correct typing
<m4b>
it just won't type check when it's mutable, is what i was asking
madroach has quit [Ping timeout: 264 seconds]
<Drup>
sure, and it's a subtype of [ `Name of string | `More of int] SMap.t, which you can put in a ref, as I said.
<m4b>
yea, hmmm
madroach has joined #ocaml
<m4b>
the reason this is coming up is i have a map, what has at least a base type, which are then extended by different modules; because the map's type is open, it can be extended fine; but now i need to cache the map every time it's accessed (i marshall it to and from disk, and it's huge, so I want to marshall it back once and be done); i was going to do this witha singletonesque pattern, but now it seems like this can't be done unless I
<m4b>
specify beforehand all of the possible variant types
<m4b>
however this seems to break the purpose of extending the base type, as now for every new extension, say in different modules, i have to g back to the map type declaration and update it :(
<Drup>
you will have the same issue with marshal
<Drup>
imagine someone extends the map
<Drup>
with completely new poly variant
<m4b>
ok
<Drup>
and then someone else uses it, by using your ref and/or by using a marshalled version
<Drup>
but don't know about the new poly variant
<Drup>
you might have a tiny bit of a an issue.
<m4b>
so, yea, if someone adds new functionality, then the new map would have to be remarshalled; but i have simple metadata associated with the map, say a version
<Drup>
then if you have versioning, why are you using polymorphic variant to begin with ?
<m4b>
the only time this would happen is new functionality is added, say a new module, and the user recompiles, or receives an update of the program
<Drup>
just use normal variants
<Drup>
no, it's not the only time it would happen
<m4b>
how else could it happen?
<Drup>
I link against your code and I change the reference to another map with a brand new poly variant that I defined
<nullcat_>
say in A.ml I have "type t = Yes of int [%%deriving yojson]". and in A.mli, do I need to explicitly write "type t = Yes of int;; val to_yojson : t -> Yojson.Safe.json;; val of_yojson : Yojson.Safe.json -> [> `Error of bytes | `Ok of t ];;"
<Drup>
nullcat_: "type t = Yes of int [%%deriving yojson]" is valid in the .mli
<Drup>
(and will do what you expect)
<m4b>
i don't return the reference in my code, only the deref's object
<nullcat_>
so just derives out the type definition? cool.
struktured has quit [Ping timeout: 256 seconds]
<nullcat_>
this is what i want..
<Drup>
m4b: then why are you using poly variants ?
<Drup>
it seems it's only inside your code
<Drup>
just define a proper variant
<m4b>
Drup: because I don't want the map to know about the different implementations of the modules, how they extend, and how they print
<Drup>
the map doesn't need that
<Drup>
it's polymorphic over its values
<m4b>
I want the map to simply say, all elements must have at least these features; returned objects can then be dealt with by a per implementation basis
ontologiae has joined #ocaml
<m4b>
not as soon as you add an element; then it's fixed
<Drup>
sure, but the implementation of the map still doesn't know anything about them
<m4b>
so the code for building the map goes: match x with | OneThing x -> ..perform implementation specific work.. return map with polymorphic variants | OtherThing o -> ..perform implementation specific work.. return map with polymorphic variants
kdef has quit [Quit: Leaving]
<m4b>
right now, if i changed the map's value to a closed variant, then if one implementation wants to use the map's values, say in a query, it has to know about the other implementation; this seems like it will lead to a build cycle
badon has joined #ocaml
<Drup>
I don't know enough about your whole application to answer that
<m4b>
hmmm
<Drup>
but I do feel like you are trying to fit the OO idiom of "let's put everything answering this baseline interface into a container and upcast at the boundaries"
<Drup>
which is usually something you can completely avoid
<m4b>
Drup: i could very well be doing that
ontologiae has quit [Ping timeout: 272 seconds]
<m4b>
but i'm not so sure
<Drup>
so, back to your answer, yes, you can use a ref, if you "close" the polymorphic variant
<m4b>
i'm going to release the project on github soon, as soon as the program is perfect ;), so maybe i can point it out more clearly then
<Drup>
but you can't let it open
<m4b>
yea, ok.
<Drup>
because it's unsafe to do so, because of the reason I pointed about adding new polymorphic variant that the other people don't know about
<m4b>
hmmmm; the only way around i can see is calling the map, and passing it in as parameters instead of pushing it into a ref
<Drup>
and marshalling will produce the same issue
<m4b>
so, what would happen if you did do that? if i marshall to disk, then unmarshall to a map with an extra polymorphic variant; i don't see how that would cause a problem?
<m4b>
if you put a value with that extra polymorphic variant, then marshalled back to disk, then another person marshals back it will crash, is that it?
<Drup>
yes
<m4b>
oh yea, fuck ;)
<Drup>
the crash is going to be either an unmatched pattern matchin or a segfault, not sure
<m4b>
only seen ocaml segfault when turning off index array bounds checking
<Drup>
or when doing unsafe things with marshall :]
<m4b>
yea; but that's pretty awesome when you stop to think about it!
javamonn has left #ocaml [#ocaml]
systmkor has quit [Ping timeout: 245 seconds]
<m4b>
i'm going to have to think about what to do; might have to do some major refactoring
<m4b>
the problem is that all objects in this map have to have specific values; but some have more, and it's nice to print them when they do; i thought it was a good use case for poly variants, but starting to become problematic
<nullcat_>
Lwt_stream has "val from : (unit -> 'a option Lwt.t) -> 'a t", but what if I want to change (redefine) the behavior of the function that will be applied next time based on the thing I retrieve from the pipe