drunK has quit [Remote host closed the connection]
theDroggl has quit [Ping timeout: 272 seconds]
theDroggl has joined #ocaml
elehack has quit [Ping timeout: 250 seconds]
LionMade0fLions has quit [Ping timeout: 260 seconds]
LionMade0fLions has joined #ocaml
ikaros has joined #ocaml
ftrvxmtrx has joined #ocaml
valross has quit [Quit: Ex-Chat]
coucou747 has quit [Read error: Connection reset by peer]
hcube has joined #ocaml
Snark has joined #ocaml
hcube has quit [Ping timeout: 276 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
Yoric has joined #ocaml
m3ga has joined #ocaml
<m3ga>
for an ocaml program compiled into a binary executable, is there a way to determine how much stack space it uses?
<flux>
no, and I believe that is generally impossible (halting problem)
<flux>
I suppose there might be a generic tool that allows to determine the stack space used for individual runs
<flux>
if not, you could just use ulimit and do a binary search: if it crashes, you had too little :)
<adrien>
what was the name of the monitoring/profiling app for/in ocaml already?
<adrien>
(I should really be sleeping :P °
<flux>
hmm.. ocamlviz?
<julm>
ocamlprof?
<flux>
if it doesn't have stack profiling, it relaly should get it :)
<flux>
it'd be a nice way to find functions that are accidentally non-tail-recursive yet handle lots of data
<m3ga>
thanks flux. i actually thing the all compilers with tail call optimisation should have the abiltity to warn/error if a function isn't tail recursive.
<adrien>
ocamlviz, was that one
<m3ga>
i was also thinking of individual runs of a program, for which it should be able to report max stack usage
<adrien>
keep on forgetting its name
<adrien>
m3ga: I think the OS can do that quite often, not sure though
<m3ga>
hmm, linux aought to have that sort of a program
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
<flux>
time has -f %p, but apparently it doesn't work
<flux>
or I don't know how to use it properly :)
ygrek_ has joined #ocaml
<adrien>
many things in time don't work =/
<julm>
flux: be sure to use /usr/bin/time, not your shell's builtin
<flux>
zsh's time doesn't appear to support any arguments
<flux>
(other than program name)
<adrien>
"Not all resources are measured by all versions of Unix, so some of the values might be reported as zero. The present selection was mostly inspired by the data provided by 4.2 or 4.3BSD."
<flux>
adrien, that's about kernel memory usage
<adrien>
so, run 4.3BSD? :P
<flux>
adrien, for user space programs it should be much easier, because the stack pages are mapped on-demand
<flux>
basically one could check how much stack is allocated at the exit of a process
<flux>
needs kernel support for that, though..
<adrien>
flux: yup, but I would have thought that if something easy was available in user-space, you wouldn't to use that on kernel
<flux>
adrien, I understood the feature tells how much the kernel itself consumes stack, regardless of user space..
<flux>
oh, it does mention process exit there :)
<flux>
in any case, it is interested more in kernel stack rather than user stack, right?
<adrien>
yup
<flux>
I don't think calls inside the kernel can be put into the user space stack due to security reasons
<adrien>
gdb should be able to give infos about the stack pointer and maybe the max stack usage
<flux>
the same approach should work for user space apps as well, though
<adrien>
(and support for running the linux kernel itself under a debugger was only recently merged iirc)
<flux>
fill the stack with magic value in the beginning etc
<flux>
sounds like it'd be doable with ptrace
yezariaely has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Yoric has quit [Quit: Yoric]
tmaeda has quit [Read error: Connection reset by peer]
yezariaely has left #ocaml []
<m3ga>
flux: yes, ptrace would be able to do, but i was hoping for an existing program :-)
mcclurmc has quit [Remote host closed the connection]
cods has quit [Quit: Reconnecting]
cods has joined #ocaml
cods is now known as cods2
cods2 is now known as cods
cods is now known as cods2
cods2 is now known as cods
fraggle_laptop has joined #ocaml
ccasin has joined #ocaml
monra has joined #ocaml
<monra>
Hello. Is anyone familiar with a good ocaml mode for emacs? I use this one: http://caml.inria.fr/pub/docs/u3-ocaml/emacs/index.html but it has many "flaws". Sometimes you must write the word before pressing tab in order to align the word to the correct position.
<monra>
Also. I was wondering is it possible to have multiple declarations in one let command? It's quite furstrating doing "let x = 2 in let y = 3 in let z = 1 ..."
<flux>
let x = 1 and y = 2 in ..
<flux>
or let (x, y) = (1, 2) in .. (parens are superfluous)
<monra>
flux: thanks for your answer. I see I'm not able to do let x = 1 and y = x + 2 ... is there a better way to do this than doing let x = 1 in let y = x + 2? Also, the solution with the tuples I think destroys a little a bit the meaning of the code, for example (x, y) could have no meaning at all as a tuple :S
larhat has quit [Quit: Leaving.]
<flux>
monra, well, it could have if x and y were related
<flux>
monra, there's also let rec .. and .. but in your situation it would need lazy values or functions. so stick to let in let in :)
<monra>
flux: ok thank you very much for your help :)
<flux>
monra, btw, I just use tuareg mode
<flux>
(and a sequence of lets would not intoduce new levels of indetntation)
<monra>
flux: I see, the mode I use isn't introducting new leveles of identation too when using multiple lets... but shouldn't it ? I'm maybe used from C or Java when for each new "{" you have a new level ...
<flux>
monra, well, the way my tuareg works is that if there's an expression not starting with let inside a let in expr, a new level will be introduced
<flux>
I think that works fine and let's you see the scolpe of a group of lets
<monra>
flux: I just Installed it and will have a look. Thank you!
<flux>
monra, good luck. btw, install caml-mode as well, it comes with caml-types.el which tuareg can make use of.
monra has quit [Remote host closed the connection]
monra has joined #ocaml
<kaustuv>
why do people prefer
<kaustuv>
let x = foo in let x = foo in
<kaustuv>
let y = bar in instead of let y = bar in
<kaustuv>
baz baz ?
<thelema>
kaustuv: got me - I prefer the second
<mfp>
I prefer the former, not sure why; maybe just conditioning
<mfp>
it tends to isolate things run only for their side-effects from bindings, which tend to float to the top, since code that interleaves let _ = ... with ';'-sequencing looks bad
monra has quit [Ping timeout: 255 seconds]
monra has joined #ocaml
<mfp>
s/run/evaluated/
<kaustuv>
I guess the tuareg 1.x defaults agree with you, mfp, even though the caml programming guidelines disagree
hcube has quit [Ping timeout: 264 seconds]
newone has joined #ocaml
<newone>
is there someone who can help me with a module problem?
<thelema>
newone: don't ask to ask, just ask
<newone>
i have a ocaml file containing several modules and i want to use the types from the last module in the file already in some type constructor in the first module in that file, but the error occurs unbound type constructor
<newone>
how to fix?
<thelema>
1) reorder the modules
<thelema>
2) recursive modules
<kaustuv>
3) pull the type definition out of both modules
<kaustuv>
4) functorize the first module and instantiate after the definition of the last one
hto has quit [Ping timeout: 255 seconds]
monra has quit [Quit: leaving]
<newone>
first of all thanks, reordering isnt possible, the situation is i am writting on a compiler with a lang.ml file which contains the different types for the abstract syntax tree like Expressions, Statements, Types
<thelema>
then you should pull the types out of your modules - kaustuv's #3
<newone>
i thought and already tried to write a single file for each module in the current file and then "open" them all in the lang.ml file but that just didnt work
<thelema>
pull your other types into the lang.ml file
ikaros has joined #ocaml
<thelema>
why doesn't it work?
<newone>
it says syntax error
<thelema>
in what code?
<newone>
come again please?
<newone>
ah now i got what you ment, i got the error in the lang.ml file
<thelema>
pastebin?
<newone>
i am very new to this kind of conversation so i dont really understand what you mean with pastebin
<thelema>
got it. pastebin is a website where you can paste some text (your code) and then you take the url that gives and paste it here so we can all see your text
<newone>
i am sorry, but its commercial code and i dont think it s possible for me to upload any code
<thelema>
fair enough. Syntax error means your program isn't properly formed ocaml code - it doesn't mean that what you're trying to do isn't right.
drunK has joined #ocaml
<newone>
i can describe how my files are arranged
<kaustuv>
If you have mutually recursive types and absolutely must have them in separate modules, then making the modules recursive is your only option. All recursion is explicit in OCaml. If you don't know what these terms mean, just put all your AST type definitions in a single module.
<thelema>
see if you can fix the syntax error in lang.ml. Once you've done that, come back and we can help with other issues.
<thelema>
We can't help you fix a syntax error without seeing the malformed code.
<newone>
ok thats more than reasonable, i try to fix the syntax error and then come back here, if thats ok
<mfp>
(3) should be the easiest, just put all the type definitions at the top and create aliases in the modules (if needed)
<newone>
how do you create those aliases?
<mfp>
e.g. type foo_ = A | B type bar_ = C | D module X1 = struct type foo = foo_ = A | B end module X2 = struct type bar = bar_ = C | D end
<thelema>
type x = Lang.x
<mfp>
note the hack used to refer to the earlier type
<mfp>
since types are implicitly recursive
<mfp>
I sometimes wish there were a type rec t = ...
<newone>
:thelema if i do it the way you said doesnt it give you a circular build detect?
<thelema>
newone: only if lang depends on the module with the alias. If lang has only types, it shouldn't depend on any other files.
<mfp>
yes, it would (unless you use a recursive module, which is very heavy-handed)
<mfp>
thelema: he's doing it _inside_ Lang IIUC
<newone>
okay what i try to do now is to put the type definitions of those types which are used in several modules in this file on top of the file and try the thing with the aliases
<thelema>
newone: if you have problems with modules depending on each other, the simplest solution is to move things around (types, values) so that the modules don't depend on each other, but that there's a heirarchy.
<mfp>
newone: don't forget to declare the types recursively with type x = .... and y = .... at the top (I missed that in the example above)
<thelema>
newone: probably just moving your type definitions together (possibly using type x = ... and y = ...)
<thelema>
is the best way to fix this
avsm has quit [Quit: Leaving.]
<mfp>
as for the aliases, they're only needed if you want each type to be in a different (sub-)module inside Lang
<mfp>
but you could as well have them all directly in Lang, or in a new module Lang.Types
rks has joined #ocaml
<newone>
:mfp if i understood you correctly you suppose to put all Statement types and Expression types and so in one module? if so i would lose that kind of order i liked to have in my code (although it s not really working ;)
ikaros has quit [Quit: Leave the magic to Houdini]
<thelema>
statement type? what is that?
ikaros has joined #ocaml
<mfp>
you can place the functions in different modules and all the types in a single one at the top, or keep everything separated by using aliases (as shown above) to "re-export" the type definitions
<newone>
:thelema it s a type in the module Statement, which contains all different statement occuring in the language i have to compile
<thelema>
maybe it'll help you - enode is an expression node, snode is a statement node in the parse tree
<kaustuv>
mfp: I won't argue this too strongly, but I don't think it's more work than your suggestion using manifest types. About the only duplication using recursive modules is the need to give the type signatures for all functions
<newone>
:thelema can i upload some partial code so you get an impression of my situation?
<thelema>
of course.
hto has joined #ocaml
<kaustuv>
mfp: Obviously, in almost every case it would just be better to avoid putting such mutually recursive stuff in different modules, assuming it can be done (i.e., no duplicate constructors, record fields, etc.)
<kaustuv>
err, s/different/the same/
<kaustuv>
or wait, I was right the first time. Bleh
<newone>
:thelema thats quite similar to the real lang.ml
hcube has joined #ocaml
<thelema>
yes, best to move Statement.t into Type
<thelema>
well, easiest
<thelema>
because I'm assuming that Statement uses lots of things in Types
<newone>
thats something i dont really understand about the module system in ocaml. it is right that i used lots of thing of Type in Statement but since Statement module comes later in the file i never had any problem, just as i neede a Type which contains something from the Statement module the unbound type constructor occured
ftrvxmtrx has quit [Quit: Leaving]
<thelema>
modules are designed to be compiled separately, which is why this restriction exists.
<thelema>
the simplest way to compile a module is to have all its dependencies already compiled. cross-references between modules make this hard. Ocaml supports recursive modules for this, but the syntax seems a lot of extra work to me, as you have to give full signatures for both modules
<newone>
ok, what i tried to do next was to cut out every module in this file and put it into their own files, and then wrote into the lang.ml file open statement (thats the name of the file containing the Statement module)
<thelema>
i.e. statement.ml has the line "open Lang", yes?
<newone>
one second
<newone>
no, it thougt since its lang.ml which needs the statement.ml file
<kaustuv>
newone: you will save yourself a *lot* of headache if you define an ast.ml containing only type definitions (i.e., only the types from the Type and Statement modules). Then in both type.ml and statement.ml you can write: open Ast
<thelema>
kaustuv: even better, he can make a .mli file, not even a .ml, as there's no code
<newone>
:kaustuv does it still work then if the types call each over recursevly
<newone>
:thelema what should i write into the mli file?
<kaustuv>
yes, the whole point is to put mutually recursive type definitions in the same place
<kaustuv>
(of course, remember to use the 'and' keyword to link them up)
mcclurmc has joined #ocaml
<thelema>
newone: just the types you'll need in other places
<newone>
do you have a pastebin example so i get an image about that?
<newone>
ups, that was at :thelema
<thelema>
that's exactly what i pasted
<newone>
:thelema sorry i looked at your code, but didnt realised that it is a mli file
init1 has joined #ocaml
kaustuv has quit [Quit: catching a train]
Yoric has quit [Quit: Yoric]
<thelema>
yup, it's all types. In my other files, I open this file and have access to all the types
<newone>
i have to admit i never really used signatures in ocaml so i am not very familiar with it. so what i have to do now, is to write a signature of the statement module and open this signature in my Type module?
<thelema>
if you're worried at all about the signature issue, just write the types in a .ml file, and don't worry about signatures.
<newone>
:thelema but than i would have again the problem with the open
<thelema>
what's the problem with the open?
<newone>
:thelema i tried before to write different files containing just one module and open them all in the lang.ml file, but i got a syntax error
<thelema>
the syntax error doesn't mean your design is wrong, it could mean you had a typo
<thelema>
also, if you split your code into separate files, you don't need [module Foo = struct ... end] wrapping the contents - ocaml adds this automatically
<newone>
what i did is, i wrote into the lang.ml file open statement \n open type1 \n
<newone>
and the compiler complains about an syntax error
<thelema>
[open Statement\n open Type1]
<thelema>
capitalization matters
<newone>
:thelema but my file names are small letters?
<thelema>
yes, but the modules they create have capital first letters.
<newone>
and how do they map it then to the right file?
<thelema>
modules *always* have capital first letters
<thelema>
it's not allowed to have ast.ml and Ast.ml
<thelema>
(I think. At least you'll have some problem with doing this)
<thelema>
maybe it's just highly not-recommended
<thelema>
a file [foo.ml] with contents <bar> is like [module Foo = struct <bar> end]
<newone>
so although my file name is written in small letters i have to open this file name with a capitalized first letter
<thelema>
yes
<newone>
thanks, didnt know that
joewilliams_away is now known as joewilliams
<newone>
:thelema okay now the problems in the lang file disappeared, but i have an unbound type constructor in one file, to get rid of that i have to open the module where the type they need is in?
<newone>
do i have to write include module-name or open module-name?
ttamttam has quit [Remote host closed the connection]
<thelema>
use [open Module] if you need the contents of Module in this file
<newone>
:thelema i wrote right at the top of the file open Statement and there is still the error unbound type constructor
<thelema>
use [include Module] if you need to export the contents of Module *through* this file (i.e. it opens the module *and* does [type foo = Module.foo] for everything in module
<hcube>
hi! is there any haskell's fromList like function for creating Map?
<thelema>
hcube: Map.fold (curry add) Map.empty list
<hcube>
ah ok :)
<thelema>
hcube: (not exact syntax, just the idea)
<hcube>
i see, thanks
<thelema>
well, it might be correct if you're using Batteries.
<newone>
:thelema the include Module part comes in the first line of the file?
<thelema>
except it's [uncurry], not curry
<thelema>
newone: you can put it anywhere, and its effect last until the end of the module (or file)
<hcube>
and you meant List.fold
<thelema>
newone: and I recommend [open] instead of [include]
<thelema>
hcube: yeah, that too
<thelema>
List.fold_left (uncurry Map.add) Map.empty list
<newone>
:thelema still doesnt work
<thelema>
newone: Okay, the problem is that some type isn't bound. What module is that type in, and why aren't you opening that module?
<newone>
in the module parameter i have something related to the Expression module, so i wrote "open Expression" in the parameter module
<thelema>
and if all your type declarations are in one module, why are you referring to a type?
<newone>
no no, i have one attempt where i seperated all the different modules in single files
<thelema>
so in parameter.ml, you have [open Type open Expression]?
<newone>
just open Expression, because this one only needs stuff from the Expression module
thieusoai has quit [Ping timeout: 245 seconds]
<thelema>
and the unbound type is correctly defined in the Expression module? no typos?
<adrien>
anyone benchmarked List.merge vs List's rev_merge_rev which is a local function and is not exported (it's tail-rec of course, otherwise List.sort would fail quite often)
ulfdoz has joined #ocaml
<hcube>
how can i tie both vale and key type of a Map?
<hcube>
e.g. i'd like to create an empty map of string keys and string values
ygrek_ has joined #ocaml
<flux>
I don't think you can
<flux>
well, you can of course create your own module ;)
<hcube>
can you show me how can i make a Map String String module? (ocaml code)
<flux>
module Z : sig type t val empty : t val add : string -> string -> t -> t end = struct module M = Map.Make(struct type t = string let compare = compare end) type t = string M.t let empty = M.empty let add = M.add end;;
<flux>
so you need a few lets more
Yoric has joined #ocaml
<flux>
Map.S signature says type 't is polymorphic, so it cannot be used to create non-polymorphic maps
<hcube>
then how can i create an empty Map String String
<flux>
you could just instantiate a string Map and give a type alias
<flux>
so something like module StringMap = Map.Make(struct type t = string let compare = compare end) type string_string_map = string StringMap.t and use that type from thereon
<flux>
I don't think it is functionally different from what you want..
ygrek_ has quit [Ping timeout: 245 seconds]
<hcube>
it works thanks :)
ftrvxmtrx has joined #ocaml
m3ga has quit [Quit: disappearing into the sunset]
ygrek has joined #ocaml
hcube has quit [Ping timeout: 240 seconds]
init1 has quit [Quit: Quitte]
Edward__ has joined #ocaml
Yoric has quit [Quit: Yoric]
thieusoai has joined #ocaml
Snark has quit [Quit: Ex-Chat]
boscop__ has joined #ocaml
boscop_ has quit [Ping timeout: 240 seconds]
yezariaely has quit [Quit: Leaving.]
ygrek has quit [Remote host closed the connection]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
Yoric has joined #ocaml
Yoric has quit [Client Quit]
hcube has joined #ocaml
ulfdoz has quit [Ping timeout: 276 seconds]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
ccasin has quit [Quit: Leaving]
coucou747 has joined #ocaml
Modius has quit [Ping timeout: 245 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
valross has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Edward__ has quit []
valross has quit [Remote host closed the connection]