<ollehar>
just saying, that unification step has to be done before any of the finished typed ast is delivered.
xyh has joined #ocaml
<companion_cube>
struktured: cool ^^
<companion_cube>
it's also useful for parsers, I suppose
<ollehar>
or: all unification steps.
<ollehar>
maybe I messed up those steps. :P
<ollehar>
I mean, delivering typed ast before unification is done completely.
<jun>
there are different flavors
<jun>
you can generate all the equations, and only unify at the end
<jun>
or you can unify while computing the typed ast
<ollehar>
ok
<jun>
(and you can have mutable fields in the ast)
<ollehar>
in my case, I have
<ollehar>
fn f l {
<ollehar>
a = l[0]
<ollehar>
b = a + 1
<ollehar>
return b
<ollehar>
}
<jun>
even if you can't read french, I think the ocaml type given in the above link may be useful
<ollehar>
where the function body is a list of statements.
<ollehar>
I'll have a look
solrize has quit [Ping timeout: 248 seconds]
antkong_ has quit [Quit: antkong_]
leowzukw has joined #ocaml
<ollehar>
off to work, thanks for your feedback, jun!
dwillems has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
dsheets has joined #ocaml
tmtwd has quit [Ping timeout: 248 seconds]
struk|desk is now known as struk|desk|away
dsheets has quit [Ping timeout: 276 seconds]
leowzukw has quit [Quit: Lost terminal]
<companion_cube>
struk|desk|away: please don't change your nickname when you're away :)
<struktured>
oh sorry thought I turned that off. will do so when I get back to my desk
<companion_cube>
sure
<companion_cube>
I'm considering providing a HAMT-like structure that has the same interface as List, too
<companion_cube>
so, a immutable vector
<companion_cube>
it's very common in clojure afaik
dsheets has joined #ocaml
leowzukw has joined #ocaml
<struktured>
interesting, seems like a useful data structure to have
<struktured>
it's somewhat surprising ocaml doesn't use it more often, based on it's popularity in other functional languages. I noticed haskell doesn't favor it either
<struktured>
well it does have "unorderd-containers" library
sepp2k has joined #ocaml
struk|desk|away is now known as struk|desk
julien_t has joined #ocaml
julien_ has joined #ocaml
<Leonidas>
companion_cube: basing on the work of phil bagwell?
<Leonidas>
I like them quite a bit, was also surprised why OCamls data structures seem so "basic"
<Leonidas>
I think the talk explaining them was my favourite part of EuroClojure 2015
solrize has joined #ocaml
yunxing has quit [Remote host closed the connection]
badon has joined #ocaml
Haudegen has joined #ocaml
Haudegen has quit [Ping timeout: 244 seconds]
julien_ has quit [Quit: Quitte]
julien_t is now known as picolino
<companion_cube>
in haskell they use fingertrees, I think
<companion_cube>
because lazyness and monoids, or whatever
<companion_cube>
(I mean, for the `Seq` type, iirc)
<flux>
ocaml-reins seems such an interesting initiative but it didn't really catch off.
Kakadu has joined #ocaml
<companion_cube>
flux: is it maintained? living on sourceforge is a big red flag for me
<flux>
I don't think so
<flux>
other than it has somehow ended up in opam
<companion_cube>
heh.
<mrvn>
companion_cube: hehe, HAMTs are basically cheating. They are O(|key|) but by hashing keys you make |key| a constant.
<companion_cube>
same as Hashtbl
<companion_cube>
in practice, it works extremely well
<companion_cube>
(I mean, Hashtbl is probably one of the data structures I use the most)
<companion_cube>
(and the standard ones are pretty fast)
<mrvn>
companion_cube: yure. but Hashtbl is array based, which you expect to have O(1) access. On the other hand for trees you expect O(log n).
<companion_cube>
I think I should use this random access list a bit more
<companion_cube>
mrvn: so what? :)
<mrvn>
companion_cube: so it's fun. efficient data structures are all about cheating :)
<companion_cube>
HAMT are basically O(log 64 >> k) for some k
<companion_cube>
ah, ok, yeah
<companion_cube>
cheating is good
<flux>
c++'s map has the problem of allocating memory for each node, so there can be quite many allocations a big map with small keys/values
<flux>
but I suppose ocaml is less sensitive to lots of allocations
<companion_cube>
you have less of a choice anyway
<companion_cube>
so, yeah
<flux>
and as ocaml cannot box arbitrary types in arrays, there's less benefit in memory management that way
<mrvn>
companion_cube: would you use a trie with fixed prefix lengths or dynamic?
<companion_cube>
I don't know, tries are not that fast in my experience
<companion_cube>
unless you talk about the hash trie that is a HAMT
<flux>
I haven't looked at hashtbl, but if it had say three arrays (key, values, value buckets) there could be benefits in the case of using small keys/values.
<companion_cube>
no, Hashtbl has a list of buckets for each slot, it's not flat
<mrvn>
companion_cube: I am. But the hashing just sits on top of it to evenly distribute keys.
<mrvn>
flux: keys are hashed and indexed modulo table size. They are always small.
<flux>
mrvn, the original keys still need to be stored (and allocated)
<mrvn>
flux: that's always one value in ocaml.
<flux>
yes, in ocaml it's less of an impact to allocate small values
<mrvn>
flux: are you considering something like float as key that would benefit from unboxing?
<flux>
well, why not though that sounds like a bad idea. let's say you need to map a million floats to million other floats, you have a lot of small allocations there.
<flux>
..but it's not really a big problem in ocaml I think
<flux>
in C++ it would be a different matter
<companion_cube>
floats are bad, m'kay?
<companion_cube>
you'd need arrays and imperative programming anyway, I think
<mrvn>
yeah. verry limited problem. Only floats, int32, int64, char, bool and unit have that problem.
<flux>
companion_cube, so I guess one could implement functional hash tables on top of HAMT then?-)
<companion_cube>
yes, that's pretty much what HAMT are designed for
<companion_cube>
functional hashtables and vectors
<flux>
how about creator/consumer byte buffers? too slow?
<mrvn>
works grate for sparse arrays too
<mrvn>
flux: map offset -> char?
<companion_cube>
flux: you mean functional byte buffers? no idea
antkong_ has joined #ocaml
<companion_cube>
(also, Hashtbl.Make(Int) is really fast when mutability is an option)
<flux>
I guess Queue of arrays is just fine
<companion_cube>
(like, really fast)
<flux>
(or Queue of bytes rather)
<Leonidas>
how is Hashtbl implemented?
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
<mrvn>
Leonidas: array of buckets (lists of key, value)
yunxing has joined #ocaml
AltGr has left #ocaml [#ocaml]
yunxing has quit [Ping timeout: 248 seconds]
ggole has joined #ocaml
badon has quit [Ping timeout: 252 seconds]
schive has quit [Quit: Leaving]
_andre has joined #ocaml
mcint has quit [Quit: hibernating...]
matason has joined #ocaml
matason has quit [Ping timeout: 264 seconds]
sfri has quit [Remote host closed the connection]
copy` has joined #ocaml
nicholasf has quit [Remote host closed the connection]
sfri has joined #ocaml
nicholasf has joined #ocaml
nicholasf has quit [Client Quit]
Vintila has quit [Ping timeout: 248 seconds]
antkong_ has quit [Quit: antkong_]
yomimono has quit [Ping timeout: 244 seconds]
antkong has joined #ocaml
<infinity0>
what's the preferred mechanism for doing timeouts in ocaml?
<companion_cube>
depends, are you using lwt?
<mrvn>
select
<infinity0>
i'm not using anything concrete right now, just exploring possibilities. i guess i would probably use lwt for the rest of the code though.
<infinity0>
mrvn: which module is that in?
<flux>
Unix
<companion_cube>
if you use lwt, then it's something like Lwt_unix.sleep
antkong has quit [Quit: antkong]
<companion_cube>
otherwise you'll probably need some multithreading and, indeed, select
<infinity0>
ah ok thanks. i was hoping for a stronger pure/impure separation but nvmd
<infinity0>
also, by "timeout" i meant "if now > t and Y then P else Q", as opposed to interrupting an ongoing computation
ggole_ has joined #ocaml
<companion_cube>
oh, well, you can measure time using Unix.gettimeofday, or the library oclock...
ggole has quit [Ping timeout: 250 seconds]
AltGr has joined #ocaml
mcint has joined #ocaml
teiresias has joined #ocaml
AltGr has left #ocaml [#ocaml]
BitPuffin has joined #ocaml
AltGr has joined #ocaml
antkong_ has joined #ocaml
leyyin has quit [Quit: So Long, and Thanks for All the Fish]
<flux>
I was also pretty sure I had written such a module somewhere, but I have misplaced it.. :)
<infinity0>
i'm still here, i'll take a look thanks :)
<Leonidas>
oh, I am not competent enough for tab-completion apparently
<Leonidas>
btw, that's edgars blog
<psaux>
Hi, does anyone have experience with js_of_ocaml?
<Leonidas>
yes
<Leonidas>
numerous people even
<psaux>
I've installed it (on 4.02.0, via opam), but I can't figure out how to build the js_of_ocaml.tyxml package. I've also installed tyxml (and js_of_ocaml was built after it).
<psaux>
(`it' being js_of_ocaml)
<psaux>
I'm trying to build the toplevel example (OCaml toplevel in the browser), and the Makefile does `ocamlfind query js_of_ocaml.tyxml')
<psaux>
and I always am getting `ocamlfind: Package `js_of_ocaml.tyxml' not found'
<Maelan>
sounds like a jester bot picked that wallpaper
<reynir>
Cool, did you register it?
<Maelan>
not mine
<reynir>
I remember it was available a while ago and suggested it here
<Maelan>
.ml are supposed to be free
<Maelan>
so it’s a shame no one reacted to your suggestion
<reynir>
THey are, but you can also pay for them, I think.
<Maelan>
the current owner gives zero information on this default page, about how to contact and if it is to sale
<reynir>
I don't think you're allowed to sell it
antkong_ has quit [Ping timeout: 246 seconds]
xyh has quit [Quit: ChatZilla 0.9.92 [Firefox 45.0.1/20160319124722]]
dhil has joined #ocaml
xyh has joined #ocaml
xyh is now known as NightElf-xyh
NightElf-xyh is now known as MYM_Moon
picolino_ has joined #ocaml
<psaux>
If anyone has experience installing js_of_ocaml, I'd appreciate your help with an issue around tyxml - thank you!
antkong_ has joined #ocaml
mcint has quit [Quit: hibernating...]
dsheets_ has joined #ocaml
copy`_ has joined #ocaml
mietek_ has joined #ocaml
lopex_ has joined #ocaml
Vintila has joined #ocaml
<picolino>
psaux, did you do opam install js_of_ocaml.tyxml
fs4lv1n1 has left #ocaml [#ocaml]
picolino has left #ocaml ["Quitte"]
cschneid has joined #ocaml
<picolino_>
sorry psaux, js_of_ocaml.tyxml does not exist
<picolino_>
I guess it's built when you install js_of_ocaml and have tyxml already installed...
cow-orker has quit [Quit: leaving]
<picolino_>
did Opam rebuild js_of_ocaml when you installed tyxml ?
AltGr has quit [*.net *.split]
copy` has quit [*.net *.split]
dsheets has quit [*.net *.split]
mietek has quit [*.net *.split]
ontologiae has quit [*.net *.split]
sz0 has quit [*.net *.split]
averell has quit [*.net *.split]
please_help has quit [*.net *.split]
myst|fon has quit [*.net *.split]
stephe has quit [*.net *.split]
lopex has quit [*.net *.split]
Harzilein has quit [*.net *.split]
boegel has quit [*.net *.split]
bitbckt has quit [*.net *.split]
cschneid_ has quit [*.net *.split]
MYM_Moon has quit [*.net *.split]
solrize has quit [*.net *.split]
sepp2k has quit [*.net *.split]
silver has quit [*.net *.split]
MercurialAlchemi has quit [*.net *.split]
Maxdamantus has quit [*.net *.split]
orbitz has quit [*.net *.split]
tobast has quit [*.net *.split]
rpip_ has quit [*.net *.split]
strmpnk has quit [*.net *.split]
caw has quit [*.net *.split]
msch has quit [*.net *.split]
_habnabit has quit [*.net *.split]
jyc_ has quit [*.net *.split]
igitoor has quit [*.net *.split]
rom1504 has quit [*.net *.split]
zozozo has quit [*.net *.split]
mehdib has quit [*.net *.split]
Rome has quit [*.net *.split]
jeroud has quit [*.net *.split]
pootler_ has quit [*.net *.split]
sspi has quit [*.net *.split]
mietek_ is now known as mietek
copy`_ is now known as copy`
lopex_ is now known as lopex
boegel|quassel has joined #ocaml
bitbckt_ has joined #ocaml
myst|fon has joined #ocaml
stephe_ has joined #ocaml
rom1504 has joined #ocaml
sspi has joined #ocaml
mehdib has joined #ocaml
jeroud has joined #ocaml
msch has joined #ocaml
igitoor has joined #ocaml
Rome has joined #ocaml
MYM_Moon has joined #ocaml
jyc_ has joined #ocaml
solrize has joined #ocaml
strmpnk has joined #ocaml
tobast has joined #ocaml
MercurialAlchemi has joined #ocaml
sepp2k has joined #ocaml
rpip has joined #ocaml
silver has joined #ocaml
zozozo has joined #ocaml
_habnabit has joined #ocaml
pootler_ has joined #ocaml
orbitz has joined #ocaml
Maxdamantus has joined #ocaml
MYM_Moon has quit [Quit: ChatZilla 0.9.92 [Firefox 45.0.1/20160319124722]]
stephe_ has quit [Changing host]
stephe_ has joined #ocaml
myst|fon has joined #ocaml
myst|fon has quit [Changing host]
MYM_Moon has joined #ocaml
caw has joined #ocaml
ggherdov has quit [Ping timeout: 276 seconds]
<psaux>
picolino_: thank you, yes I tried all of those, with no luck
<picolino_>
which version of ocaml do you use ?
srcerer has quit [Ping timeout: 244 seconds]
<psaux>
picolino_: 4.02.0
<psaux>
picolino_: Ah! So, if I opam install reactiveData
<psaux>
it then rebuilds js_of_ocaml
sz0 has joined #ocaml
<psaux>
and now I have js_of_ocaml.tyxml. Fantastic! thank you
darkf has quit [Quit: Leaving]
please_help has joined #ocaml
ontologiae has joined #ocaml
<psaux>
So, having tyxml isn't enough. I've also in the mean time installed higlo and cohttp, two packages needed by the js_of_ocaml toplevel example
<reynir>
You can run opam info js_of_ocaml to see depopts
<reynir>
Although that doesn't seem to explain why you need reactiveData
<picolino_>
thx reynir, that's a good thing to know
NingaLeaf has joined #ocaml
<psaux>
excellent, thank you. would I have seen 'tyxml' as one of the depopts before it was built on my machine?
<psaux>
(I see it now, but it is installed / available)
Algebr` has joined #ocaml
picolino_ is now known as picolino
Maxdamantus has quit [Ping timeout: 250 seconds]
Algebr` has quit [Ping timeout: 248 seconds]
Maxdamantus has joined #ocaml
AlexRussia has joined #ocaml
Algebr` has joined #ocaml
dsheets has joined #ocaml
dsheets_ has quit [Ping timeout: 260 seconds]
leyyin has quit [Quit: So Long, and Thanks for All the Fish]
th5 has joined #ocaml
pierpa has joined #ocaml
ggherdov has joined #ocaml
sh0t has joined #ocaml
dwillems has quit [Ping timeout: 244 seconds]
cow-orker has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 250 seconds]
AltGr has joined #ocaml
MYM_Moon is now known as no-zuo-no-die
A1977494 has joined #ocaml
Vintila has quit [Ping timeout: 260 seconds]
jackweirdy has joined #ocaml
A19774941 has quit [Ping timeout: 240 seconds]
boldters has joined #ocaml
sh0t has quit [Quit: Leaving]
Algebr` has quit [Ping timeout: 250 seconds]
no-zuo-no-die is now known as xyh
tmtwd has joined #ocaml
copy` has quit [Quit: Connection closed for inactivity]
<psaux>
Hi, I've an opam question: I've a working OCaml installation (via opam), but have realized I didn't have libX11 installed, so when opam installed OCaml, it didn't build the Graphics library. I've now installed (via yum / CentOS package manager) libX11. What's the right way to get opam to rebuild my Ocaml installation with graphics support (e.g., compiling graphics.cma, wherever it is)?
<companion_cube>
I'm not sure, but you might have to recompile the switch
<psaux>
companion_cube: thank you - i'm on 4.02.0 (and need to stay with this version) - would I just switch to it (and would this not be a noop)
yunxing has joined #ocaml
xyh has quit [Quit: ChatZilla 0.9.92 [Firefox 45.0.1/20160319124722]]
<companion_cube>
there is `opam switch reinstall 4.02.0`
<companion_cube>
it will recompile everything though
<psaux>
that sounds perfect (recompilation shouldn't take very long) - thank you
<zozozo>
unless you have coq installed, :p
TheLemonMan has joined #ocaml
yunxing has quit [Ping timeout: 268 seconds]
xyh has joined #ocaml
AltGr has left #ocaml [#ocaml]
<psaux>
:-)
hcarty has joined #ocaml
slash^ has joined #ocaml
tmtwd has quit [Ping timeout: 260 seconds]
ohama has quit [Ping timeout: 244 seconds]
ohama has joined #ocaml
noddy has joined #ocaml
tane has joined #ocaml
MercurialAlchemi has joined #ocaml
freehck has quit [Ping timeout: 260 seconds]
<psaux>
somehow, doing 'opam switch reinstall 4.02.0' rebuild OCaml but didn't rebuild any of my packages :/
<psaux>
is there any way to recover from this state? or shall I just reinstall everything?
<companion_cube>
huuu, weird
<companion_cube>
in the error messages you should have something like "previous state can be restored with ..."
<psaux>
I don't see those (it just finished saying successful build without any error messages), but let me try to learn if there's a way to list recoverable staes
<psaux>
*states
<psaux>
thank you
<companion_cube>
but are the packages still installed?
<companion_cube>
(like, in `opam list`)
<psaux>
they're not -- `opam list` gives an empty response
<psaux>
and: `ls ~/.opam/4.02.0/lib/` yields just `ocaml stublibs toplevel`
copy` has joined #ocaml
<companion_cube>
-_-
<companion_cube>
this... looks like a bug (`opam switch --help` states that reinstall should rebuild all packages)
<companion_cube>
or maybe you have an old opam
rand__ has joined #ocaml
dwillems has joined #ocaml
<psaux>
opam version 1.2.1~rc2
<psaux>
yes, seems like a bug. many thanks
Algebr` has joined #ocaml
mistermetaphor has joined #ocaml
<companion_cube>
oh, it's a beta of a previous release
<companion_cube>
current is 1.2.2
th5 has quit [Quit: Leaving.]
<hcarty>
companion_cube: I think 1.2.1~rc2 may be == 1.2.2
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<companion_cube>
ôO
<hcarty>
I remember seeing that version number in one of the pre-packaged opam versions floating around
<hcarty>
(this may also be a faulty memory)
FreeBird_ has joined #ocaml
FreeBird_ has quit [Remote host closed the connection]
FreeBirdLjj has quit [Ping timeout: 260 seconds]
pyon has quit [Quit: Reality is multidimensional. More precisely, two-dimensional.]
aantron has joined #ocaml
<aantron>
Drup, i think you should drop the "5" from Html5 and [%html5], unless you think "HTML6" or whatever comes in the future will not be backwards-compatible in a way that cant be handled using deprecation
<aantron>
and save the 5 for the docs and announcements
yunxing has joined #ocaml
<Drup>
true
<aantron>
s/cant/can
<Drup>
on the hand, the "html5" is in many (eliom/js_of_ocaml) programs, and I don't see the point of changing it
<aantron>
probably. i guess if its already in use thats kind of annoying
Algebr` has quit [Ping timeout: 246 seconds]
<aantron>
i was writing an issue with a list of points... main being that its going to look very much un-cool if HTML6 ever comes out :p
<aantron>
but also that it makes no sense, as the language is called HTML by the W3C, HTML5 is the title of the current spec. the whatwg living standard doesnt even have a concept like HTML5 afaik
<aantron>
and in principle the html5 module and extension point can be used to output syntaxes other than HTML5, such as XHTML
<aantron>
anyway, my 2 eurocents
<aantron>
maybe you can silently rename Html5 to Html, define Html5 as "include Html", release the ppx as [%html], and just stop mentioning the Html5 module in documentation except for some blurb somewhere
<aantron>
"Html5" does look a lot cooler than "Html" for some reason though :p
<aantron>
let me know if you want me to open that issue anyway
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Anarchos has joined #ocaml
srcerer has joined #ocaml
pyon has joined #ocaml
bitbckt_ is now known as bitbckt
bitbckt has quit [Changing host]
bitbckt has joined #ocaml
<flux>
HtML would be a version emphasizing ocaml and look cooler!
pyon has quit [Disconnected by services]
ontologiae has quit [Ping timeout: 276 seconds]
pyon has joined #ocaml
deko-pyon has joined #ocaml
deko-pyon has quit [Client Quit]
pyon has quit [Client Quit]
ollehar has joined #ocaml
pyon has joined #ocaml
<Anarchos>
hi smondet
ollehar has quit [Quit: ollehar]
Harzilein has joined #ocaml
psaux has quit [Quit: Page closed]
shinnya has joined #ocaml
larhat has quit [Quit: Leaving.]
ygrek has joined #ocaml
xyh has quit [Quit: ChatZilla 0.9.92 [Firefox 45.0.1/20160319124722]]
<companion_cube>
(although I tend to prefer the first one)
<pierpa>
companion_cube: will do ASAP
<twobitsprite>
I updated with a third, basically with the open { on it's own line...
<Drup>
twobitsprite: first is the most common
<twobitsprite>
Drup: ok, that's what I was looking for, thanks
<companion_cube>
this is one of the cases where ocp-indent makes crazy things
<twobitsprite>
companion_cube: ocp-indent seems to handle all 3 cases pretty well...
<companion_cube>
it's more when you write let a = {
<companion_cube>
it keeps all the record at the same level as the {
<companion_cube>
if I remember correctly
<Drup>
huh, no it doesn't
noddy has quit [Ping timeout: 240 seconds]
<twobitsprite>
companion_cube: nope, it just puts the next line at one indent level higher than the previous
jwatzman|work has quit [Quit: jwatzman|work]
<companion_cube>
oh wait, maybe it's with "where"
<companion_cube>
yep, that's it
<companion_cube>
let x = { r with\n
dhil has quit [Ping timeout: 244 seconds]
<twobitsprite>
oh, yeah, if you have text after the { on the same line, then yeah. But there's also a max-indent config option that'll prevent that if you're already at a certain level of indentation
<companion_cube>
I just hit newline before the {, now
<twobitsprite>
that's basically how it indents my seconds case... if there's an open bracket followed by text, it assumes you want the next line indented with the text
<companion_cube>
(so it actually made me change my indenting style -_-)
<twobitsprite>
it's similar to how lisps are indented... if you have "(let ((x y)\n" it'll indent to paren just before the x, to keep the let bindings lined up
<twobitsprite>
my only gripe with ocp-indent is there's no way to tell it you have a file-wide module clause, and to not indent it's contents...
<twobitsprite>
ok, so new question... what about in the case of "let x = some kind of long expr here in {\nfield1=x;\nfield2="something}" etc... having the opening { at the end of the long-ish let...in clause seems to distract from the intent... would you then put the opening { on it's own line?
<companion_cube>
after a "in" I always have a newline
<twobitsprite>
ok, so the second one is better?
<twobitsprite>
that's kind of why I thought about putting the first field on the same line as the open {, because it seems odd to have a line with nothing other than "{"
<companion_cube>
that's fine
<twobitsprite>
my eyes look at that and make me think it's a C for block for just a split second and it confuses me :P
<twobitsprite>
but ok, I'll stick with whatever is the normal convention
dwillems has quit [Ping timeout: 260 seconds]
<twobitsprite>
ok... not to be that newb who fires off FAQs in rapid succession, but... :P
<twobitsprite>
I'm confused about the difference between modules and classes... seems to me like modules can serve in any place where a class would, except that modules don't have inheritence...?
<twobitsprite>
I mean, a functor, to me, basically just feels like a more expressive initializer function, and modules seem like more flexible objects...?
<companion_cube>
twobitsprite: there is little in common between modules and objects
<companion_cube>
in particular, modules are (mostly) static
<companion_cube>
(except, well, first-class modules, but that's advanced)
<companion_cube>
whereas classes describe objects in which methods are dynamically dispatched, with inheritance, etc.
<twobitsprite>
pierpa: I was reading that before I came here. It didn't seem to have any recommendations for the case I was considering though...
<pierpa>
ach!
<twobitsprite>
companion_cube: well, I *am* talking about first-class modules :P
<twobitsprite>
i.e., using a module returned from a functor as a way of passing around a cluster of closures and data...
Kakadu has quit [Quit: Page closed]
dsheets has quit [Remote host closed the connection]
yunxing has quit [Remote host closed the connection]
dsheets has joined #ocaml
<companion_cube>
well, it's an alternative t o classes, for sure
<companion_cube>
it's also much more recent
<companion_cube>
many people tend to avoid the object system
<twobitsprite>
oh? I got the impression that the OOP system was the most recent addition to the ML dialect, and that the module system was more core to the language itself
<twobitsprite>
yeah, I'm not a big fan of OOP
<companion_cube>
the first-class modules are recent
<companion_cube>
static moduels are indeed very old :)
dsheets has quit [Ping timeout: 268 seconds]
<twobitsprite>
but the module system is preferred over the object system, generally?
<twobitsprite>
because it doesn't need to use message passing with late-binding polymorphism
<companion_cube>
well, for first-class modules this doesn't hold
rand__ has joined #ocaml
<companion_cube>
since they are a way of implementing dynamic dispatch
slash^ has quit [Quit: Leaving.]
<twobitsprite>
that page doesn't seem to differentiate between "modules" and "first-class modules"...
rand__ has quit [Quit: leaving]
dsheets has joined #ocaml
slash_ has joined #ocaml
wiredsister has joined #ocaml
dsheets_ has joined #ocaml
<companion_cube>
by default, "module" means static module
noddy has joined #ocaml
<flux>
also first class modules didn't exist at the point of writing that book
<companion_cube>
yeah :D
slash_ has quit [Quit: Leaving]
slash^ has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
slash^ has quit [Client Quit]
slash^ has joined #ocaml
dsheets_ has quit [Ping timeout: 250 seconds]
<flux>
I think the ocaml object system is great, but has some issues with interacting with the rest of the type system (recursive definitions come into my mind), and all in all is an advanced concept, considering the 'ease' of objects perhaps in some other languages
<flux>
but everyone should try them!
<twobitsprite>
so, what does the functor do if not create a first-class module?
<flux>
functors creatr modules
<flux>
(or possibly other functors)
<twobitsprite>
but they aren't first-class?
<flux>
we call modules first-class when we stick them into a variable
<flux>
but yes, you can use first-class functors to create first-class modules
<flux>
or plain old functors to create first-class modulse :)
<twobitsprite>
so, a functor paramaterizes an abstract module, similarly to how an init method can sort-of paramaterize a "class" which is kind-of an "abstract object", right?
<flux>
sounds about right
<twobitsprite>
so, I'm still trying to figure out the different purposes of modules/functors/first-class-modules vs classes/initializers/objects
<flux>
or how about this: modules are records, and functors are functions over those records
<twobitsprite>
right, that's kind of how I'm thinking about it
<flux>
there are some things first class modules cannot express, where you need plain old functors to do the trick
<flux>
for example the general form for converting any map to a list requires the use of functors
<twobitsprite>
by "map", do you mean a hashmap or associative array, or do you mean the (map) function?
<flux>
the functor-based Map module
<twobitsprite>
*googles*
<twobitsprite>
ok, so the modules produced Map.Make would be first-class, right?
<flux>
no, they are regular modules
<flux>
most everything is just regular modules
<flux>
you only use first class modules for the special occasion
<flux>
that is: when you need to dynamically dispatch on the input to choose a module
<twobitsprite>
so, you can't have a function return the result of Map.Make?
<flux>
you can.
<Algebr>
yea you can
<twobitsprite>
ok... I guess I'm thinking of a different definition of "first-class"
<twobitsprite>
to me, "first-class" means, can be passed to and returned from functions like any other value
<flux>
that's exactly correct :)
cgc_ has joined #ocaml
<companion_cube>
errr, a function returnign the result of Map.Make is very difficult to make (or it will be useless)
<companion_cube>
because the type inside Map.Make is parametrized
<twobitsprite>
so, you say the result of Map.Make isn't a first-class module, yet it can be returned from a function...?
<companion_cube>
you can turn it into a first-class module
<companion_cube>
but by default it's a regular, static function
<flux>
companion_cube, it depends on what you parametrize it by, doesn't it?
<companion_cube>
^ this is static
<companion_cube>
flux: not, 'a M.t, can't be used properly in a first-class module
<twobitsprite>
let f x = Map.Make(x)
<twobitsprite>
^ not ok?
<companion_cube>
noooo
<companion_cube>
not ok :)
<companion_cube>
it's even a syntax error.
<cgc_>
hi, i have this: let loc = lookup (var, Env) in if isLocation loc then let fldE = getFieldEnv (loc, H) in let val = lookup (field,fldE) in val
<cgc_>
else raise RuntimeError "test"; and i get syntax error after the third let, can someone explain me why? thanks
<companion_cube>
cgc_: it seems to me you are writing SML, not OCaml
<cgc_>
it should be sth like: let x = 1+2 in let a = x+3 in a;
leyyin has joined #ocaml
<companion_cube>
ah, better
<companion_cube>
ah, yeah, you try using "val" as a variable name
<companion_cube>
but it's a keyword
<cgc_>
oh, stupid me, thanks
<companion_cube>
(and it made me think, at first, you were trying to write SML)
<cgc_>
why? in SML val is not keyword?
<companion_cube>
it is
<companion_cube>
but `let val x = ...` is valid SML
<companion_cube>
(if I remember correctly)
<twobitsprite>
I think it's like Ocaml's refs, right?
<companion_cube>
I don't think so, it's just that you write `let val ...` or `let fun ...`
<twobitsprite>
ahh, right
<twobitsprite>
I looked in to SML once years ago :P
<flux>
it seems it's possible to write that function, though, though it's super-verbose
<flux>
let f (x : (module Map.OrderedType)) = let module Z = (val x : Map.OrderedType) in let module Z2 = Map.Make(Z) in (module Z2 : Map.S)
<flux>
^ so that's why you use them only at the last resort ;)
<flux>
I wonder if I can even make that do something useful :-), as-is it's useless because of abstract types
<twobitsprite>
ok, so modules make even less sense to me than I thought they did :P
<companion_cube>
flux: but it's useless
<flux>
let f (type a) (x : (module Map.OrderedType with type t = a)) = let module Z = (val x : Map.OrderedType with type t = a) in let module Z2 = Map.Make(Z) in (module Z2 : Map.S with type key = a)
<companion_cube>
you cannot bind the abstract type
<flux>
is that useless as well?
<companion_cube>
mostly, yes
<companion_cube>
you cannot talk about the map type from outside
<companion_cube>
twobitsprite: just ignore "first-class modules" and you will be fine
<companion_cube>
they are an advanced feature anyway
<flux>
companion_cube, this works as well: module I = (val (f (module String)) : Map.S with type key=string)
<companion_cube>
it does, but it's useless
<flux>
and then so does I.iter (Printf.printf "%s %d\n") (I.add "hello" 42 I.empty)?
<flux>
what part of that is useless, except this whole exercise?-)
<twobitsprite>
lol
<twobitsprite>
smh
<flux>
I use the first-class modules thingy so rarely I need to look up the syntax when I deal with them.
d0nn1e has quit [Ping timeout: 240 seconds]
d0nn1e has joined #ocaml
<Algebr>
module related stuff is syntax heavy
antkong_ has quit [Ping timeout: 248 seconds]
Kakadu has joined #ocaml
antkong_ has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
dwillems has joined #ocaml
<dwillems>
Why in some license it's written: "[license] with OCaml linking exception" ? What does it mean ?
<reynir>
I think it can be considered a derived work if you link in some library, or some such
<smondet>
dwillems: `[license]` is then LGPL. The LGPL gives more freedom when dynamic linking but not when static linking. The OCaml linking exception also allows static linking.
<smondet>
by "allows" I mean that you can distributed a closed-source binary linked with that library
<dwillems>
Oh ok. Thanks for the information.
<smondet>
sorry if not clear; license details are crazy
<flux>
it has come to be because ocaml (in practice) only does static linking of ocaml code, therefore the basic LGPL would be effectively the same as GPL
noddy has quit [Ping timeout: 276 seconds]
<companion_cube>
flux: you cannot return a value of type 'a I.t
<companion_cube>
it can only live in the scope of the function where you opened the 1st-class module
dsheets has joined #ocaml
TheLemonMan has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
mistermetaphor has quit [Remote host closed the connection]
mistermetaphor has joined #ocaml
boldters has quit [Ping timeout: 268 seconds]
<cgc_>
inside a match how can I return unit or other functions that return unit?
<Algebr>
match foo with
<Algebr>
| Constr1 -> ()
<cgc_>
and i have a function that takes one parameter and returns unit
<cgc_>
and it looks like i can't use both in the same match
<Algebr>
you have to give back the same signature
<Algebr>
giving back unit is different than giving back a function that gives back unit
<cgc_>
yep, i get this, but is there a way to use both cases?
<Algebr>
not trying to be rude but if you "got it" then you'd understand that you have to give back the same signature.
hcarty1 has joined #ocaml
<flux>
hmm, I wonder if the mirage project might at some point bring in advanced tracing/debugging tools for ocaml, given how nice they would be for developing an OS..
<Algebr>
maybe wrap your () as fun () -> (), essentially a no op lambda
_andre has quit [Quit: leaving]
<cgc_>
thank you and sorry, i didn't mean to be cocky :)
hcarty has quit [Ping timeout: 246 seconds]
BitPuffin has quit [Read error: Connection reset by peer]
yunxing has joined #ocaml
nicoo has quit [Remote host closed the connection]