mfp changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.11.2 released | Inscription for OCaml Meeting 2010 is opened http://wiki.cocan.org/events/europe/ocamlmeetingparis2010
slash_ has quit [Quit: leaving]
pad has joined #ocaml
<hiptobecubic> I'm a bit confused about how loading a library works
tarbo2 has quit [Ping timeout: 258 seconds]
<hiptobecubic> http://vpaste.net/H6rEm if that is /usr/lib64/ocaml/ why does.. say... "open Graphics;;" not work until i do #load "graphics.cma";; first?
tmaeda is now known as tmaedaZ
<mrvn> open Graphics just imports the values from the Graphics namespace into yours.
<yziquel> hiptobecubic: because you have to load the library first. Therefore #load "graphics.cma".
<yziquel> hiptobecubic: then open Graphics simply opens a namespace.
<mrvn> Since you haven't loaded Graphics yet it doesn't have it to import.
<hiptobecubic> yziquel, ok i misunderstood what 'open' was doing then
<yziquel> hiptobecubic: sort of a statically typed namespace.
<hiptobecubic> so i have lablgtk2 installed, but it has no .cma files
tarbo2 has joined #ocaml
<hiptobecubic> other than lablgtk.cma... but i'm trying to open Gmain
<yziquel> hiptobecubic: no .cm[x]a means no .a file, in C world.
<hiptobecubic> and it's failing
<hiptobecubic> yziquel, i'm not a C programmer so i barely know the difference between .a .so .o etc
<hiptobecubic> #load "lablgtk/lablgtk.cma";; is successful, but i don't know what that gets me if anything
tarbo2 has quit [Ping timeout: 248 seconds]
<hiptobecubic> yziquel, also, could you explain why http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs doesn't use any #load expressions if they are supposedly mandatory? Is there some shortcut they are doing? Or is it just not a very good tutorial
sgnb` has quit [Ping timeout: 258 seconds]
sgnb` has joined #ocaml
pimmhogeling has quit [Ping timeout: 276 seconds]
tarbo2 has joined #ocaml
<yziquel> hiptobecubic: ok. a .cma is a bytecode library. if #load is successful, that's generally a good sign. If #load is successful and you cannot open a module, it often is the case that ocaml doesn't know where to find the .cmi files that are the compiled descriptions of the modules you want to open. That's why I was asking how you installed ocaml in the first place.
<yziquel> hiptobecubic: they do not use #load because you only use #load on the toplevel. When you write your ocaml files, you compile them, and then you link them to other object files, or library. The #load is the toplevel equivalent of the linking phase.
<hiptobecubic> yziquel, ah. Well i installed it in the most 'official' way that slackware offers, which is through SlackBuilds.org, using the script i pasted earlier. http://vpaste.net/Lv1Ow?ft=sh
<hiptobecubic> yziquel, ok so if you're running the code as a 'script' and not compiled, you need the '#load' first
<yziquel> hiptobecubic: yes. running the code 'as script' means doing parsing + compilation to bytecode on the fly. You need the #load to load stuff.
<hiptobecubic> ok i think i understand the difference
<yziquel> hiptobecubic: i do not know slackware, but you should probably investigate using GODI on your platform.
<hiptobecubic> So. what's going on with lablgtk then? should there be a gMain.cma somewhere?
<hiptobecubic> GODI?
<yziquel> The slight 'inconvenience' with ocaml is that ocaml provides a compiler with a so-so standard library. packaging is done separately, within Debian, GODI, or Fedora.
<yziquel> hiptobecubic: GODI provides a packaging mechanism that's used rather pervasively.
<hiptobecubic> yziquel, ah i see on wikipedia. it's like a CPAN for ocaml?
<yziquel> hiptobecubic: sort of. OCaml is so statically typed that it's a bit difficult to make packages evolve as easily as in perl...
<yziquel> hiptobecubic: GODI provides 'rocketboost' if i remember well. installs the ocaml toolchain + GODI.
<hiptobecubic> Well i just have the source ball from caml.inria.fr
<yziquel> hiptobecubic: my guess with your #load issue is that the .cmi cannot be found.
<hiptobecubic> well you can see the tree http://vpaste.net/H6rEm
<hiptobecubic> that's all under /usr/lib64/ocaml
<yziquel> hiptobecubic: a trick too. from the toplevel, you can see if a module is loaded by doing 'module X = Graphics;;"
<hiptobecubic> yziquel, yes, i did that actually
<yziquel> hiptobecubic: you've got graphics.cmi.
<yziquel> hiptobecubic: and?
<hiptobecubic> i got graphics to work
<hiptobecubic> but not lablgtk
<yziquel> hiptobecubic: so what's the issue?
<hiptobecubic> which is what the next little demo script is about
<yziquel> haven't tried lablgtk. but with lablgtk, i'd rather compile than have it on the toploop.
<hiptobecubic> yziquel, what do you mean? like compile the whole program rather than run it as a script?
landstalkerx has joined #ocaml
<yziquel> hiptobecubic: compile the program to an executable. that talks directly to the CPU.
<hiptobecubic> Sure, i'll see how it goes. thanks for you help
<hiptobecubic> your* :)
<landstalkerx> I'm having some trouble with an Exercise involving LIst.fold. Is anyone willing to help?
ikaros has quit [Quit: Leave the magic to Houdini]
<thelema> landstalkerx: go ahead
<landstalkerx> http://pastebin.com/d4a172e1b that's what I have for the function
<landstalkerx> I'm supposed to fill in what base and f b x are
<thelema> what should pipe do?
<landstalkerx> it's supposed to achieve the following functionality
<landstalkerx> # pipe [(fun x-> 2*x);(fun x -> x + 3)] 3 ;;
<landstalkerx> - : int = 9
<landstalkerx> or if you pass it [] 3 it should just return 3
<thelema> ok. that last sentence gives you the base.
<thelema> which you already have.
<landstalkerx> and the function type is supposed to be pipe: ('a -> 'a) list -> ('a -> 'a)
<landstalkerx> so it takes the integer (last parameter) and applies it to the function list sequentially basically
<thelema> yes. But instead of thinking about it like that, imagine taking a bunch of functions and making one big function that runs the input through each of the given functions in order.
<mrvn> thelema: List.fold_left
<thelema> mrvn: see his pastebin
<landstalkerx> the let f b x = line is where I'm having trouble I believe... but I'm not sure how to combine it with the "base"
<thelema> the [f b x =] line doesn't need to worry about the base directly. Its job is to take the current accumulated function and combine it with the next function in the list.
<thelema> b is the current accumulated function (the result of combining the first n)
<thelema> x is the next function that needs to be attached
<landstalkerx> ok so I need to combine x and b
<thelema> yes. They're functions, so the combination will be a function, right?
<landstalkerx> yes
<thelema> how many arguments will that combination function take?
<landstalkerx> well pipe fs is supposed to look like ('a -> 'a) list -> ('a -> 'a)
<landstalkerx> so I believe it should be a function that takes an 'a and reutrns an 'a
<thelema> ok, so [let f b x = fun z -> ...]
<thelema> what should the combination function do with its argument, z?
<landstalkerx> so z would be the combination of the previous functions in the list right?
<thelema> no, z is the argument to that combination function
Associat0r has joined #ocaml
<landstalkerx> ok so z should be of type 'a right?
<thelema> yes
<landstalkerx> so would I want to apply it to x?
Modius has quit [Quit: I'm big in Japan]
Modius has joined #ocaml
<thelema> which do you apply it to first, the composition of the first n functions in the list or the n+1st function?
<landstalkerx> it should be applied to the compilation first I believe
<thelema> s/apply/pass/
<thelema> ok, so how do you write that?
<landstalkerx> x (b z)
<landstalkerx> which gives the correct answer
<thelema> good job
<landstalkerx> I guess the trouble I was having was that I was thinking f b x was the function and I just needed to specify what it would do
<thelema> List.fold_left takes care of constructing the function for you
<landstalkerx> I was thinking I was writing the function. not that I was going to write a function that makes the function if you will
<thelema> you just have to tell it how to build it piece by piece
<landstalkerx> ok I guess I need to review how exactly it works a bit more
<landstalkerx> thank you for your help
<thelema> you're welcome
Associat0r has quit [Quit: Associat0r]
elehack has quit [Quit: Goodbye...]
haelix has quit [Quit: leaving]
haelix has joined #ocaml
boscop_ has joined #ocaml
94SAAAN9U has left #ocaml []
boscop has quit [Ping timeout: 240 seconds]
Alpounet has quit [Read error: Connection reset by peer]
Alpounet has joined #ocaml
Asmadeus has quit [Changing host]
Asmadeus has joined #ocaml
thrasibule has quit [Read error: Operation timed out]
thrasibule has joined #ocaml
mutew has quit [Ping timeout: 256 seconds]
mutew has joined #ocaml
CcSsNET has joined #ocaml
Drk-Sd has quit [Quit: dodo]
derdon has quit [Quit: derdon]
pad has quit [Remote host closed the connection]
maskd has quit [Quit: leaving]
ski_ has joined #ocaml
tarbo2 has quit [Ping timeout: 248 seconds]
tarbo2 has joined #ocaml
_unK has quit [Remote host closed the connection]
boscop_ has quit [Quit: Gxis revido!]
yakischloba has joined #ocaml
thrasibule has quit [Ping timeout: 276 seconds]
yakischloba has quit [Ping timeout: 272 seconds]
quant has joined #ocaml
yakischloba has joined #ocaml
<quant> hi all.
<quant> why can't I define some thing like the following:
<quant> let a = 1 in let foo n = n + a;;
<quant> it gives a syntax error
struktured has quit [Remote host closed the connection]
Amorphous has quit [Ping timeout: 256 seconds]
mutew has quit [Ping timeout: 246 seconds]
struktured has joined #ocaml
tarbo2 has quit [Ping timeout: 276 seconds]
tarbo2 has joined #ocaml
struktured has quit [Ping timeout: 248 seconds]
Amorphous has joined #ocaml
struktured_ has joined #ocaml
Don_C has joined #ocaml
yakischloba has quit [Ping timeout: 240 seconds]
yakischloba has joined #ocaml
Don_C_ has joined #ocaml
Don_C_ has quit [Remote host closed the connection]
Don_C has quit [Remote host closed the connection]
pflanze has quit [Ping timeout: 260 seconds]
tarbo2 has quit [Ping timeout: 258 seconds]
tarbo2 has joined #ocaml
quant has quit [Quit: ERC Version 5.2 (IRC client for Emacs)]
struktured_ has quit [Ping timeout: 246 seconds]
pflanze has joined #ocaml
tarbo2 has quit [Ping timeout: 246 seconds]
tarbo2 has joined #ocaml
Modius_ has joined #ocaml
Modius has quit [Ping timeout: 248 seconds]
tmaedaZ is now known as tmaeda
_zack has joined #ocaml
tensorpudding has quit [Remote host closed the connection]
tarbo2 has quit [Ping timeout: 258 seconds]
tarbo2 has joined #ocaml
qwertycute has joined #ocaml
_zack has quit [Quit: Leaving.]
valross has joined #ocaml
tmaeda is now known as tmaedaZ
_zack has joined #ocaml
tmaedaZ is now known as tmaeda
Paczesiowa has joined #ocaml
<Paczesiowa> why ocamldep returns the same result, whether I give -pp flag or not?
yakischloba has quit [Quit: Leaving.]
Yoric has joined #ocaml
<mfp> Paczesiowa: ocamldep doesn't return syntax extension dependencies, if that's what you're thinking about
yziquel has quit [Ping timeout: 248 seconds]
<Paczesiowa> mfp: why does it have -pp flag then?
pimmhogeling has joined #ocaml
<Yoric> Paczesiowa: because it can read files that are written using syntax extensions.
<Paczesiowa> Yoric: didn't know that has something to do with deps
<Yoric> Well, ocamldep needs to be able to read the contents of the file.
<Yoric> If your file uses a syntax extension, it may not even remotely look like OCaml code.
<Yoric> So to understand it, ocamldep needs to pass it through camlp4.
<Paczesiowa> Yoric: makes sense, thanks
<Yoric> np
<Paczesiowa> I'm using Makefile from http://caml.inria.fr/pub/docs/manual-ocaml/manual027.html can ocamldep generate things like PROG1_OBJS, when there is prog1.ml present?
hiptobecubic has quit [Quit: For a holy stint, a moth of the cloth gave up his woolens for lint.]
tmaeda is now known as tmaedaZ
<mfp> Paczesiowa: well, I guess you could take ocamldep's output, uncapitalize the module names and append .cmo in the Makefile
clog has joined #ocaml
boscop has joined #ocaml
ski_ has quit [Quit: Lost terminal]
jereman has quit []
_zack has joined #ocaml
pimmhogeling has joined #ocaml
Paczesiowa has quit [Remote host closed the connection]
_unK has joined #ocaml
Drk-Sd has joined #ocaml
Narrenschiff has joined #ocaml
mutew has joined #ocaml
<flux> how would one go about adding attribute 'onload' to a tag in ocsigen? apparently it's not in the list of supported onxxx-events?
<flux> conveniently functions like val add_string_attrib : string -> string -> 'a attribs -> 'a attribs are not published..
<flux> it seems rather annoying that such a loophole has been blocked, as using it would only aim at your own foot. and the list of attributes doesn't appear to be complete!
<mrvn> Can I create a function [ `Foo | 'a ] -> ([> ] as 'a)?
<mfp> flux: there's a function to turn XML.xml into _ XHTML.M.elt somewhere
<flux> mfp, it sounds slightly inconvenient, as I also have other tags under body, so I'd need to convert them back
<flux> also, I didn't find that function yet, maybe I missed it :)
<mfp> mrvn: I don't think you can express "type difference" with polymorphic variants
ttamttam has joined #ocaml
<mfp> flux: I'm pretty sure it exists (I've used it before :)
* mfp looks for it
<flux> mfp, ah, yes, tot and toelt
<flux> maybe I'll try that instead of patching ocsigen (which I actually already did ;))
<flux> better to work with stock ocsigen..
<mfp> or you can send the patch to the list
<mrvn> Maybe 'a * foo * 'b -> 'a * 'b?
<mfp> somebody did for the other onxxx and they merged it in no time
<flux> do I need to be on the list?
<mrvn> I have a object that can have a number of callbacks which are yet unset. I want to encode each unset callback as phantom type and setting the callback should remove the phantom type from the full type.
<mfp> flux: dunno
<mfp> mrvn: what about going the other way around? add `Has_xxx_callback when you set it
<mfp> then you can specify that the callback needs to be there with [> `Has_xxx_callback]
<mfp> unless you want to prevent having more than one callback (as opposed to mandating that there's at least one)
<mrvn> mfp: Later I want a function that only accepts objects that have all their callbacks set.
<mfp> mrvn: then you can use val f : [>`Has_xxx | `Has_yyy | `Has_zzz] obj -> _
<mrvn> mfp: and different objects have different callbacks
<mfp> and type has_all_callbacks = [`Has_xxx | `Has_yyy | `Has_zzz]
<mfp> oh
<mfp> that's a pb :-|
<mrvn> type 'a foo type 'a bla type 'a bar
<mrvn> type 'a t = { mutable foo : bool; mutable bla : bool; mutable bar : bool }
<mrvn> let make () = ({ foo = false; bla = false; bar = false; } : unit foo bla bar t);;
<mrvn> let (set_foo : 'a foo 'b -> 'a 'b) = function x -> x.foo := true; x;;
<mrvn> Any way to make the last line work?
<mrvn> 'a foo doesn't work, [ `Foo ] doesn't work. I think that leaves only some foo * bla * bar * t as possibility. Any idea how to do that?
_zack has quit [Quit: Leaving.]
<mfp> don't know any, sorry
<mfp> I haven't found a way to encode type differences
_zack has joined #ocaml
_zack has quit [Quit: Leaving.]
<mrvn> You can do it if you require a certain order. 'a foo t -> 'a t works. But then you can not set bar in bar foo t unless you set foo first
<mrvn> I want something like named argumens (order doesn't matter) but with currying.
pimmhogeling has quit [Ping timeout: 272 seconds]
Yoric has quit [Quit: Yoric]
Narrenschiff has quit [Ping timeout: 240 seconds]
<mrvn> Hah, got it:
<mrvn> type t = { mutable foo : bool; mutable bla : bool; mutable bar : bool };;
<mrvn> let make ~foo ~bla ~bar = { foo = foo; bla = bla; bar = bar };;
<mrvn> let set_foo x = x ~foo:true;;
<mrvn> or not. That only works in the right order.
Narrenschiff has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 276 seconds]
drunK_ has joined #ocaml
drunK_ has left #ocaml []
pimmhogeling has joined #ocaml
_unK has quit [Ping timeout: 256 seconds]
_unK has joined #ocaml
ulfdoz_ has quit [Quit: Reconnecting]
ulfdoz has joined #ocaml
mutew has quit [Ping timeout: 272 seconds]
mal`` has quit [Quit: Coyote finally caught me]
mal`` has joined #ocaml
jeddhaberstro has joined #ocaml
mutew has joined #ocaml
derdon has joined #ocaml
mrvn has quit [Remote host closed the connection]
yziquel has joined #ocaml
jeddhaberstro has quit [Quit: jeddhaberstro]
_zack has joined #ocaml
Submarine_ has joined #ocaml
Submarine_ has quit [Client Quit]
_zack has quit [Quit: Leaving.]
_zack has joined #ocaml
Submarine_ has joined #ocaml
lokydor has joined #ocaml
AvA|anche has joined #ocaml
bzzbzz has quit [Quit: leaving]
lokydor_ has joined #ocaml
lokydor_ has quit [Client Quit]
hcarty_ has quit [Quit: leaving]
<flux> how do I create untyped basic forms in eliom? I was thinking something like form ~action:(uri_of_string "#") (input ()) [] would get me going, but no
hcarty has quit [Quit: leaving]
<flux> wait, where did I pick that ~action..
hcarty has joined #ocaml
<flux> ah, it did have that argument :)
freddie111 has joined #ocaml
Waleee has quit []
AvA|anche has quit [Quit: ChatZilla 0.9.86 [Firefox 3.6/20100115144158]]
freddie1` has joined #ocaml
<flux> so, form takes [< block_sans_form | `Fieldset ], type block_sans_form = [ TEXT.block | PRESENTATION.block | TABLES.block | TEXT.heading | LIST.list | misc ], but none of those appear to contain anything related to forms
freddie111 has quit [Ping timeout: 246 seconds]
freddie1` has quit [Client Quit]
jeddhaberstro has joined #ocaml
<flux> when, finally: http://masyn.org/flux/ - my small ocsigen-based chat :). perhaps I'll clean up the sources at some point and put them online as well.
<flux> (it uses ajax/comet to be real-time)
<flux> perhaps it could even be revised to work in a more general fashion..
ikaros has quit [Quit: Leave the magic to Houdini]
<flux> but, off to do something else, I've spend atleast two nights on that thing. getting up to speed with ocsigen is not simple, and infact I'm not sure if I ever will :)
<yziquel> flux: ocsigen is not that hard, but there are some rather undocumented areas where you wonder about the typing.
<yziquel> like forms and such... when you put weird things in them...
<flux> yziquel, indeed. if I were coding in plain html, I would have oodles of documentation, examples and tutorials all over the net.
<flux> while ocsigen has a lot of documentation too, it feels lacking at some points
<flux> for example the non-reference-part of "Forms" is less than a screenful in the docs, and doesn't mention how XHTML.form/XHTML.input should work.
<flux> ie. I'm not sure if all this safety is worth all this trouble :). maybe ocamlduce is nicer, or just the plain embedded xml-syntax..
<yziquel> when i was interfacing extjs with eliom i had a rough time trying to get extjs people to understand the typing problem i had for their uploading-files-widget-piece-of-code.
<flux> hm, why would extjs people care about ocsigen typing problems?
<yziquel> flux: because i had to know what their widget was feeding back to my eliom app. to type the POST service...
<yziquel> flux: the only answer i had was "as usual"...
<flux> ah, ok, you were writing type-safe interfacing library for it?
<flux> did you finally get useful answers?-)
<yziquel> flux: no, it's eliom who was picky about the args.
<yziquel> flux: yes. works fine.
thrasibule has joined #ocaml
<yziquel> flux: the (X)HTML safety is not what i praise ocsigen for. what it's really cool for is that you have a .cmo, that you can make fully reactive in the sense of React module.
<yziquel> flux: then your imagination can be limitless as to what you want to interface.
<flux> yziquel, I haven't tried React yet..
<flux> I did consider writing a more traditional cgi-library for ocsigen, along the lines of Perl::CGI
<flux> but perhaps it's too much work to write a complete one
<yziquel> flux: embed perl to parse Excel sheets, feed numbers to an Asterisk server, who informs you about softphone IP, you reconcile with web browser client IPs, put ExtJS real-time tables for the admin supervising the calls...
<yziquel> flux: you can do such a beast with two weeks, evenings only.
<flux> one fun idea I had about that chat was that each page on the system would have a small chat-window at the bottom
<flux> and when you arrive to the page from for example google, the visit would trigger a message (say, to irc)
<flux> and you could respond to that visitor by IRC as well
<flux> unfortunately I don't think I have any pages people would google for, though :-)
mutew has quit [Ping timeout: 256 seconds]
tmaeda is now known as tmaedaZ
<yziquel> flux: true. but eliom + o'browser + extjs, and you can go quite wild in the field of web apps.
<flux> yziquel, so you've tried o'browser as well?
tmaedaZ is now known as tmaeda
<yziquel> flux: yes, but no. i was fine on my stuff with plain ajax and javascript.
<yziquel> flux: but i definitely look forward to using it for something cool.
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
pimmhogeling has quit [Ping timeout: 272 seconds]
z0ltan has joined #ocaml
z0ltan has left #ocaml []
avsm has joined #ocaml
itewsh has joined #ocaml
Smerdyakov has joined #ocaml
pimmhogeling has joined #ocaml
avsm has quit [Quit: Leaving.]
Alpounet has quit [Quit: ``Do what you think you can't do.'']
Alpounet has joined #ocaml
lokydor has quit [Quit: Lost terminal]
bitbckt has joined #ocaml
jeddhaberstro has quit [Quit: jeddhaberstro]
steve32 has joined #ocaml
<steve32> how do i pattern match on whether a value is a float int or char?
<steve32> i am working with images and sometimes they are ints and sometimes floats and sometimes chars
<steve32> and i need to know which type it is in my function
<mfp> steve32: you can use a sum type type x = Int of int | Float of float ...
<steve32> here is my current image type
<steve32> type 'a image = { w : int; h : int; data : 'a array; }
<steve32> so you are saying for the data part I should instead use an array of the sum type you mentioned above?
<flux> steve32, most likely a image would have either all pixels as int or all pixels as float, no mixes?
<steve32> yes
<flux> well, type image' = IntImage of int image | FloatImage of float image would then be the corresponding sum type
<flux> although there are other ways to encode this as well
<steve32> ic
<steve32> makes sense
<steve32> i think i will use that
<flux> but there are alternatives
<flux> you could use function compositions, and infact they might make more sense here
<steve32> ic
<steve32> so pass in a function that deals with the appropriate type
<steve32> thanks for that idea
<flux> for example you might have a function like: let sum_images f a b = assert (a.w = b.w && a.h = b.h); Array.init (a.w * a.h) (fun i -> f a.data.(i) b.data.(i))
<steve32> makes sense
<steve32> i think i like that for now
<flux> and in general you might have a record describing an image type, like type 'a image_ops = { sum : 'a -> 'a -> 'a } etc
<flux> good luck :)
ikaros has joined #ocaml
<steve32> thanks, this is the first real project I am doing in ocaml, so I am playing with different ideas and learning. This is helpful info
steve32 has quit [Quit: Leaving]
tarbo2 has quit [Ping timeout: 240 seconds]
tarbo2 has joined #ocaml
gareth_0 has joined #ocaml
gareth_0 has quit [Remote host closed the connection]
gareth_0 has joined #ocaml
ttamttam has quit [Quit: Leaving.]
yakischloba has joined #ocaml
mutew has joined #ocaml
jeddhaberstro has joined #ocaml
aspecto has joined #ocaml
gnuvince has joined #ocaml
gnuvince has left #ocaml []
Drk-Sd has quit [Quit: {'EXIT', Drk-Sd, "bye"}]
avsm has joined #ocaml
avsm has left #ocaml []
nat_ has joined #ocaml
aspecto_ has joined #ocaml
aspecto has quit [Ping timeout: 276 seconds]
aspecto_ is now known as aspecto
smimou has quit [Ping timeout: 248 seconds]
smimou has joined #ocaml
<flux> can ocsigen load the same module multiple times?
nat_ has left #ocaml []
Yoric has joined #ocaml
<mfp> flux: yes
<flux> nice to know, as apparently I can use a 'global' state in my module as I wish
<flux> mfp, how do two modules exchange information, can they?
<mfp> via side effects when the module initializes
<mfp> using an existent function
pflanze has quit [Quit: Leaving]
<mfp> e.g. registering new services/handlers using Eliom
<flux> do existing functions to do that in some convenient way exist?
aspecto has quit [Quit: aspecto]
<flux> (hmph, redundant phrase is redundant)
<mfp> nope, as the precise communication you want is very app-dependent
<mfp> you can define yours trivially though
<mfp> just link statically against a module that defines the function (e.g. to send a msg or whatever)
<mfp> then dynamically loaded modules can use it
<flux> iow, recompile ocsigen?
<mfp> no need to recompile
<flux> relink?-)
smimou has quit [Quit: bli]
<mfp> you can build a custom server easily using ocamlfind
<mfp> hmm
<mfp> in fact, even loading the module that provides the comm functions dynamically might work
<flux> well, I suppose if a need arose, a simple unsafe generic mechanism could be patched in
<flux> say, val set_entrypoint : string -> 'a -> unit etc
<mfp> so you could even use a plain old ref :P
<mfp> what should that do?
<flux> use a global hash table and associate that key to that value
<mfp> you can do it all while keeping type-safety (cmo/cmxs interfaces are checked by Dynlink)
<mfp> dict.ml: let foo = ref None <- linked statically / dynamically probably works too, don't remember
<mfp> then foo.cmxs/.cmo can do let () = Dict.foo := Some "whatever"
<flux> mfp, actually you can't have let foo = ref None in a module without giving a more exact type..
<mfp> yeah, it'd be '_a
<mfp> but I don't see the pb you're trying to solve
<mfp> you don't even need an heterogeneous container here
<mfp> you can add the refs/funcs/whatever with the appropriate type to the module loaded first
<mfp> then use them in modules loaded dynamically subsequently
<mfp> fwiw, you can build an ocsigen server linked statically against a module with this rule:
<mfp> STATIC_PKGS=ocsigen.parsecommandline,ocsigen.server,ocsigen.ext.ocsipersist-sqlite,ocsigen.ext.eliom,ocsigen.ext.staticmod,ocsigen.ext.extendconfiguration,ocsigen.ext.deflatemod
<mfp> myserver.opt: module.cmx
<mfp> ocamlfind ocamlopt -package $(STATIC_PKGS) $+ -o $@ -linkpkg -thread
<mfp> s/ocsigen.parsecommandline// <- that comes from an old Makefile, it's no longer needed with current Ocsigen
<mfp> also extendconfiguration, deflatemod, etc. only needed if actually used in ocsigen.conf
<mfp> you can choose not to link them statically and then load them dynamically
<mfp> I prefer fully static servers (except for a single .cmxs with the site, maybe), since they're self-contained
<flux> hm, extensions are globally accessible?
<mfp> they are
<flux> so that simply covers my totally made-up use-case
<mfp> so that answers the above Q
<mfp> modules loaded dynamically can necessarily be seen by subsequently loaded modules
<mfp> since Eliom sites wouldn't work otherwise
<mfp> when Eliom is loaded dynamically from the cmxs (which is what the docs recommend IIRC)
tarbo2 has quit [Ping timeout: 272 seconds]
<mfp> (building statically linked servers came later, I know because I wrote the initial patch ;)
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
pimmhogeling has quit [Ping timeout: 272 seconds]
tarbo2 has joined #ocaml
johnnowak has joined #ocaml
pimmhogeling has joined #ocaml
Narrenschiff has quit [Quit: Narrenschiff]
gareth_0 has quit [Ping timeout: 276 seconds]
Submarine_ has quit [Ping timeout: 276 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
yziquel has left #ocaml []
yziquel has joined #ocaml
pimmhogeling has quit [Ping timeout: 272 seconds]
CcSsNET has quit [Ping timeout: 248 seconds]
johnnowak has left #ocaml []
_zack has quit [Quit: Leaving.]
_zack has joined #ocaml
BigJ has quit [Ping timeout: 240 seconds]
mutew has quit [Ping timeout: 248 seconds]
ikaros has joined #ocaml
avsm has joined #ocaml
_zack has quit [Quit: Leaving.]
bzzbzz has joined #ocaml
BigJ has joined #ocaml
CcSsNET has joined #ocaml
tarbo2 has quit [Ping timeout: 258 seconds]