ulfdoz has quit [Read error: 60 (Operation timed out)]
ulfdoz_ is now known as ulfdoz
Associat0r has joined #ocaml
tmaedaZ is now known as tmaeda0
tmaeda0 is now known as tmaeda_
tmaeda_ is now known as tmaedaZ
rcloud has joined #ocaml
tmaedaZ is now known as tmaeda_
bzzbzz has quit ["leaving"]
verte has joined #ocaml
kaustuv_` has joined #ocaml
kaustuv_ has quit [Read error: 110 (Connection timed out)]
ski_ has quit ["Lost terminal"]
tmaeda_ is now known as tmaeda
caligula__ has joined #ocaml
caligula_ has quit [Connection timed out]
schme has quit ["leaving"]
schme has joined #ocaml
thrasibule has quit [Read error: 110 (Connection timed out)]
gaze___ has joined #ocaml
rcloud has quit [Read error: 54 (Connection reset by peer)]
rcloud has joined #ocaml
gaze___ has quit []
rcloud has quit [Remote closed the connection]
mlak has joined #ocaml
mlak has left #ocaml []
thrasibule has joined #ocaml
gaze___ has joined #ocaml
<gaze___>
hey, would someone mind helping me figure out how to structure the dependency tree for this build system I'm trying to come up with? Really I'm trying to get a feeling for the functional way of doing things and this seemed like an interesting problem
<palomer>
try asking specific questions
<gaze___>
hmm, okay. Say I have files foo, bar, and baz, foo and bar depend on baz. I try recursing through the tree to resolve dependencies, I resolve baz for foo, resolve foo, and then i have to resolve bar which depends on baz but has already been built. How would I record that baz has been built? I suppose I'm just really uncomfortable with the pure functional way of doing things
<gaze___>
sorry if this is really really general
<palomer>
step 1: define the types that represent your data structures
<palomer>
step 2: define the functions that act on those types
<palomer>
step 3: profit!
<palomer>
that's the functional way
<gaze___>
okay in that case it's the immutability that's weirding me out the most
<palomer>
in your case you might just add an extra argument which contains all the built modules sofar
<palomer>
(to whatever function is building)
* palomer
goes to bed
<palomer>
night
<gaze___>
so I guess i'll define an object... which is something that depends on zero or more other objects... it can be in a resolved or unresolved state... then you have some function that's guaranteed to resolve or error out on that object
<gaze___>
balls. okay.
thrasibule has quit [Read error: 145 (Connection timed out)]
Associat0r has quit []
kaustuv_ has joined #ocaml
kaustuv_` has quit [Read error: 104 (Connection reset by peer)]
ski_ has joined #ocaml
Submarine has joined #ocaml
f[x] has joined #ocaml
_zack has joined #ocaml
ttamttam has joined #ocaml
komar__ has joined #ocaml
sgnb has quit [Read error: 104 (Connection reset by peer)]
sgnb has joined #ocaml
ttamttam1 has joined #ocaml
Submarine has quit [Remote closed the connection]
onigiri has quit []
Yoric[DT] has joined #ocaml
f[x] has quit [Read error: 110 (Connection timed out)]
ulfdoz has quit [hubbard.freenode.net irc.freenode.net]
mattam has quit [hubbard.freenode.net irc.freenode.net]
haelix_ has quit [hubbard.freenode.net irc.freenode.net]
Hadaka has quit [hubbard.freenode.net irc.freenode.net]
M| has quit [hubbard.freenode.net irc.freenode.net]
Hadaka_ has joined #ocaml
ulfdoz has joined #ocaml
Hadaka_ is now known as Hadaka
M| has joined #ocaml
mattam has joined #ocaml
haelix has joined #ocaml
_JusSx_ has joined #ocaml
hkBst has joined #ocaml
Summermute has joined #ocaml
knightrage is now known as knight\zzz
mishok13 has joined #ocaml
mihamina has joined #ocaml
<mihamina>
Hi all
<mihamina>
would you know a simplistic tutorial on queriyn PGSQL thourgh Ocaml?
<mihamina>
by the way, when, in a ml file, it says "open Postgrsql", what do I have to perform in the interactive toplevel
<mihamina>
?
<mihamina>
in order to load this module
<flux>
mihamina, #require "findlib";; - stick this to your ~/.ocamliit also
<flux>
I mean ~/.ocamlinit
<flux>
argh
<flux>
#use "topfind";;
<flux>
_after_ that, #require "packagename";;, such as postgresql (if that's its name) will do the trick
<gildor_>
flux: you mean "#use "topfind";;
<gildor_>
(#require is not an ocaml toplevel directive without topfind)
<mihamina>
does it mean this function will be always called?
<flux>
yes
<mihamina>
I dont understand the meaning of "let _ ="
<flux>
mihamina, as you might notice, there are no expressions in the top level of the code
<flux>
mihamina, only statements, such as open, let a = b, etc
<mihamina>
yep
<flux>
note that let a = b in c is not a statement, but an expression
<flux>
mihamina, you might also find that the file has no ;; -sequence in it
<flux>
mihamina, because you need to use ;; only if you use expressions as top-level statements in a file
<flux>
many (most? all?) advanced ocaml-coders just use top-level statements in their programs. one advantage is that you can stick them inside a module Foo = struct .. end as-is if you want
<flux>
one disadvantage is that sometimes error messages can be less well placed
<flux>
(one annoying example is the additional ; at the end of a value definition, because that error will likely appear after the next value definition)
<mihamina>
I understand "let _ =" as the "void main()" in C
<flux>
well, not really
<flux>
it's like: #include <math.h> float v = sin(42); int main() { .. }
<flux>
that's akin to let v = sin 42.0
<flux>
however, in ocaml the expression can be more complicated
<flux>
and in ocaml you don't need to bind the value of the expression into any value
<flux>
so while float _ = sin(42) will probably compile (although I think technically that's invalid..), symbol _ cannot be reused again
<flux>
in ocaml it just won't be bind
<flux>
there is no 'main' in ocaml per se: files are just read from the top to the bottom and values are bind to their names per te let name = value -statements
<flux>
if the expression 'value' has side effects, they will be performed
<flux>
like this: int value = puts("hello world") is like let value = print_endline "hello world"
<flux>
in imaginary syntax you could do this in C: int value = do { puts("hello"); puts("world"); return 0; };
<mihamina>
ooookay
<flux>
but, alas, that's not valid syntax. in ocaml however you can wriet: let avlue = (print_endline "hello"; print_endline "world")
<flux>
which is the same as: let value = print_endline "hello"; print_endline "world"
<flux>
but if you discard the value, it's just let _ = ..
<flux>
coming any more clear?-)
<mihamina>
let _ =... is then a way to > /dev/null
<mihamina>
well... I am going to have lunch and re-read again. then, i will com back with my postgresql tries :-P
fremo has quit [Remote closed the connection]
fremo has joined #ocaml
fremo is now known as Guest1908
th1 has joined #ocaml
<kaustuv_>
(very delayed) <julm> one may be reluctant to pass through the camlp4 machinery (which makes things slower)
<kaustuv_>
Is that really the main objection to camlp4?
kaustuv_ is now known as kaustuv
<flux>
well, my ocamldep takes longer..
<flux>
however I think a legitimate reason is that it changes some error messages. and imo for the worse.
<_JusSx_>
I defined a record type r in a.ml file. I can call record item in file b.ml only if i open module a. How can i avoid opening module?
<_JusSx_>
i can record item in this way A.r.item where A is module, r record, item record item
<_JusSx_>
compiler says that mp3tag.key is unbound. If I open Tag module in db.ml file all is ok
<_JusSx_>
I don't like to open modules
Camarade_Tux has quit ["leaving"]
Camarade_Tux has joined #ocaml
gaze___ has quit []
tmaeda is now known as tmaedaZ
<thelema>
_JusSx_: mp3tag.Tag.key
<_JusSx_>
thelema: thank you very much
Yoric[DT] has quit ["Ex-Chat"]
<thelema>
it's wierd having namespacing on the record fields, but it's needed because of how the type inference works
<flux>
I was just thinking if that still would be fixable, and what would need to be given up..
<thelema>
There's a tradeoff to be had. Is the solution a type annotation somewhere to set the inference engine straight on what type the record is?
mishok13 has quit [hubbard.freenode.net irc.freenode.net]
schme has quit [hubbard.freenode.net irc.freenode.net]
caligula__ has quit [hubbard.freenode.net irc.freenode.net]
Ched has quit [hubbard.freenode.net irc.freenode.net]
Jedai has quit [hubbard.freenode.net irc.freenode.net]
mal`` has quit [hubbard.freenode.net irc.freenode.net]
lanaer has quit [hubbard.freenode.net irc.freenode.net]
gildor_ has quit [hubbard.freenode.net irc.freenode.net]
whale has quit [hubbard.freenode.net irc.freenode.net]
<flux>
I suppose we would need to be sure that cut-pasted code fragments still work as they worked in the original place
<flux>
so no 'spooky action in the distance' :)
<thelema>
then my solution is insufficient.
<thelema>
because the type system can act at quite a distance
<flux>
I suppose the final solution would be something akin to objects or sml's records, but that would be too big of a change
mishok13 has joined #ocaml
schme has joined #ocaml
caligula__ has joined #ocaml
Ched has joined #ocaml
Jedai has joined #ocaml
mal`` has joined #ocaml
lanaer has joined #ocaml
whale has joined #ocaml
gildor_ has joined #ocaml
_andre has joined #ocaml
<flux>
one alternative: a smart IDE extension that automatically fixes foo.bar into foo.Module.bar iff Module is the only module that introduces field name bar :P
<thelema>
if that's a requirement, then we're just arging syntax, or we're giving up O(1) record field access.
<thelema>
it would add that annotation, and grey it out so it's not highlighted
<flux>
I wonder if anything came out of that ocamlwizard project
<flux>
last post on forums 2008 -> that would be, no (other than the stuff they already released)
<kaustuv>
SML's records are not necessarily better than OCaml's
<flux>
qtcaml dev mailing list archives appear dead too. none of the interesting projects are advancing :(
<flux>
how about the concurrent gc..
* thelema
likes the idea of generating n codeblocks for n different record types, and linking in the right one later.
caligula__ has quit [Remote closed the connection]
caligula__ has joined #ocaml
<thelema>
that said, there's a limit - if we only know about one .foo field, we can't produce code that works for all records with a .foo field
<kaustuv>
In principle you can keep the field order in a special field, like how methods are kept in objects. But that would just make fat records, and reusing field names in the same module is not necessarily good style.
<thelema>
it's not necessarily bad, as with 2d_point and 3d_point both having .x and .y
<kaustuv>
But it can lead to confusion when seeing a function like let norm pt = sqrt (sqr(pt.x) + sqr(pt.y)). Is it a bug or not?
<flux>
I've just ended up prefixing fields names for example like type entry = { e_score : float; .. }
<thelema>
flux: hungarian notation for field names - ick. I thought we had good type systems to let the computer do this work.
<thelema>
kaustuv: yes, you would need an annotation that pt must be a 2d_point
<kaustuv>
type systems don't magically solve naming issues
flx_ has joined #ocaml
<thelema>
naming issues don't substitute for a good type system.
<thelema>
s/issues/workarounds/
flux has quit [Read error: 54 (Connection reset by peer)]
flx_ is now known as flux
<kaustuv>
You can do what you want with:
<kaustuv>
module 2d = struct type pt = { x : float ; y : float } end ;; module 3d = struct type pt = { x : float ; y : float ; z : float } end
<kaustuv>
Then you have pt.2d.x and pt.3d.x
<kaustuv>
instead of pt.2d_x and pt.3d_x
<kaustuv>
(except you'd have to name them D2 and D3, of course)
<flux>
which I think brings us to the beginning of this discussion :)
<thelema>
yes, but this still seems like I'm doing too much of the work. Just like using r_val and c_val to keep my row numbers and column numbers separate instead of letting the computer distinguish them on the type level.
<kaustuv>
If there were no type inference, you'd be right. Problem is, OCaml has type inference, and it is not always clear what the programmer meant.
<kaustuv>
And indeed, when he's writing rubbish
<thelema>
yes, there's the rub - if you have to give a lot of info, the compiler can check for contradictions
<thelema>
but if you don't give much info, the compiler will usually do best effort to turn what you gave into a program
<thelema>
which might be better effort than you expected.
<kaustuv>
The SML equivalent to the above is to have:
<kaustuv>
datatype D2 = D2 of {x : real, y : real} and D3 = D3 of {x : real, y : real, z : real}
<kaustuv>
That is, you say the "D2" annotation once, instead of at every field projection
* thelema
wouldn't mind requiring type annotations in some places
<thelema>
as long as it's not too much.
<thelema>
but then we're back to using the module name as a mini-type annotation.
<flux>
kaustuv, but what is tehe type of pt then?
<kaustuv>
flux: the type of pt is {x : real, y : real}
<thelema>
because that's really the place to put it, right where it's being used.
<kaustuv>
flux: in SML record types are not treated as generative like in ocaml
<flux>
kaustuv, and you can have a function that works on that? and it's incompatible with D3's pt?
<kaustuv>
flux: yes, you can't run two_d_foo on a D3
<flux>
I was under the understanding they'd work something like ocaml objects, but apparently not quite?
<kaustuv>
No, they are nothing like ocaml objects because there's no row polymorphism
<kaustuv>
You can't write: fun get_x k = #x k
<flux>
so that wouldn't compile?
<kaustuv>
Yes, that won't compile. The compiler must be told enough to know what *all* the fields of k are before it will do a projection
<flux>
but you can annotate it and then it compiles?
<kaustuv>
Sure, that's what the D2 and D3 constructors do.
<kaustuv>
D2 has type {x : real, y : real} -> D2
<flux>
hm, I thought they were pattern matching
<flux>
maybe I should take a look at SML some day, just to know what I'm talking about :)
<kaustuv>
It's a fun language with atrocious tools
f[x] has joined #ocaml
tmaedaZ is now known as tmaeda
whale has quit [hubbard.freenode.net irc.freenode.net]
mal`` has quit [hubbard.freenode.net irc.freenode.net]
mishok13 has quit [hubbard.freenode.net irc.freenode.net]
gildor_ has quit [hubbard.freenode.net irc.freenode.net]
Jedai has quit [hubbard.freenode.net irc.freenode.net]
schme has quit [hubbard.freenode.net irc.freenode.net]
Ched has quit [hubbard.freenode.net irc.freenode.net]
lanaer has quit [hubbard.freenode.net irc.freenode.net]
mishok13 has joined #ocaml
schme has joined #ocaml
Ched has joined #ocaml
Jedai has joined #ocaml
mal`` has joined #ocaml
lanaer has joined #ocaml
whale has joined #ocaml
gildor_ has joined #ocaml
schme has quit [Connection reset by peer]
schme has joined #ocaml
komar__ has quit [Read error: 110 (Connection timed out)]
willb has joined #ocaml
kaustuv_ has joined #ocaml
f[x] has quit [Read error: 110 (Connection timed out)]
kaustuv has quit [Read error: 110 (Connection timed out)]
komar__ has joined #ocaml
noj has quit [Read error: 110 (Connection timed out)]
Amorphous has quit [Read error: 110 (Connection timed out)]
Amorphous has joined #ocaml
_zack has quit [Remote closed the connection]
_zack has joined #ocaml
derdon has joined #ocaml
tmaeda is now known as tmaedaZ
mihamina has left #ocaml []
<thelema>
flux: I like the idea of the compiler integrated into the editor - it could put the type annotations into the source automatically when possible, but fold them hidden - maybe viewable on mouseover or have an + Expand types + mode
<thelema>
I like the idea of compilation returning more than just an executable, but also a modified version of the source
<flux>
thelema, some may hold the opinion that if a language needs a special tool to be edited, there's something to be fixed in the language, though :)
<thelema>
The modified version of the source would be text, same as the source.
<thelema>
your editor just has to reload the file.
<thelema>
hmm, having the compiler modify the input file....
<thelema>
you could have its default be that, with an option to put the annotated source into a separate file for editors ready to deal with thta.
<thelema>
but ocaml is sorta doing this now, with -dtypes and all.
tmaedaZ is now known as tmaeda
Tinos has joined #ocaml
julm_ has joined #ocaml
julm has quit [Read error: 60 (Operation timed out)]
bluestorm has joined #ocaml
bluestorm has quit [Read error: 104 (Connection reset by peer)]
petchema has quit [Remote closed the connection]
rcloud has joined #ocaml
ski_ has quit ["Lost terminal"]
tmaeda0 has joined #ocaml
Submarine has joined #ocaml
tmaeda has quit [Read error: 110 (Connection timed out)]
Narrenschiff has joined #ocaml
julm has joined #ocaml
f[x] has joined #ocaml
<thelema>
hmm, I think I need some type magic to do this.
julm_ has quit [Read error: 110 (Connection timed out)]
<thelema>
I have 4 types, in two categories:
<thelema>
type foo = `A of x * x list | `B of y * x list | `C of x * foo list | `D of y * foo list
komar___ has joined #ocaml
verte has quit [Read error: 104 (Connection reset by peer)]
verte_ has joined #ocaml
<thelema>
I've factored this into foo1 = `A ... | `B ... and foo2 = `C ... | `D ...
verte_ is now known as verte
<thelema>
but I'd like a function that does A -> C, B -> D to have a better type than foo -> foo
<thelema>
any ideas?
xevz has left #ocaml []
komar__ has quit [Read error: 113 (No route to host)]
<Tinos>
Would it be relevant to do:
<Tinos>
type 'a foo' = `A of x * 'a list | `B of y * 'a list
<Tinos>
and then
<Tinos>
type foo1 = x foo'
<Tinos>
type foo2 = foo foo'
<Tinos>
?
<Tinos>
Not sure I really guess what's your situation
komar___ is now known as komar_
smimou has joined #ocaml
ttamttam1 has quit ["Leaving."]
tmaeda0 is now known as tmaedaZ
tmaedaZ is now known as tmaeda0
<thelema>
I did that at first with non-polymorphic variants, and wasn't happy with the results - I think I see now how to do this for both dimensions at once with polymorphic variants
<thelema>
Tinos: thank you
<thelema>
or maybe not - I don't think I can have the right tags.
<thelema>
yup, I think I can only do 1 dimension of tagging, there's no way to have a pair of tags
<thelema>
a pair of `X tags
aij has quit ["Changing server"]
<Tinos>
I definitely don't get what you mean :)
gaze___ has joined #ocaml
aij has joined #ocaml
<thelema>
I want to have (`X,`R) foo = x * foo list
<thelema>
(`Y,`R) foo = y * foo list
<thelema>
(`X,`F) foo = x * x list
<thelema>
(`Y,`F) foo = y * x list
<thelema>
so I can have a function ('a, `F) foo -> ('a, `R) foo
<thelema>
turning a flat foo into a recursive foo
<thelema>
but keeping its `X or `Y
Tinos has quit []
Narrenschiff has quit []
Narrenschiff has joined #ocaml
onigiri has joined #ocaml
_zack has quit ["Leaving."]
schme has quit [Read error: 104 (Connection reset by peer)]
Narrenschiff has quit []
schme has joined #ocaml
robocop has joined #ocaml
knight\zzz is now known as knightrage
<robocop>
hello
<robocop>
I want to try batteries
<robocop>
I installed it, but I can't launch a toplevel
<thelema>
ocamlfind batteries/ocaml
<robocop>
I trying :
<robocop>
rlwrap ocamlfind batteries/ocaml
<robocop>
/usr/lib/ocaml/site-lib/batteries/ocaml: line 2: /usr/lib/batteries/batteries/toplevel.top: Aucun fichier ou dossier de ce type
<thelema>
"file or folder not found"?
<robocop>
yes
<robocop>
Any idea ?
<thelema>
some configuration problem, I think...
<thelema>
do you have a toplevel.top file somewhere in /usr/lib?
<thelema>
Mine's in /usr/local/lib/ocaml/3.10.2/batteries/toplevel.top
<robocop>
I've got this : ./usr/lib/ocaml/site-lib/batteries/toplevel.top
<det>
Ocaml is hard to compare with Python because Ocaml is statically typed
<derdon>
eh, I think OCaml's unit is Python's types.NoneType, isn't it?
<derdon>
None is a singleton
<det>
None serves many roles in Python that Ocaml has separate concepts for
<derdon>
okay, but I got the idea of it
<det>
unit serves 1 role of None
<det>
option serves another
ulfdoz has quit [Remote closed the connection]
ulfdoz has joined #ocaml
f[x] has quit [Read error: 110 (Connection timed out)]
rcloud has left #ocaml []
palomer is now known as shazam
<shazam>
anyone heard of incorporating ML style typing with context free grammars?
slash_ has joined #ocaml
<hcarty>
flux: ping
<flux>
pong
<hcarty>
flux: Do you still have your PLplot build tree around?
<flux>
yes
<hcarty>
Could you pastebin the output from "ldd -r dllplplot_stubs.so" from plplot-source-dir/build-dir/bindings/ocaml/_build/?
<flux>
hcarty, modeemi.fi/~flux/foo
<hcarty>
flux: Ok, thanks
<flux>
I'm on ubuntu 8.10 if that's of any interest
<hcarty>
There seems to be some error/problem with rpath and ocamlmklib 3.10.x
<hcarty>
flux: Definitely. Thanks.
<flux>
ocamlmklib, version 3.10.2
<hcarty>
Ideally, "ldd -r" should show the build-tree dllplplot_stubs.so looking for the build-tree libplplotd.so.9
<hcarty>
It does on my system (Ubuntu 9.04, OCaml 3.11.1).
<hcarty>
flux: Thank you very much!
<flux>
hcarty, happy to be of help :)
<hcarty>
flux: If it is of interest, I added function plotting (f(x)) to the Quick_plot module :-)
<flux>
hcarty, ooh
<flux>
I don't have immediate plotting needs, though
<flux>
unless.. I wanted to plot highscore table with highscore, number of errors, time spent, characters per second (it's an abcdefg..-typing game for the new-student-fair of tut)
<hcarty>
I plan/hope to fix up a few consistency issues (order of function parameters mainly) and then make a general announcement/RFC.
<flux>
any suggestions what kind of plot would be nice?-)
<flux>
(actually I also have a timestamp for each pressed key, that could produce something interesting)
<hcarty>
flux: :-) high score on one vertical axis, number of errors on the other.
<hcarty>
And then, stacked underneath, the same with time spent on one axis and characters/sec on the other.
<flux>
maybe I could produce a bunch of stats
<flux>
for example time-of-day versus score
<flux>
number of errors per number of games played per time unit
<robocop>
thelema: do you know what when I type "ocamlfind batteries/ocaml" I've got : "/usr/lib/ocaml/site-lib/batteries/ocaml: line 2: /usr/lib/batteries/batteries/toplevel.top: File not found" ?
<flux>
if I want to put that kind of enhancement in, the deadline would be on thursday ;)
<robocop>
by the way, rlwrap /usr/lib/ocaml/site-lib/batteries/toplevel.top /usr/lib/ocaml/site-lib/batteries/top.ml work/
<robocop>
*-/
<hcarty>
robocop: It sounds like a path was set incorrectly somewhere, either at build or install time. I'm not sure how or why that would happen though.
<robocop>
okey
<robocop>
I should install ocaml with godi ?
brooksbp has joined #ocaml
<brooksbp>
is there Eval in OCaml?
<flux>
brooksbp, no. well, you could write the source to a file, compile it and then dynamically link it in, if you wanted.
<brooksbp>
I'm trying to understand the typechecker/interpreter implementations of TAPL and am struggling learning OCaml
<flux>
how would eval help you?
<brooksbp>
there's a source line: " | Eval(fi,t) ->" and I'm wondering if Eval is something built in to OCaml
<brooksbp>
because grepping Eval reveals nothing useful in the remaining source files
_andre has quit ["Lost terminal"]
<hcarty>
robocop: I would recommend using GODI.
<hcarty>
robocop: It makes it much easier to keep the base OCaml install in order.
gaze___ has quit [Read error: 60 (Operation timed out)]
ulfdoz has quit [Read error: 110 (Connection timed out)]
<flux>
brooksbp, no, Eval isn't defined in OCaml
<flux>
brooksbp, I would expect there is a type with constructor Eval defined somewhere in the code you're reading
gaze___ has joined #ocaml
<brooksbp>
let _ = blah in expr
Submarine has quit [Remote closed the connection]
<brooksbp>
what's the '_' mean?
<flux>
ignore the return value
<flux>
that is the same as ignore (blah); expr
<flux>
simply sequencing expressions with ; will cause a warning from the compiler if the expression doesn't return a unit value
<brooksbp>
that feels like an imperative lang feature?
<flux>
yes
<flux>
off to sleep ->
ttamttam has quit ["Leaving."]
<robocop>
okey hcarty, thanks
_zack has joined #ocaml
Ched has quit ["Ex-Chat"]
shazam is now known as palomer
Snark has quit ["Ex-Chat"]
brooksbp has quit [Read error: 110 (Connection timed out)]
robocop has quit [Remote closed the connection]
hkBst has quit [Read error: 104 (Connection reset by peer)]
tvn2009 has joined #ocaml
<tvn2009>
is there a function in ocaml standard library that tests if a string s is a substring of a string s' ?
<hcarty>
tvn2009: Str may have something, and if not then the PCRE bindings would certainly allow checking for this.
<tvn2009>
is Str part of the std library ? I thought it's in the ext lib right ?
smimou has quit ["bli"]
<tvn2009>
oh wait -- nm
<tvn2009>
it's in the std lib
<tvn2009>
thanks :]
_zack has quit ["Leaving."]
noj has joined #ocaml
<hcarty>
tvn2009: It does have to be linked/loaded separately, but it is included as part of the official OCaml distribution.
Summermute66 has joined #ocaml
<tvn2009>
can you tell me how to load Str from the intepreter ?
jlouis has quit [Remote closed the connection]
jlouis has joined #ocaml
<hcarty>
tvn2009: Do you have findlib installed?
<hcarty>
If so, then "#use "topfind";;", "#require "str";;"
<tvn2009>
I don't think I have it
<hcarty>
If not, then other steps are required which I don't remember :-)
<hcarty>
I highly recommend installing it.
<tvn2009>
I can use it in my .ml by calling open Str; then Str.something
_JusSx_ has quit ["leaving"]
<tvn2009>
but if I want to do in the interpreter then I don't know how
<hcarty>
You don't need to, and probably should not, have an "open Str" line
<tvn2009>
I did
<hcarty>
You shouldn't, under most circumstances :-)
<tvn2009>
# Str.regexp "a";;
<tvn2009>
Reference to undefined global `Str'
<hcarty>
"open Str" allows you to use any type or value in the Str module without needing the "Str." prefix.
<tvn2009>
oh
<tvn2009>
right
<hcarty>
It can make things easier, but it also leads to name clashes.
<tvn2009>
yeh - nonethless I still can't use stuff in Str from the intepreter
<hcarty>
Simply using "Str.foo" is generally enough. Some modules are designed to be used with open (ex. Bigarray).
<hcarty>
You should install findlib
<hcarty>
Otherwise, I think the steps are something like "#directory "+str";;"
<hcarty>
#load "str.cma";;
<hcarty>
You may or may not need the #directory command. It has been a long time since I have used a toplevel without findlib or the Str module.
<tvn2009>
I am not sure if I have findlib or not --- how to check ?
<hcarty>
How did you install OCaml?
<hcarty>
One way to check is to type "#use "topfind";;" in the toplevel. If you get an error then it is not installed. If you get a bunch of non-error output then it is installed.
<tvn2009>
aha
<tvn2009>
I think I got it
<tvn2009>
thanks !
<tvn2009>
it's installed
<tvn2009>
great -- thanks so much
Summermute66 has quit []
<hcarty>
You're welcome. #require "some-library";; is quite a useful thing to have around :-)
<tvn2009>
but that's only used in the interpreter right ? the #require "something" ;; ?
<hcarty>
Yes
<hcarty>
When compiling, you can use the
<hcarty>
"ocamlfind" command to get similar features.
<tvn2009>
I seem to be able to compile file using Str without calling that feature
<hcarty>
For example, "ocamlfind ocamlopt -package str -linkpkg foo.ml" would produce a.out from foo.ml, linking in the items required for the str package.
<tvn2009>
I just do Str.some_function
<hcarty>
It may be found automatically since it is included with OCaml? I'm not sure.
<tvn2009>
yeh I don't know either -- but that's oka
Summermute has quit [Read error: 110 (Connection timed out)]
<tvn2009>
I got it work in both interpreter & compiler
<tvn2009>
so that's ok for now
sramsay has quit ["Leaving"]
cognacc has quit [Read error: 110 (Connection timed out)]