<_y>
ie· types such that « ∀α. α → ∀β. β → (α × β) » would be available, and could be inferred instead of « ∀αβ. α → β → (α × β) »
<_y>
changes nothing from the logical side, but allows to work around the value restriction
<mrvn>
_y: all I see are ?
<_y>
mrvn, enlarge your unicode
<_y>
... [forall a. a -> forall b. b -> (a * b)] ... [forall a b. a -> b -> (a * b)]
<mrvn>
what's the difference between the two?
jeffmo has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<_y>
partial application
<_y>
because of the value restriction
<_y>
in the first case, partial application would give you a non-polymorphic function
<_y>
in the second case, you would still have polymorphism on the type variable b
<mrvn>
So you would have to choose a "b" when you apply "a". got it
jeffmo has quit [Client Quit]
AlexDenisov has joined #ocaml
octachron has joined #ocaml
loocash has joined #ocaml
loocash has quit [Client Quit]
<def`>
_y: records/objects provide universal quantification, so yes, that's encodable
<_y>
indeed, but then why isn’t it directly available?
<_y>
let f a b = a, b
<_y>
against
<_y>
let f a = object method v : 'b. 'b -> _ * 'b = fun b -> a, b end
BitPuffin|osx has joined #ocaml
tennix has joined #ocaml
<ggole>
Inference doesn't really work once you have polymorphic arguments - the usual approach is to require annotations
<beginner>
I am trying to install menhir on windows, but it fails with "Cannot find oamlbuild.cmo in ocamlbuild -where directory. But when calling ocamlbuild -where i get the right folder with the ocamlbuild.cmo file
tennix has quit [Client Quit]
<ggole>
It *would* be nice if that were possible directly rather than going through the record/object.
<beginner>
Is this a question suited for the ocaml mailing list?
<gasche>
beginner: that sort of sounds like an environment setting issue
<gasche>
which version of OCaml are you using and how was it installed?
<beginner>
gasche: i have installed it from source, OCaml 4.03.1
<gasche>
_y: note that rank-1 polymorphism is much less expressive than what you get through explicit annotations in OCaml, as you cannot have a forall quantifier as a function argument type
<beginner>
gasche: OCamlbuild was also installed from source
<gasche>
I don't think there is a 4.03.1 version?
<gasche>
_y: also, the type grammar given in the SML# document has the problematic downside that there are no principal types anymore unless you introduce a Feta-style subtyping relation
<beginner>
gasche: if i start the ocaml interpreter i get "OCaml version 4.03.1@
<gasche>
hm
hcarty has joined #ocaml
<gasche>
beginner: out of curiosity (that's probably unrelated to your problem), where did you get this source archive?
<beginner>
gasche: i cloned the official ocaml git repo
<beginner>
and build branch 4.03
<gasche>
ah, so it's not a released version
<gasche>
and which Menhir version are you using?
<beginner>
20160526
<beginner>
gasche: how can i get the source for the official released 4.03 version?
<gasche>
but I think using the tip of the 4.03 branch is not the source of the issue, and it should mostly work
<gasche>
so which build command are you using for menhir?
mattrepl has joined #ocaml
<beginner>
i just call make with the install prefix USE_OCAMLFIND=false and some make variables pointing to my install folder of ocamlbuild
unbalancedparen has quit [Ping timeout: 276 seconds]
<gasche>
note that if you don't care which ocaml version you use, 4.02.3 probably has an easier menhir installation story, as ocamlbuild is distributed with the compiler
<gasche>
ah
<gasche>
I think there may indeed be a Windows-specific issue in ocamlbuild
<beginner>
no it has to be 4.03
<beginner>
want to have flambda :)
<gasche>
could you test calling Filename.is_implicit on the output of (ocamlbuild -where) on your machine (in an ocaml toplevel)?
<_y>
gasche, yes, i know that rank‐1 is limited; i’m asking because the base ocaml is limited to rank‐1 to keep type inference decidable (i’ve been told — at least rank‐3 is undecidable)
<gasche>
well
<gasche>
OCaml let you express higher-ranked polymorphism, but it is more verbose
<gasche>
I'm not convinced by SML#'s particular choice, which does not give you much extra expressivity, and endangers principality
<gasche>
but it would be interesting to see the concrete cases where they found this useful
<gasche>
(*relaxed* value restriction may sound minor and uninteresting as well until you notice how useful it is in practice)
<_y>
and if we can scratch a bit this ground while staying under rank‐1, well why not
<beginner>
gasche: what does it tell? i am reinstalling ocaml right now
<gasche>
well their extension already hurts inference
<gasche>
beginner: I don't know, I wonder what it tells on your machine
<_y>
but you gave me a convincing reason why not
<gasche>
I think it may be possible to recover principality with a restricted subtyping relation that remains decidable
<gasche>
hm
unbalancedparen has joined #ocaml
<gasche>
that may be possible in Daan Leijen's relaxations of MLF as well
<gasche>
(namely in HML)
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<gasche>
beginner: you should file an issue on https://github.com/ocaml/ocamlbuild/issues to explore the problem further and not bother IRC people with back-and-forth debugging
<gasche>
I believe that this is an ocamlbuild+Windows issue rather than a Menhir-specific issue
<beginner>
gasche: you are right, if i can not fix it very soon i will file an issue
<gasche>
please try that (Filename.is_implicit <output of ocamlbuild -where>) thing; if it says "true", it's the cause of the bug
AlexDenisov has joined #ocaml
dexterph has quit [Ping timeout: 272 seconds]
NingaLeaf_ has joined #ocaml
malc_ has joined #ocaml
Sorella has quit [Quit: Connection closed for inactivity]
darkf has quit [Ping timeout: 246 seconds]
slash^ has joined #ocaml
malc_` has joined #ocaml
malc_ has quit [Ping timeout: 264 seconds]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Unb3kannt has joined #ocaml
Unb3kannt has left #ocaml [#ocaml]
AlexDenisov has joined #ocaml
al-damiri has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
malc_`` has joined #ocaml
malc_` has quit [Ping timeout: 240 seconds]
govg has quit [Quit: leaving]
<gasche>
octachron: do we both agree that the "partial fix" in your PR is mergeable now, instead of waiting for a perfect fix?
<octachron>
gasche, yes: the partial fix are the minimal fix needed to make the manual build again
<octachron>
they are partial because there are still bugs/crashes lurking around in the ocamldoc code
<octachron>
I may have more complete look later this week or open a mantis ticket on the subject
<gasche>
I'll run the testsuite and merge, thanks
zpe has quit [Remote host closed the connection]
bobry has joined #ocaml
yomimono has quit [Ping timeout: 260 seconds]
malc_`` has left #ocaml ["ERC (IRC client for Emacs 25.0.50.2)"]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dario2 has joined #ocaml
<dario2>
Hallo everyone! I would like your opinion on ZeroMQ vs Nanomsg...
<dario2>
There's OCaml bindings for both...
<dario2>
I know both projects had their fair share of drama...
<dario2>
But I'm not up-to-date with the latest gossip...
<dario2>
Nanomsg has finally released 1.0 after a much publicised controversy surrounding the quitting of its founder...
<dario2>
Nanomsg has a superficially nicer API, but which project would you guys trust more?
<dario2>
I'm especially interested in hearing opinions from people who have used both.
<mrvn>
the ocaml bindings I tried segfault ocasionally
<mrvn>
for zmq
<dario2>
mrvn: And the problem was for sure with the bindings?
<mrvn>
dario2: can't be with ocaml. it doesn't segfault.
<mrvn>
No Obj.magic or unsafe_* used
<dario2>
mrvn: I mean what if the problem was in ZMQ itself?
hcarty1 has joined #ocaml
<mrvn>
dario2: does that make a difference?
rgrinberg has quit [Ping timeout: 244 seconds]
<Bluddy[m]>
mrvn, dario2: have these bindings been kept up to date?
<dario2>
mrvn: Well, in theory it's a lot simpler to fix the bindings...
<dario2>
There's fairly recent updates on Github, so I guess they are still maintained...
<mrvn>
python zmq bindings crash too but I suspect pyside, which is also used) there. Only the GUI cliend segfaults.
<dario2>
mrvn: Have you tried (o)nanomsg?
<mrvn>
no
<dario2>
They're both nice, though API-wise I lean towards nanomsg...
ygrek_ has joined #ocaml
<dario2>
However, I'm not sure how actually stable it is...
hcarty has quit [Ping timeout: 258 seconds]
<mrvn>
zmq's biggest problem is that you don't see when a peer goes away.
<mrvn>
and when they reconnect you have package loss
<mrvn>
if they reconnect
<dario2>
mrvn: I'm not sure how nanomsg handles that situation...
<mrvn>
not handling is fine. just tell me about it
mattrepl has quit [Quit: mattrepl]
<tormen>
Hi. How can I define a polymorph type with 2 type variables ? This fails: type 'a 'b db_context = (db_conn * 'a list * 'b option)
<ggole>
('a, 'b) t rather than 'a 'b t
<tormen>
ggole: cool, thanks !!! :)))
<tormen>
gasche: ... i'll send you a mail ;) ... btw. did you find my last one useful ? because I don't want to spam you :)
copy` has joined #ocaml
ygrek has joined #ocaml
ygrek_ has quit [Ping timeout: 252 seconds]
<gasche>
tormen: yes (although I haven't acted on it) yet, don't worry
dario2 has quit [Quit: Konversation terminated!]
ggole has quit [Ping timeout: 276 seconds]
<tormen>
gasche: ok, just wanted to double-check . No problem of course for any delay of treatment :))
* tormen
is extremely excited, just trying to put in place his first monad :))
<mrvn>
I so whish one could have 'a 'b t
<tormen>
mrvn: you mean as equivalent of / instead of ('a, 'b) t ? (so with the same meaning?)
<mrvn>
tormen: no, not equivalent. Has higher order type.
<tormen>
mrvn: hmmm. like f(x) vs. f(x,y) ? ... but in this context I fail to grasp the consequences... (yet ;)) ... maybe one day :))
<mrvn>
tormen: as in type 'a 'b t = 'a 'b for e.g. a functor.
AlexDenisov has joined #ocaml
<tormen>
hmmm... sorry^^ (still not explicit enough for me) but don't worry. I am a happy camper, not to undstand everything :)
<mrvn>
tormen: say you want something tow work with both int list list and int array list
<tormen>
mrvn: ok, then I would use (int * list * list) ... ?
<mrvn>
where is the array in there?
<tormen>
... I mean (int * 'a * list)
hcarty1 has quit [Quit: WeeChat 1.5]
<tormen>
but then 'a can be ANYTHING
<tormen>
... but how dows the 'a 'b thingy help me here ?
<mrvn>
tormen: let empty = ([] : int 'a)
<mrvn>
tormen: or how do you specify the type of empty for the mli file?`
<tormen>
hmmm...
<mrvn>
nowadays you would use a first class module defining type 'a container and some getter and setter functions.
ygrek_ has joined #ocaml
<mrvn>
or use objects
<mrvn>
but it all adds an extra abstraction.
<tormen>
let empty = ([] : int 'a) I am not sure what that does :(
mattrepl has joined #ocaml
<tormen>
[] is a pattern ? "int 'a" is a type ?
<mrvn>
tormen: that would be the empty list of int containers
TheLemonMan has joined #ocaml
<mrvn>
both [1] :: empty and [| 1 |] :: empty would work if int 'a where possible.
ygrek has quit [Ping timeout: 260 seconds]
<tormen>
ah so you are defining that "[]" will mean "int 'a" empty list ?
<mrvn>
that would be the idea
<tormen>
hun
<tormen>
okey I think now I got a GLIMPSE of understanding what you mean :)))
<tormen>
... thanks !!!
rgrinberg has joined #ocaml
<tormen>
... even though I still need time to "GRASP" :)) ..... but it's like with my MONAD I am building... I had this glimpse of an idea/understanding since a while and ... sort of prepared stuff ... and now I am doing it :)) ...
<tormen>
When is Ocamls birthday ?
<mrvn>
give me callcc (and ocaml can't :( ) or keep your monads
<tormen>
... critized by Oleg Kiselyov... not that I would understand what he is saying though ^^
<gasche>
there are known correspondence between monads and delimited continuations (although usually not call/cc itself)
<gasche>
correspondences
<gasche>
but anyway that shouldn't be of concern to you if you're trying to practice monads
<tormen>
gasche: :)) my thought too :)) ... another time!
<tormen>
Hmm. If I have a function f that takes "int option" as parameter and I KNOW that it should be SET when calling f, can I then write : let f (Some x) = ... ?
* tormen
is launching his utop :))
<tormen>
hun. Only a ... Warning 8: this pattern-matching is not exhaustive. .... so possible, but of course not recommended...
<gasche>
exactly
<tormen>
:D
<gasche>
note that if you know the parameter is set, you can always take an (int) instead
<tormen>
yes... but in my super-Monad I am handing along a tuple and in there it is not always set... I pattern match in the function for now :)
mattrepl has quit [Quit: mattrepl]
pierpa has joined #ocaml
w1gz has quit [Quit: WeeChat 1.4]
Sorella has joined #ocaml
jonasen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
octachron has quit [Quit: Leaving]
<Bluddy[m]>
tormen: what I would do in this case is have an 'unwrap_some' function that matches on Some and throws an exception on None.
<tormen>
Bluddy[m]: hmm. yes :) .... thanks! I'll keep that in mind :)
<tormen>
... monads are so fun ... now I am building functions that output functions that I then bind...
* tormen
is just hoping that ocamlc will agree with my mental construction ;) ...... oh oooh ^^
<tormen>
s/my/his/
<tormen>
how expensive (or cheap) is sprintf over ^ String concatenation ? like when I have "["^foo^"]" do I better write (sprintf "[%s]" foo) ? .... maybe a silly question, but I just wonder how good/bad sprintf's are (in general) ?
rgrinberg has quit [Quit: WeeChat 1.5]
rgrinberg has joined #ocaml
<mrvn>
tormen: for longer text or more ^ use sprintf
<mrvn>
does ocaml optimize the two ^^ into a single allocation and copying?
<mrvn>
+or
<gasche>
no
<gasche>
but it's easy to write (String.concat ["["; foo; "]"]) instead
<tormen>
which would be better than the ^^ ?
<gasche>
yes
<gasche>
hm
<gasche>
I don't know if you are talking about (^) or (^^), but in the former case, yes
<gasche>
sprintf is asymptotically (with lots of strings) as good as String.concat, but it's slower for a small number of strings
<gasche>
(it uses a buffer internally)
<mrvn>
gasche: x ^ y ^ z
<tormen>
:) yes former case 2* ^
<mrvn>
gasche: doesn't sprintf do a dry run computing the length, then allocate string and print?
<flux>
seems like it would be a decent idea to als put the constructed substrings into a list?-o
<mrvn>
if not: a buffer or Buffer.t?
<gasche>
it uses Buffer.t
<gasche>
currently
<gasche>
I think that if you have just string, accumulating into a list might be more efficient
* tormen
looks for popcorn while reading the cool exchanges in consequence of his simple question .... thanks guys! sooo cool :)
<gasche>
but when you also have int and chars, this is less clear
<gasche>
hm
<mrvn>
gasche: Buffer.t can use a larger buffer and fill it up bit by bit. should have less allocations.
<gasche>
less than repeated concatenation with (^), certainly
<gasche>
as I said, it's asymptotically good
<gasche>
but it might still not be as fast as String.concat on small sequences
<mrvn>
sprintf might also be easier to read
<gasche>
(because of the resizing check and all)
<gasche>
yep
<gasche>
flux, mrvn: it should be rather easy to implement a version of sprintf that precomputes a size instead of using Buffer
<gasche>
if either of you is interested in giving it a go
<gasche>
the function you would have to implement is a counterpart of (strput_acc) in stdlib/camlinternalFormat.ml
<gasche>
(which currently puts everything in a buffer argument)
<tormen>
gasche: waoh you really now ocaml well :))
<mrvn>
is it using GADTs now?
<tormen>
gasche: thanks for your answer(s) !! :)))
<tormen>
s/now/know/
<gasche>
tormen: you're welcome
<gasche>
mrvn: yes
<mrvn>
gasche: one could also use a rope
<mrvn>
collect all the strings in a list and then sum up the length and copy
<gasche>
hm
<gasche>
usually "rope" refers to something else than just a list of strings
<tormen>
a rope ... it's the 2nd time I read that... what is a "rope"? like a (new?) data type ?
<mrvn>
(Rope.add all the % strings and Rope.to_string at the end)
<tormen>
hm
* tormen
is asking google for ocaml rope :)
<mrvn>
tormen: simplified a list of fragments (strings)
<gasche>
ropes are a list-like data structure with fast concatenation used in some implementations of repeated string concatenation
<mrvn>
tormen: yes, we do want to hang ourself :)
<gasche>
(and also persistent)
<gasche>
(suicide jokes are meh)
<gasche>
so (sprintf) already builds a list of fragments to output
<gasche>
copying into a list of strings would be costly and unecessary
<gasche>
it's better to iterate-and-sum and then iterate-and-blit on the accumulator structure directly
<gasche>
(in particular you never need to convert each single char in the accumulator into a string)
<tormen>
gasche: you also type extremely fast...
<mrvn>
gasche: depends. computing the size of %something can be as costly as creating the string.
<tormen>
no strings and ropes attached :) ... hehe. Thanks !
<gasche>
I'm not sure how you would measure the performance difference however
<gasche>
ocamldoc's html output uses sprintf a lot, it may be a good macro-benchmark
<gasche>
(hm it also uses a lot of string concatenations...)
nalgeneus has joined #ocaml
<tormen>
if I call for instance (List.length l) two times in two consecutive lines, will ocaml call it only once ? and/or should I prepend a "let l_length = List.length l in" and then use l_length ?
<gasche>
it will call it twice
<gasche>
there is very little magic in OCaml's evaluation order, it mostly does as you say
<tormen>
gasche: ok good to know :) - thanks :)
<mrvn>
tormen: List.length could have side effects
<tormen>
mrvn: *dough* sure ... ^^
<mrvn>
asmanur: In c++ the first error is often 10 pages long. There is enough there to keep the mind busy. :)
<mrvn>
ups,
manizzle has joined #ocaml
rgrinberg has quit [Read error: Connection reset by peer]
<cheater>
tormen: it will call only once if the function has been memoized
slash^ has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
Kakadu has joined #ocaml
<flux>
ocaml doesn't do that kind of memoization automatically, though
<flux>
as I understand, so doesn't even Haskell in some (most?) cases by default, apparently it has bad implications in memory management and reachability
tobast has quit [Ping timeout: 244 seconds]
AlexRussia has quit [Ping timeout: 272 seconds]
mattrepl has joined #ocaml
tobast has joined #ocaml
agarwal1975 has joined #ocaml
shum has joined #ocaml
sdothum has quit [Read error: Connection reset by peer]
<Bluddy[m]>
flux, tormen: haskell can do CSE (common subexpression elimination) to essentially create a new let binding for the length, since it has full effect information. Flambda should be able to do this as well potentially -- it's just not as easy since there's no effect information in the language. But if we annotate function signatures with effects, it'll be able to do it.
<flux>
..how likely is that going to happen?
<Bluddy[m]>
Flambda already does simple effect analysis, and there's plenty of work going into Flambda currently
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<flux>
I guess effect annotations have other benefits as well, because I really don't consider it worth the effort for just CSEing such expressions - you can extract the CS yourself where it matters for performance :)
<flux>
ghc wiki from year 2008 says "GHC doesn't actually perform CSE as often as you might expect. The trouble is, performing CSE can affect the strictness/laziness of the program. So GHC does do CSE, but only in specific circumstances --- see the GHC manual"
<flux>
things may have changed since :)
<Bluddy[m]>
Yeah who knows -- ghc is moving along so fast
<Bluddy[m]>
effects have tons of benefits
<flux>
expressiveness-wise?
<flux>
or "just" performance?
<Bluddy[m]>
optimization-wise
<Bluddy[m]>
performance
<Bluddy[m]>
effect annotations as part of the language also give additional correctness guarantees, but that's outside the scope of optimization passes
<Bluddy[m]>
and effect annotations that aren't linked to the type system can result in the wrong effects being calculated, which could cause wrong behavior
<Bluddy[m]>
so ideally they should only be created by FLambda itself
<Bluddy[m]>
i.e. not written manually
shinnya has quit [Ping timeout: 276 seconds]
rgrinberg has quit [Ping timeout: 244 seconds]
AlexRussia has joined #ocaml
nicholasf has joined #ocaml
sepp2k has quit [Quit: Leaving.]
rand__ has joined #ocaml
rgrinberg has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 276 seconds]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Denommus>
ocsigen allows FRP in the frontend using the React library (and that module that allows DOM elements made of signals)
<Denommus>
but does it support an FRP in the backend too?
mattrepl has quit [Quit: mattrepl]
nicholasf has quit [Remote host closed the connection]
nicholasf has joined #ocaml
<Kakadu>
AFAIU yes, but in the backend it is supported by OCaml (using React lib), not Ocsigen
orbifx has joined #ocaml
<Denommus>
kakadu: can I do something like a backend that feeds information reactively to the front-end whenever a change in the database is made, for instance?
<gasche>
Bluddy[m]: effect annotations are only necessary if you want to do CSE across information boundaries
<gasche>
you can actually do most of the work in a local fashion using inlining
<gasche>
(or any kind of cross-module optimization information)
<gasche>
hm
<gasche>
well I guess you would also need effect typing in the higher-order case of taking an unknown function in parameter
<gasche>
I'm not sure that's a common case of CSE requirement, though
<Bluddy[m]>
That's true. I thought that for example, for libraries, FLambda could annotate effects in the CMX, so that even without inlining, you'd get full effects knowledge. And yes so long as you're not enforcing it in the type system, you're going to have to generalize.
<Bluddy[m]>
So a data structure of functions must take the widest possible effect signature.
<Bluddy[m]>
But this is where inlining could really help -- you could specialize the code for a particular high-order application.
<gasche>
type information (or in general analysis summaries) make those optimizations more modular
<gasche>
but they're not a prerequisite to perform them, and in fact betting that the wins happen before that is often relatively reasonable
<gasche>
(for example OCaml doesn't use type information to optimize currified function applications, and yet in practice it works very reliably)
<gasche>
(from a language design / research perspective, I'm very interested in type systems for modular optimization, but from a practical perspective in OCaml we can get a lot of things before we need to go there)
Denommus has quit [Quit: going home]
<Bluddy[m]>
I think what you're saying is that many optimizations aren't really that important, and I generally agree. I remember reading one of Appel's books, and in the end he lists the performance advantages of most of his optimizations, and they were surprisingly minor -- which he helpfully pointed out.
<gasche>
I mean that for many programs making the optimizations *locally* suffices, you don't need optimizations during separate compilation
<gasche>
arity-raising, the optimization of currying, is super-important to get reasonable performances in a currified-by-default language; in OCaml it's made without type information and yet it works very well
<gasche>
(we could have a type system with explicit n-ary functions to make the optimisation modular, but we don't need to)
<Bluddy[m]>
I see
orbifx has quit [Ping timeout: 244 seconds]
<Bluddy[m]>
I guess the problem with effects is that they're not local properties. You have to explore the call tree all the way down to see if there's any effect there. So you either annotate (in the type system or outside of it) or you only reason about effects in a very limited manner, which is what FLambda currently does.
agarwal1975 has quit [Ping timeout: 240 seconds]
<Bluddy[m]>
Anyway, the big wins are with unboxing and type specialization -- anything to improve cache locality and reduce allocations. You don't need effects for that.
Kakadu has quit []
nicholasf has quit [Remote host closed the connection]
silver has quit [Quit: rakede]
sgnb has quit [Remote host closed the connection]
al-damiri has quit [Quit: Connection closed for inactivity]
A1977494 has quit [Remote host closed the connection]