dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
chessguy_away is now known as chessguy
dibblego has joined #ocaml
ita|zzz is now known as ita
omnipath has joined #ocaml
omnipath has left #ocaml []
mikeX has joined #ocaml
idiotequa has joined #ocaml
<idiotequa> So does anyone know anything about Ocaml Lex and Yak?
<ita> idiotequa: ask your question
<idiotequa> Back
<idiotequa> sorry
<idiotequa> Well I guess people are familiar
<idiotequa> I'm new to this room so I was wanting to get a general sense of the knowledge of Ocaml
<idiotequa> since I'm a beginner to this as well as functional programming
<ita> idiotequa: if you need an example of ocamllex/ocamlyacc use, i have one -> http://freehackers.org/~tnagy/eqchem-0.5.0.tar.bz2 (look in the subdirectory, there is a parser for chemical equations)
<mikeX> idiotequa: there's a tutorial available for both ocamllex and ocamlyacc
<idiotequa> Okay thanks guys
<mikeX> google them
<idiotequa> Yeah I have a program to do for homework and it involves changing up the Calculator program they have on the site
<idiotequa> I have you create a "validity test" and put in boolean functions
<idiotequa> have to *
<ita> idiotequa: when you have some work to do, just do it
<idiotequa> oh I know
<idiotequa> I'm not asking anyone to code anything for me
<idiotequa> sorry if it came across that way
<dbueno_> idiotequa: Boolean functions in a calculator? You mean pseudoboolean?
<idiotequa> possibly
<dbueno_> I'm just wondering how the boolean functions interact with arithmetic expressions.
<dbueno_> If they're pseudoboolean (0-1 valued), it makes sense.
mikeX has quit ["zzzZZ"]
<dbueno_> 1 + f(3)
ita has quit ["zzz"]
<dbueno_> Could simplify to 1 + true (doesn't make sense) or 1 + 1 (does).
<dbueno_> I'm just splitting semantic hairs.
<idiotequa> I think so
<idiotequa> it's like...
<idiotequa> P v Q -> -Q -> P
<idiotequa> returns true
<dbueno_> Oh, so a validity test.
<dbueno_> ... like you wrote above.
<dbueno_> But how does this interact with the "Calculator"?
<idiotequa> (P -> Q) & Q -> P
<idiotequa> returns false
<idiotequa> yeah a test
<idiotequa> ropositions may contain the constants 0 and
<idiotequa> 1 (representing false and true), parentheses for grouping, single
<idiotequa> uppercase letters as variables, and the following operators, listed
<idiotequa> from lowest to highest precedence
<idiotequa> ops are things like ==, ->, v, &, -p
pango_ has joined #ocaml
pango has quit [Remote closed the connection]
idiotequa has quit [Read error: 110 (Connection timed out)]
chessguy2 has joined #ocaml
chessguy has quit [Nick collision from services.]
chessguy2 is now known as chessguy
shawn_ is now known as shawn
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Try something fresh"]
batdog is now known as batdog|gone
joshcryer has joined #ocaml
sponge45 has joined #ocaml
Smerdyakov has quit ["Leaving"]
bohanlon has joined #ocaml
bohanlon has quit [Read error: 104 (Connection reset by peer)]
jewel has joined #ocaml
jdev has joined #ocaml
bohanlon has joined #ocaml
kilimanjaro has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
ktne has joined #ocaml
bohanlon has quit [Client Quit]
bohanlon has joined #ocaml
shawn has joined #ocaml
punisher has joined #ocaml
punisher has quit []
<flux__> hmm.. I think it could be useful, if patterns were first-class citizens. is there a language that does this? something like let matcher p v w = match v with \p x when x = w -> true else false in matcher (Str _) (Str "Hello") "Hello" would work then..
<ktne> heya flux__
<ktne> i don't really understand what you mean
<ktne> you mean to have programmable match?
<ktne> like to send the match context as a variable?
<ktne> you can do that using a function
<flux__> yes, but it's less convenient
<ktne> a function that defines just the match and then use that with currying, or i'm wrong?
<ktne> hmm, you can't define just the match
<ktne> the thing is that i'm not exactly sure what you mean :)
<ktne> but remember that you need type inference to work, so any addition to the language but support type inference
<ktne> i'm not sure if first class patterns would support type inference
<flux__> well, you could have functions like let str_of s = match s with Str x -> Some x | _ -> None let int_of s = match s with Int x -> Some x | _ -> None
<pango_> flux__: I've heard compiling 'match'es is non trivial, as it does important test optimizations, so separate cases may lose some of then 'identity' in generated code
<pango_> s/then/their/
<pango_> flux__: btw, the question was asked in beginners list, found that yesterday
<flux__> fun timing
<pango_> flux__: (not something recent; I was doing a search on tail recursivity, and found that)
b00t has joined #ocaml
<flux__> ..and after those functions you could do let matcher f v w = match f v with Some x when x = w -> true | _ -> false, but passing and using multiple patterns that way becomes inconvenient, because you can't use 'match'
<pango_> couldn't find theorical knowledge on the tail rec topic, but still interesting informations
<pango_> like, tail recursive version of functions may be something like 15% slower than "naive" implementation on small cases
<flux__> I suppose most of these tricks could be achieved with camlp4, but with extra syntax
<pango_> with an inversion of trends "around 2^12 recursive function calls"
<pango_> where tail rec version then can get much faster (and eventually non tail rec simply fails, obviously)
<pango_> so converting to tail rec "for the sake of optimization" shouldn't be done blindly
dibblego has quit [Read error: 110 (Connection timed out)]
<mellum> pango_: I don't see that. Why would tail recursion ever be slower?
slipstream has joined #ocaml
slipstream-- has quit [Read error: 145 (Connection timed out)]
pango_ has quit ["brb"]
pango has joined #ocaml
sponge45 has quit ["zzzzzzzz"]
b00t has quit [Client Quit]
<mellum> I don't get that. Which value is stored on the stack in fold1 and on the heap in fold2?
<ktne> hi mellum
ertai has quit [Client Quit]
dancor has joined #ocaml
<dancor> is there an import Longname as Shrt;; syntax
<dancor> sorry
<dancor> s/import/open
<mellum> in fact when I look at the assembly, none of the two versions does any heap allocation whatsoever.
<ktne> isn't the goal of tail recursive stuff to avoid heap&stack allocations?
<ktne> doing recursive computations in constant space
<flux__> dancor, module Shrt = LongName
<mellum> ktne: no. the point is to avoid stack allocations.
<dancor> flux__: oh, i don't even need open Mod unless i want to drop Mod. do id
<dancor> do i
<flux__> dancor, no
<dancor> sweet
<dancor> is module A = B expensive
<flux__> not at all
<flux__> from the performance point of view it's a no-op
<dancor> sweet
<flux__> note that if you don't open a Module and it has records, you will need to refer to them as value.Module.field
<dancor> ah
<dancor> cool
* dancor likes name spacing
<dancor> what's the right way to use png images and sdl in ocaml
<dancor> i know there is sdl-image but i don't thing there are ocaml bindings
<dancor> s/thing/think
<flux__> isn't there?
<dancor> hm let me check again
<flux__> I've used sdl and bitmaps with ocaml-sdl
<flux__> it actually works in windows too
<dancor> hm the gentoo linux package ocamlsdl depends on sdl-image, but i don't see anything in http://ocamlsdl.sourceforge.net/doc/html/index.html
<flux__> my ocamlsdl has:
<flux__> sdl.sdlimage (version: n/a)
<dancor> oh cool
<dancor> i guess it's just not documented yet or something
<flux__> what do you want to do with it? it atleast has sdlloader.mli:val load_image : string -> Sdlvideo.surface
<flux__> it doesn't appear to have its own sdlvideo-module though
<dancor> just read pngs
<flux__> that should do it then
<dancor> cool
Snark has joined #ocaml
<dancor> Error while linking obj/sdl.cmo: Reference to undefined global `Sdlloader'
<dancor> is it possible the name has changed
<dancor> i guess i can find the source
<flux__> it's in the documentation url you mentioned
<flux__> Sdlloader-module
meng has joined #ocaml
<dancor> so why would ocamlfind ocamlc -package sdl -c -o obj/sdl.cmo -linkpkg src/sdl.ml
<dancor> explode on module Sdll = Sdlloader;;
<dancor> it likes module Sdlv = Sdlvideo;;
<dancor> but not loader
<dancor> i checked the source and sdlloader.ml exists just like sdlvideo.ml
<flux__> dancor, try -package sdl,sdl.sdlvideo
<dancor> Uncaught exception: Fl_topo.Inconsistent_ordering
<dancor> happens with '-package sdl -package sdl.sdlloader' too
<dancor> is that a double inclusion error
<flux__> I haven't seen it
<flux__> maybe the package is somehow broken :-o
<flux__> PACKAGES=-package sdl,sdl.sdlttf,sdl.sdlimage,unix,threads
<flux__> works for me
vadimtk has joined #ocaml
<dancor> woah. sdl.sdlimage works
<dancor> does the ref to sdlloader
<dancor> ok
<dancor> i guess that makes sense
<dancor> i guess sdlimage is not in by default in some way
<dancor> that sdlvideo is
b00t has joined #ocaml
meng has quit []
priyanka has joined #ocaml
priyanka has left #ocaml []
chessguy has joined #ocaml
DRMacIve1 is now known as DRMacIver
dbueno_ has quit ["Leaving"]
gene9 has joined #ocaml
<gene9> Hi, how can I match something like a "(int * int) list" in function? http://pastebin.ca/183934
<ktne> type My_type = int * int;;
<ktne> no
<ktne> hmm
<ktne> you just define a type with the right variant
<ktne> you could just use an integer operator in the function
<ktne> this way the type inference will make sure that ('a * 'a) list is always (int * int) list
<gene9> hmm. it looks like it doesn't work. http://pastebin.ca/183936
<pango> I think f a:t1 reads as (f a):t1
<pango> try f (a:t1), I guess that's what you meant
<gene9> pango, omg, thank you, you'rintf nonsense?
<mellum> Smerdyakov: because it's much much shorter
<mellum> and easier to read
<Smerdyakov> Not even close.
<Smerdyakov> Compare:
<Smerdyakov> printf "%d is %s!" x y;
<Smerdyakov> print [d x, " is ", y, "!"]
<mellum> Okay, now make the integer zero-filled to 3 digits.
<Smerdyakov> print [d0 3 x, " is ", y, "!"]
<mellum> No, this is just reinventing the wheel. Printf is just fine.
<Smerdyakov> Printf is less desirable, because the arguments are separated from the descriptions of how to print them.
<Smerdyakov> AND it needs special support from the language.
<mellum> I still prefer it. Probably a matter of taste.
<mellum> Oh, and it can easily be i18n'd, while yours cannot.
<Smerdyakov> What is that?
<mellum> Internationalization
<flux__> mellum, if you refer to retrieving format strings from a database, I don't think so
<Smerdyakov> Yeah. In OCaml, formats must be known at compile time.
<flux__> there could be a function like format_of_string_with_template "%d%s%d" (find_string "FOO") which would solve that, but I'm not sure it would be any better than just using lists :)
<mellum> Smerdyakov: Oh, right. That would thwart this.
<mellum> Oh well, I don't care about i18n anyway :)
<Smerdyakov> Format strings are essentially functions in a special programming language. Serializing and deserializing them is no easier/harder than doing the same for arbitrary lists in the style I gave.
<flux__> (although I prefer printf too: less ",",","-stuff)
<Smerdyakov> flux__, easy to solve with macros.
<flux__> also I think I actually LIKE the values are elsewhere :)
<flux__> hm, is there a language extension that would provide a similar mechanism, usable with your own stuff?
<Smerdyakov> It's trivial to compile printf into it.
<flux__> I suppose so, but I haven't done any camlp4-stuff :)
<flux__> actually, if you scroll a few pages back, I have a related problem..
<Smerdyakov> Sorry, I must go now.
<flux__> I found the gettext-bindings for ocaml
<flux__> the first function is:
<flux__> let format_of_string x =
<flux__> Obj.magic x
<flux__> \o/
<flux__> I suppose it might have a proof somewhere that it doesn't do anything wrong.. even though I somehow doubt it
<flux__> actually, it could very well have that proof
smimou has joined #ocaml
postalchris has joined #ocaml
pango has quit ["Leaving"]
pango has joined #ocaml
vadimtk has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
jajs has quit ["Leaving"]
shawn has joined #ocaml
batdog is now known as batdog|gone
bluestorm is now known as bluestorm_aw
chessguy has joined #ocaml
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- The professional IRC Client"]
jajs has joined #ocaml
lmbdwr has joined #ocaml
seto has joined #ocaml
Snark has quit ["Leaving"]
<seto> hi all
<seto> I search people who uses vim for editing ocaml, I need an easy way to test my ocaml code in vim, to view debug, and to test line per line if it's possible, but don't find many documentation about that
<dbueno> Emacs can do that.
* dbueno ducks
<seto> yeah, ok
<pango> where is nattfodd when you need him :)
<seto> nattfodd is a vim addict ?
<nattfodd> pango: yes?
<pango> nattfodd: any idea about seto question?
<nattfodd> heh, I'm feeling watched
<nattfodd> seto: in short, it's not easy
<nattfodd> I'm usually using a toplevel in another term with big #load "bli.cmo"
<nattfodd> I did some of the interactive stuff with a lisp toplevel though
<nattfodd> but it was complex to set up and not really practical
romildo has joined #ocaml
<romildo> Hi.
<romildo> How can I get the current directory as an absolute path, in a portable way?
<romildo> I am asking because Filename.current_dir_name is "the conventional name for the current directory (e.g. . in Unix)", and that is not enough for me. I need the abolute path of the current directory.
<seto> nattfodd: hmm ok, and about editing project and have a debugger ? you use the makeprg variable or something else ?
mikeX_ is now known as mikeX
<pango> romildo: Unix.getcwd () ?
<romildo> pango: Is it portable? My program is supposed to run at least on both Linux and Windows.
<nattfodd> seto: huh?
<nattfodd> can you restate, please?
<seto> nattfodd: sorry for my bad english.. (you don't speek french?), I only want to compile my file for ocaml, but for now I use :!ocaml < % , I think you know a better way so I ask it
<nattfodd> seto: yes, I am french too, but this is an english chan...
<pango> seto: ocaml is the toplevel interpreter
<nattfodd> seto: ah, I always make a Makefile
<nattfodd> and ocamlc
<pango> seto: ocamlc and ocamlopt are the bytecode and native compilers, respectively
<seto> nattfodd: I think it's the good way, do you have a short makefile for little plroject (like one file :D) .. I go search on the web if not
<nattfodd> seto: sure
<nattfodd> one sec
<pango> seto: that's a Makefile using ocamldep
<pango> btw $(OCAMLFLAGS) is used twice, I guess the second should be $(OCAMLOPTFLAGS)
<romildo> pango: I need the absolute name of a file for use with GtkFileChooser (from lablgtk). I have just a relative name. So I need the current directory name to build its absolute name. glib has g_get_current_dir and g_build_filename. But it seems that they have not been considered in lablgtk. Any comments?
<nattfodd> you need to add the "missing" filenames
<nattfodd> hum, actually wait
<nattfodd> it's scp'ing
<pango> romildo: Filename.concat ? Not sure it'll do what you want, though
<seto> ok thx nattfodd, thx pango
<nattfodd> hum, I don't know what's wrong with scp today, so use http://zakathfr.free.fr/Make.ocaml
<nattfodd> seto: out of curiosity, are you a student somewhere?
batdog|gone is now known as batdog
chessguy has joined #ocaml
<seto> nattfodd: hmm, yeah, in m1 in poitiers.. are you a teacher in my university ;D ?
<nattfodd> heh no :)
<nattfodd> I'm in m2 in paris
<seto> student too .. well
<nattfodd> but I heard that the new l3 at the ens lyon were all using vim, so I wanted to check :)
<seto> in my university .. only emacs, and some java ide .. so I am alone
<nattfodd> try to convert people
<nattfodd> it usually works pretty well, especially as (g)vim is so much better looking than emacs
<mellum> Yeah, you'll be much more productive with a slick looking editor
<seto> yeah.. but it's difficult, for now, in my 4 university years, I convert 20 people to use linux, and 5 to use debian.. but nobody follow me in vim
<nattfodd> mellum: not to use, but it's a good argument to make people at least try
<beschmi> seto: did you try http://www.bononia.it/~zack/wowcamldebug.en.html for debugging
jajs has quit ["Leaving"]
<beschmi> i use emacs for editing code, so i never tried it
<nattfodd> beschmi: but that's only for ocamldebug
<beschmi> i only read the first question where he asked for a debugger
<nattfodd> beschmi: I suspect what he wants is more an interactive ocamltop inside vim than an embedding of ocamldebug
<seto> yeah, but something to debug will be a good tool
<nattfodd> well, at least for me, ocamldebug is always the very last tool I use
<nattfodd> after everything else has failed
<seto> for now, I have the vim error windows, and seem to help me debugging
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Go on, try it!"]
dan2 has quit [Remote closed the connection]
postalchris has quit ["Leaving."]
romildo has quit ["Leaving"]
smimou has quit ["bli"]
bluestorm_aw has quit ["Konversation terminated!"]
shawn has quit [Connection timed out]
shawn has joined #ocaml
batdog is now known as batdog|gone
chessguy has joined #ocaml
mikeX_ has joined #ocaml
mikeX has quit [Nick collision from services.]
mikeX_ is now known as mikeX