<mrvn>
source being in gui/src/Signal.ml for example.
<mrvn>
n8
talzeus has quit [Read error: Connection reset by peer]
boogie has joined #ocaml
boogie has quit [Ping timeout: 240 seconds]
talzeus has joined #ocaml
ollehar1 has joined #ocaml
ollehar has quit [Ping timeout: 252 seconds]
S11001001 has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
zpe has joined #ocaml
WraithM has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
ollehar1 has quit [Remote host closed the connection]
ygrek has joined #ocaml
nikki93 has joined #ocaml
chare has joined #ocaml
Guest97126 has quit [Ping timeout: 255 seconds]
<chare>
so why should I learn ocaml and use it over haskell?
<Drup>
I don't find in the log my answer to the last person who asked this question :(
<Drup>
chare: in order to answer : what are you looking for ?
<chare>
you tell me
<Drup>
and what language do you come from
<Drup>
no, I don't tell you what you want a programming language for =')
<chare>
i said haskell
boogie has joined #ocaml
<Drup>
you ask "haskell or ocaml", and the answer will depends of what you want do to with them.
<chare>
I already know Haskell.
<chare>
Don't know Ocaml
<chare>
tell me when you would use Ocaml over Haskell.
<Drup>
ok, I though you wanted to know which one to learn, which is a different question
<Drup>
personally, I would use ocaml all the time, but there are also good reasons to learn haskell.
<Drup>
ocaml is just more pratical to get stuff done
<Drup>
I don't like purity by default, it forces me to fiddle with monads and transformers all the time
<Drup>
I don't like lazyness by default, because it's very tedious to reason about when you want to have good performances
nikki93 has quit [Remote host closed the connection]
<Drup>
I don't like the shity module system that haskell have
jpdeplaix has quit [Ping timeout: 265 seconds]
<Drup>
I do like typeclasses :p
boogie has quit [Ping timeout: 240 seconds]
phay has joined #ocaml
<chare>
Is it true that Ocaml can be used where you would use C
<Drup>
it's a bit simplified
phay has quit [Client Quit]
<Drup>
you are not going to write a driver in ocaml, at least not easily
<Drup>
but you can certainly do a good amount of stuff that C is used for
zzing has joined #ocaml
<Drup>
(for example, some people wrote an almost OS in ocaml, it's called mirage)
<chare>
but C will still be unmatched for speed things?
<Drup>
not always
aurynj has joined #ocaml
<chare>
come on I want a less vague aswer
<Drup>
you ask very vague question and it's 4 in the morning :D
phay has joined #ocaml
<Drup>
allocation in ocaml is very cheap, it makes working with immutable data structure very efficient
<Drup>
sometime more than in C
<chare>
so in other words I'm stuck with having to use C or C++ when speed matters
<Drup>
certainly not C++, no =')
<chare>
ok link to evidence to the contrary
<Drup>
I'm not going to play the micro benchmark game with you, especially at this hour. But C++ has never been efficient in any way, only the C subset is.
<chare>
Drup: so suppose i want to make an endgame tablebase generator like https://github.com/syzygy1/tb are you saying Ocaml is a wise choice over C?
jpdeplaix has joined #ocaml
<Drup>
you don't really try to be convinced, don't you ? :)
<chare>
Drup what?
<Drup>
you start by talking about haskell then you want me to compare to an hyper specialized piece of C code that I have no idea what it his doing.
<Drup>
OCaml is on par or faster with C++/Java for efficient purposes on sequential stuff
<Drup>
no, it's not going to be as fast as C most of the time, since you can do so much dirty fine tune hard coded optimisation in C that it's ridiculous
<chare>
you letting me down I thought I could replace C with Ocaml
<Drup>
I said that it could be used instead of C most of the time
zpe has joined #ocaml
<Drup>
which is strictly true, since C is used for everything, and especially stuff that it's ill suited for.
<Drup>
and your ocaml code have a good chance to be reusable, as opposed to some C code.
<araujo>
chare, from a stronger haskell background than o'caml myself... I believe one of the appealing feature for a haskell developer is that ocaml tends to be more practical and with an easier learning curve for most of the developers, which has resulted in usually more practical tools and libs in widespread usage, so.. as a haskeller, you might have a better chance to introduce people or co-workers into the functional world :)
<araujo>
pure languages are not widely used (at least not like we would like to) because they tend to enforce a very strict way of thinking in practical terms, so languages like o'caml somehow tries to find a way in the middle
<araujo>
and that is useful too in the field
<chare>
araujo I'm looking for a speed demon to replace C
<chare>
will I forever be stuck with C?
<araujo>
chare, hehehe, I believe you could give it a try with o'caml
<araujo>
maybe is the closer and with a decent C-like speed to haskell out there
<chare>
araujo: you should go work on making OCaml compiler faster, so that we don't have to end up using C,C++, or D
boogie has joined #ocaml
<araujo>
hehe
Dongyanc1i has quit [Ping timeout: 265 seconds]
Dongyancai has joined #ocaml
<chare>
aren't you tired of using C, C++, or D?
boogie has quit [Ping timeout: 264 seconds]
<chare>
araujo you going to respond?
<araujo>
chare, away... and well, sometimes I am.. hehe :)
WraithM has joined #ocaml
chare has quit [Ping timeout: 252 seconds]
araujo has quit [Quit: Leaving]
zpe has joined #ocaml
boogie has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
nikki93 has joined #ocaml
phay has left #ocaml []
Dongyancai has quit [Ping timeout: 252 seconds]
nikki93 has quit [Remote host closed the connection]
Dongyancai has joined #ocaml
tlockney is now known as tlockney_away
mal`` has quit [Ping timeout: 264 seconds]
paolooo has joined #ocaml
mal`` has joined #ocaml
aurynj has quit [Ping timeout: 264 seconds]
yacks has joined #ocaml
aurynj has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 255 seconds]
nikki93 has joined #ocaml
boogie has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 255 seconds]
axiles has joined #ocaml
nikki93 has quit [Remote host closed the connection]
wwilly has quit [Quit: Leaving]
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
yacks has quit [Quit: Leaving]
aurynj has quit [Ping timeout: 240 seconds]
aurynj has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 252 seconds]
aurynj has quit [Ping timeout: 246 seconds]
aurynj has joined #ocaml
yacks has joined #ocaml
ygrek has joined #ocaml
boogie has joined #ocaml
aurynj has quit [Read error: Connection reset by peer]
boogie has quit [Ping timeout: 264 seconds]
Hannibal_Smith has joined #ocaml
ddosia has joined #ocaml
angerman has joined #ocaml
aurynj has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 255 seconds]
Dongyancai has quit [Ping timeout: 252 seconds]
algoriddle has quit [Ping timeout: 240 seconds]
boogie has joined #ocaml
ggole has joined #ocaml
boogie has quit [Ping timeout: 264 seconds]
tane has joined #ocaml
algoriddle has joined #ocaml
csakatoku has joined #ocaml
boogie has joined #ocaml
elfring has joined #ocaml
boogie has quit [Ping timeout: 246 seconds]
aurynj has quit [Ping timeout: 255 seconds]
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
angerman_ has joined #ocaml
patronus_ has joined #ocaml
angerman has quit [Ping timeout: 240 seconds]
algoriddle has quit [Ping timeout: 240 seconds]
algoriddle has joined #ocaml
patronus has quit [Ping timeout: 240 seconds]
ddosia has quit [Ping timeout: 240 seconds]
bjorkintosh has quit [Ping timeout: 240 seconds]
_5kg_ has joined #ocaml
AltGr has joined #ocaml
Hannibal_Smith has quit [Ping timeout: 240 seconds]
_5kg has quit [Ping timeout: 240 seconds]
seggy has quit [Ping timeout: 240 seconds]
Hannibal_Smith has joined #ocaml
maattdd has joined #ocaml
Hannibal_Smith has quit [Ping timeout: 240 seconds]
bjorkintosh has joined #ocaml
mika2 has joined #ocaml
ddosia has joined #ocaml
seggy has joined #ocaml
Hannibal_Smith has joined #ocaml
Kakadu has joined #ocaml
mika2 has quit [Quit: Leaving.]
zpe has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 255 seconds]
ontologiae has joined #ocaml
Snark has quit [Quit: leaving]
ontologiae has quit [Ping timeout: 240 seconds]
mika1 has joined #ocaml
dsheets has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 264 seconds]
dsheets has quit [Ping timeout: 264 seconds]
ollehar has joined #ocaml
segimondu has joined #ocaml
seggy has quit [Ping timeout: 246 seconds]
ollehar1 has joined #ocaml
Simn has joined #ocaml
ddosia has quit [Remote host closed the connection]
ddosia has joined #ocaml
ggole has quit [Ping timeout: 252 seconds]
lopex has quit [Write error: Connection reset by peer]
leifw has quit [Read error: Connection reset by peer]
lopex has joined #ocaml
leifw has joined #ocaml
csakatoku has quit [Remote host closed the connection]
<elfring>
The command "ocamlfind query batteries" works with an expected display.
<elfring>
A command like "ocamlfind ocamlc -package ~/.opam/packages/batteries/batteries.2.2.0 unused_return_value1.ml" is insufficient so far.
<adrien_oww>
hmm?
<adrien_oww>
man findlib.conf
<adrien_oww>
env vars
<adrien_oww>
OCAMLPATH
<adrien_oww>
This variable may contain an additional search path for package
<adrien_oww>
directories. It is treated as if the directories were prepended
<adrien_oww>
to the configuration variable path.
<adrien_oww>
OCAMLFIND_DESTDIR
<adrien_oww>
This variable overrides the configuration variable destdir.
<adrien_oww>
and I expect opam to set them when you load the environment
<adrien_oww>
and then you use "-package batteries"
skchrko has joined #ocaml
boogie has joined #ocaml
<ddosia>
Hi, I am trying to figure out how mutable variables works (in particular in records), and have a question
<ddosia>
is it possible to have such record with two fields, that one field will be shared among all variable, and other will be unique per each instance?
<ddosia>
say: type 'a timed = { item: 'a; mutable time: Time.t };;
<ddosia>
let a = {item = "aaa"; time = Time.now ()};;
<adrien_oww>
let b = { a with time = Time.now () }
<adrien_oww>
that will preserve sharing
<ddosia>
I want that field time was shared
<ddosia>
but when I do like you suggest I see that in a and in b this two fields a differs
pippijn_ is now known as pippijn
<ddosia>
I want whenever I change field a.time, b.time was changed too
<ddosia>
but in the same time I want a.item and b.item with different values
<adrien_oww>
then
<adrien_oww>
let b = { a with item = "lapin" }
<adrien_oww>
hmm
<adrien_oww>
well
boogie has quit [Ping timeout: 264 seconds]
<adrien_oww>
you'd have to check
<adrien_oww>
if that doesn't work, another solution is to have "time: Time.t ref"
<ddosia>
it does not work
<ddosia>
could you elaborate this?
Hannibal_Smith has quit [Ping timeout: 255 seconds]
<adrien_oww>
type 'a timed = { item: 'a; time: Time.t ref }
<adrien_oww>
let a = { item = "aaa"; time = ref (Time.now ()) }
<adrien_oww>
let b = { a with item = "bbb" }
dsheets has joined #ocaml
<adrien_oww>
a.time <- Time.t ()
<adrien_oww>
haven't checked it yet :)
<ddosia>
not works as well
<ddosia>
I change it to type 'a timed = { item: 'a; *mutable* time: Time.t ref }
<ddosia>
and repeat, a nd b have different values for time field after I do " a.time <- ref (Time.now ());;"
<adrien_oww>
remove the mutable
<adrien_oww>
and change <- with :=
<ddosia>
adrien_oww: now it works, now I should understand why...
shinnya has joined #ocaml
Hannibal_Smith has joined #ocaml
ggole has joined #ocaml
_andre has joined #ocaml
jonludlam has joined #ocaml
<elfring>
Would you like to give ane more hints about the cooperation of OPAM und the build parameter "package"?
ygrek has quit [Ping timeout: 252 seconds]
avsm has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 264 seconds]
paolooo has quit [Ping timeout: 245 seconds]
sepp2k has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
talzeus has quit [Remote host closed the connection]
<adrien_oww>
elfring: should be pretty close to what I mentionned
<adrien_oww>
ddosia: understood how it works?
<Drup>
elfring: ocamlfind is local package manager
<Drup>
it handle where to put and retrieve stuff in your system
<Drup>
opam manage the download of dependencies and so on
<Drup>
opam use ocamlfind on the local scale to install packages
ollehar has quit [Ping timeout: 252 seconds]
<adrien_oww>
think of ocamlfind/findlib as an OCaml version of pkg-config (and one that does more and better)
csakatoku has quit [Remote host closed the connection]
<def-lkb>
you are compiling and linking in the same pass (you should add -c as with gcc)
<Drup>
that's why I never invoke the compiler myself >_>
<def-lkb>
comparing ocamlfind/ocaml and pkg-config/gcc, -linkpkg is similar to -l…/--libs flags, -package alone is similar to -I… -D… / --cflags
<elfring>
I imagine that a single pass should be sufficient for what I would like to try out here.
stomp has quit [Ping timeout: 255 seconds]
<def-lkb>
so "ocamlfind ocamlc -package batteries -linkpkg unused_return_value1.ml" should be sufficient
stomp has joined #ocaml
Hannibal_Smith has quit [Quit: Sto andando via]
<elfring>
Thanks for your answers.
araujo has joined #ocaml
<elfring>
Are there any chances to make a message like the following easier to understand?
<elfring>
File "unused_return_value1.ml", line 10, characters 4-48:
<elfring>
Warning 10: this expression should have type unit.
<companion_cube>
how is this message not clear?
<nicoo>
elfring: Isn't it already clear ?
<companion_cube>
I guess it's foo; bar and foo isn't of type unit
<nicoo>
companion_cube: Most probably.
<flux>
well, an emacs interface might visually highlight the expression causing trouble
<flux>
other than that, it's probably as clear as it gets
<nicoo>
flux: merlin does that
ygrek has joined #ocaml
<elfring>
The real error reason in my toy example was that I did not assing the return value from the function call "Array.fold_left" to the global name "m". Are other software tools eventually clearer about unused return values?
<Drup>
elfring: if you use something like merlin, it will help you locate the error (and then figure out the cause). The cause is not always the same for this warning, so it's hard to give something universally clearer
avsm has joined #ocaml
boogie has joined #ocaml
<flux>
elfring, most often than not return values are used in functional style programs
<flux>
elfring, of course, real programs sometimes ignore return values. for that there is let _value_to_be_ignored = expr in or ignore (expr);
avsm1 has joined #ocaml
avsm1 has quit [Client Quit]
<nicoo>
flux: much better to « let _ = expr » than polute your scope, IMHO
<adrien_oww>
ddosia: basically, when you write { a with field = value }, OCaml will share "value" but "field" is still the same
<nicoo>
(though I would myself use ignore)
<adrien_oww>
erf
<adrien_oww>
ddosia: but "field" isn't
<flux>
nicoo, yes, that's a good option as well. I was actually only thinking of scenario where you still want to describe what is being returned.
<adrien_oww>
if it is mutable, the "field" pointer will be changed to another value
<adrien_oww>
but only for one struct
<flux>
nicoo, although I wouldn't really call it 'polluting', by convention you're not supposed to use _variables for other than binding
<adrien_oww>
now, if field points to a reference and you change the reference, then all the fields will see the new value since they always point to the same thing
<adrien_oww>
ddosia: however that adds one indirection
avsm has quit [Ping timeout: 264 seconds]
<flux>
(machine-generated code being the exception)
boogie has quit [Ping timeout: 240 seconds]
<Drup>
(adrien_oww, ddosia : in this case, I'm not sure the point of using a record)
<nicoo>
flux: I meant that if I read « let _foo = expr », I expect it to be used later. (Regarding the description, I would prefer a comment in that case)
aurynj has joined #ocaml
<flux>
nicoo, why? the very point of _foo is that not using _foo will not produce a warning
cantstanya has joined #ocaml
cantstanya has left #ocaml []
aurynj has quit [Client Quit]
<flux>
for example if I have a hairy patternmatching of nested tupples, I might want to use match x with (interesting1, (_name, _address, interesting2)) -> ..
<ggole>
Mmm. I'd actually be happy for using a _var to be an error.
<ggole>
(Or warning.)
cantstanya has joined #ocaml
<ddosia>
adrien_oww: I hope I got it, thanks
shinnya has quit [Ping timeout: 252 seconds]
saml has joined #ocaml
csakatoku has joined #ocaml
zpe has joined #ocaml
zpe has quit [Read error: No route to host]
zpe has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
avsm has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
jzelinskie has quit [Read error: Connection reset by peer]
jzelinskie has joined #ocaml
darkf has quit [Quit: Leaving]
WraithM has quit [Ping timeout: 252 seconds]
* adrien_oww
can't remember his reddit password anymore ='(
mreca has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
avsm has joined #ocaml
ygrek has quit [Ping timeout: 264 seconds]
freling has quit [Read error: No route to host]
boogie has joined #ocaml
mika1 has quit [Quit: Leaving.]
boogie has quit [Ping timeout: 246 seconds]
zzing has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csakatoku has quit [Remote host closed the connection]
csakatoku has joined #ocaml
csakatoku has quit [Ping timeout: 255 seconds]
divyanshu has joined #ocaml
divyanshu has quit [Client Quit]
_5kg_ has quit [Ping timeout: 264 seconds]
WraithM has joined #ocaml
samae has joined #ocaml
<samae>
As graphics crashes when I draw images successively, is there any other lib I can use to replace it?
<flux>
there are bindings to sdl
<flux>
I don't remember if it comes with many drawing primitives though
<gasche>
samae: crashes? that's weird, aren't you doing something wrong?
travisbrady has joined #ocaml
<gasche>
I used pango with some success years ago
<hcarty>
Has anyone used lacaml and Ctypes together from the same program/library? I get module conflicts.
<hcarty>
I thought that I had read something about this and a fix/work-around but I am not finding anything now.
ollehar has joined #ocaml
avsm has quit [Quit: Leaving.]
lostcuaz has joined #ocaml
<ddosia>
where should I look for documentation of Core modules? I need docs for List module
<ddosia>
adrien_oww: seems that I have nod any docs for core package. But I have docs for some of the modules though (i.e. List). is it possible to install this docs through opam?
boogie has joined #ocaml
RMacy has joined #ocaml
_2can has quit [Ping timeout: 264 seconds]
boogie has quit [Ping timeout: 252 seconds]
wwilly has joined #ocaml
_5kg_ has joined #ocaml
<samae>
gasche: pango seems dead, as many others…
<adrien_oww>
no idea
<adrien_oww>
samae: but pango is for _text_
<adrien_oww>
samae: and which others?
<companion_cube>
samae: don't know...
<nicoo>
pippijn: I know the companion_cube, yes :)
ggole has quit [Ping timeout: 246 seconds]
<hcarty>
samae: Cairo, Camlimages
S11001001 has joined #ocaml
S11001001 has quit [Changing host]
S11001001 has joined #ocaml
<hcarty>
samae: What will the PNGs contain?
<samae>
Camlimages is unmaintained since 2004 and doesn't compile here :/ hcarty
<hcarty>
samae: There is an OCaml version of the Cairo tutorial somewhere. It gives a nice overview of the library.
<adrien_oww>
samae: that camlimages is a fork of the other one
<hcarty>
samae: And for better or worse, the library you most likely want from opam is cairo2. The 'cairo' package is older and less complete.
ggole has joined #ocaml
<samae>
hcarty: and doesn't work : )
<samae>
I successfully ran an example with cairo2
<adrien_oww>
what's the issue?
* adrien_oww
trying to commute back home
<Drup>
cairo2 works quite nicely and is actively maintained
<Drup>
(understand that most issues are fixed in less than a month :p)
<adrien_oww>
actively is an understatement
<adrien_oww>
Christophe Troestler is way too reactive :P
<Drup>
it depends :p
<hcarty>
adrien_oww: Proactive too. I like using his libraries.
boogie has joined #ocaml
boogie has quit [Remote host closed the connection]
avsm has quit [Quit: Leaving.]
ygrek has joined #ocaml
mort___ has joined #ocaml
hegemoOn_ is now known as hegemoOn
jwatzman|work has joined #ocaml
<samae>
argl, no way to compile ocamlimages
<samae>
…
angerman_ has quit [Ping timeout: 264 seconds]
avsm has joined #ocaml
<adrien>
samae: what's the issue?
<samae>
Seems like there's a missing header in the source (exif_….h)
<adrien>
Enjolras will be happy to talk to you
<adrien>
Enjolras: right? :P
<adrien>
(he has a patch)
<adrien>
samae: actually
<adrien>
samae: you're using arch linux, right?
<samae>
adrien: quite right why?
<adrien>
because arch's package for libexif is broken
boogie has joined #ocaml
<samae>
argl!
<samae>
that must be it
<adrien>
mostly because upstream sources are broken
<adrien>
I was talking to Enjolras about this this very morning
<adrien>
not sure what he did
<adrien>
your /usr/lib(64)/pkgconfig/libexif.pc should have that as the last line:
<adrien>
Cflags: -I${includedir}/libexif
<samae>
oooh, well let's try it again
<samae>
It does help!
<adrien>
there's an issue in upstream camlimages when using with giflib 5.x though; the author has only giflib 4.x and noone has provided him with a patch
<samae>
Now I have the giflib problem : )
<adrien>
unless Enjolras did it this morning
<samae>
ok
<kerneis>
win 1
<kerneis>
pff, sorry
avsm has quit [Quit: Leaving.]
<kerneis>
time to go back home, I guess
<adrien>
nope
<samae>
Until then, I guess I'll push towards cairo
<gasche>
late to the party, but indeed I meant cairo, not pango
freling has joined #ocaml
<adrien>
:)
ygrek has quit [Ping timeout: 252 seconds]
nickmeharry has quit [Quit: leaving]
Kakadu has quit [Ping timeout: 245 seconds]
wwilly has quit [Ping timeout: 255 seconds]
xianxu has joined #ocaml
cdruzac has joined #ocaml
jonludlam has quit [Remote host closed the connection]
nickmeharry has joined #ocaml
Kakadu has joined #ocaml
q66 has joined #ocaml
mort___ has quit [Ping timeout: 264 seconds]
q66 has quit [Ping timeout: 252 seconds]
q66 has joined #ocaml
michel_mno is now known as michel_mno_afk
ollehar has quit [Ping timeout: 252 seconds]
Hannibal_Smith has joined #ocaml
ddosia has quit [Ping timeout: 264 seconds]
Guest97126 has joined #ocaml
<elfring>
I try out the following few lines ...
<elfring>
open Batteries
<elfring>
module My_map = Map.Make(Int)
<elfring>
let map_count dir =
<elfring>
let add_one map key = My_map.modify_def 0 key (fun n -> n + 1) map in
<elfring>
let register map name = add_one map (String.length name) in
<elfring>
let map = Array.fold_left register My_map.empty (Sys.readdir dir)
<elfring>
I get the message "Error: Syntax error" here. Is this response expected for the compiler and OCaml command line interface?
AltGr has left #ocaml []
sepp2k has quit [Quit: Konversation terminated!]
<ggole>
The last binding is incomplete
<rks`_>
elfring: no, you fucked up your installation
<rks`_>
caml error messages are usually much more descriptive
<ggole>
Presumably you need "let map = Array.fold_left register My_map.empty (Sys.readdir dir) in map" or something like that
<rks`_>
you should go on stackoverflow, I'm sure people there have had the same problem many times
<flux>
elfring, it does highlight the location of the error, though?
<rks`_>
(or you could just fix your code they way ggole says and wait for the next uninformative error message)
<flux>
(I suppose without that the error message can look even more information-free)
<elfring>
I stumbled over this special case during my OCaml experiments. An error is not reported if I append a few output expressions there.
<flux>
well, the syntax is like this
<flux>
first, modules are made of top-level statements
<flux>
like let name = expr
ddosia has joined #ocaml
<flux>
now "let name = expr in" is an experssion
<flux>
but "let name = expr" is a statement
<flux>
and you cannot have statements inside statements
<flux>
the value of "let name = expr1 in expr2" is the value of expr2
<flux>
"let name = expr" does not have a value, therefore it's a statement :)
<flux>
(I actually should have written "let name = expr1 in expr2" earlier as well)
<flux>
what you have before ;; is a 'phrase'
<flux>
phrase is either a list of top-level statements or a single expression
<flux>
so that may confuse a bit..
<flux>
but I think most people generally don't use 'top-level expressions' at all. however, they can be useful when learning, because ;; is very effective boundary for an error message. an error before ';;' cannot look like it is after it and vice versa.
<elfring>
I would not interpret the last assignment in the source code snippet as an OCaml statement so far.
<flux>
well, it is of form "let a = b", therefore it's a statement
<flux>
so if you add "in ()" it becomes an expression, therefore valid
<elfring>
Thanks for your explanation. How does the wording "statement" fit to the published OCaml grammar which mentions expressions?
<flux>
(though the rule given for 'module-items' seems a bit perplexing)
<flux>
wouldn't it suggest that 5 let a = 5 is valid ocaml.. (it's not)
<flux>
but they aren't really a formal specification of the language, but very useful regardless
<ggole>
module F = struct 5 let x = 5 end does in fact compile...
_2can has joined #ocaml
* ggole
didn't know that
<flux>
oh :)
<flux>
what.. a useless feature :)
xianxu has quit [Ping timeout: 240 seconds]
* whitequark
suggests calling such features "featureoids", similar to "factoids"
<whitequark>
e.g. "C++ template system is a featureoid"
srcerer has joined #ocaml
dsheets has quit [Ping timeout: 264 seconds]
<ggole>
Hey, I like that
dRbiG has quit [Ping timeout: 252 seconds]
dRbiG has joined #ocaml
elfring has quit [Quit: Konversation terminated!]
angerman has joined #ocaml
ikaros has joined #ocaml
pyon has quit [Quit: restart]
tlockney_away is now known as tlockney
RMacy is now known as RMacy|Away
RMacy|Away has quit []
xianxu has joined #ocaml
<ddosia>
if I want to iterate through a list and to pass some state through each iteration, what fun best to use? Also i dont interesting in this state, every iteration makes some sideeffects
<adrien>
fold
<adrien>
well
<adrien>
if it's purely a side-effect, iter should be enough
<ddosia>
iter accespts only one arg - the list item
<ddosia>
and fold returs accum
<companion_cube>
I'd say List.fold_left, and ignore the final state?
<ddosia>
and I want to write:
<ddosia>
let () = List.iter ...
<ddosia>
I wonder how to do that
<flux>
?
<Kakadu>
I also don't understand
<flux>
how to ignore the fold result?
<ddosia>
currently I do something like: let uselessvar = List.fold ... in ()
<ddosia>
yes
<Kakadu>
let _ = ...
<ddosia>
sorry I am newbie
<Kakadu>
everybody was like you)
<ggole>
ignore (List.fold ...) reads a bit strangely, though
arjunguha has joined #ocaml
<Kakadu>
What kind of side effect do you want?
<ggole>
I'd probably write let list_iter_state ... and call that.
<ddosia>
so if generalize question, how to run two functions one after another
<companion_cube>
ignore (List.fold_left ....)
<ggole>
Eh, details :)
<companion_cube>
or let _ = List.fold_left
<ddosia>
Kakadu: just printf
<companion_cube>
ddosia: and what do you carry as state?
<Kakadu>
ddosia: yes, what?
<ddosia>
I build: let rec bc = `Black :: `Blue :: `Cyan :: `Green :: `Magenta :: `Red :: `White :: `Yellow :: bc
<ddosia>
and want each iteration different color
<ggole>
companion_cube: let _ = List.fold_left has the (minor) disadvantage that you can't use it at the end of a function without an additional "in ()"
<ddosia>
so I build a simple program which reads strings, split by words and colorize each word according to this "bc" var
<Kakadu>
ddosia: Have you come here after Haskell?
<ddosia>
Kakadu: after erlang
watermind has joined #ocaml
<ddosia>
Kakadu: I would say not after but during :)
<ddosia>
Kakadu: I am not sure how it works though
<ggole>
But what happens when you need the time in your repl?!
<ddosia>
it is some kind of iterator with mutable state
<ddosia>
?
<Kakadu>
flux: useless time, useless counter, average usefule <hr>
<Kakadu>
ggole: rlwrap @@ ocaml
<ggole>
I just use emacs
<Kakadu>
ddosia: yes
<Kakadu>
The problem is that default list functions a strict
<Kakadu>
so If you execute them on infinite list they will hang
<Kakadu>
s/a/are/
tlockney is now known as tlockney_away
<Kakadu>
ddosia: do you know how to write function which returns how many times it was executed? This is the same
cdruzac has quit [Ping timeout: 246 seconds]
<ddosia>
No I am not
<Kakadu>
ddosia: btw, does your nick sohow related to soap powder?
tlockney_away is now known as tlockney
<Kakadu>
somehow*
<ddosia>
Kakadu: yeah :)
cdruzac has joined #ocaml
<ddosia>
Kakadu: In erlang we have to return two values: 1st for next element, 2nd next iterator
<ddosia>
so next() will return somenglike: (`Blue, next2 )
<ddosia>
and so on
<ggole>
You could do it that way
<Kakadu>
you can write let next xs = (List.hd xs, List.tl xs)
<Kakadu>
but I like by solution more
<Kakadu>
my*
<ddosia>
I dont understend how your solution works, and I have a problem to repeat inside mine utop
<ggole>
Or you could wrap it in an iteration function, like let iter_colors f list = let rec loop colors = function | [] -> () | x::xs -> f (List.hd colors) x; loop (List.tl colors) xs in loop bc list
<Kakadu>
ggole: he has infinite loop of colors :)
wwilly has joined #ocaml
<ggole>
Yes, that's what makes it work.
RMacy is now known as RMacy|Away
<ggole>
Otherwise you'd write a next function that matched against colors, which I think is a bit clumsy.
<ddosia>
Kakadu: type m = {mutable i: int};; let next = let a = {i = 0} in (fun () -> a.i <- (a.i + 1); a.i);;
<ddosia>
who-hoo
<Kakadu>
:)
<ddosia>
could I define a type just for this function?
<Kakadu>
if only with 1st class modules...
<Kakadu>
int ref type suits there better
ggole has quit []
RMacy is now known as RMacy|Away
RMacy|Away has quit []
RMacy has joined #ocaml
mreca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Hannibal_Smith has quit [Quit: Sto andando via]
claudiuc has quit [Read error: No route to host]
araujo has quit [Read error: Connection reset by peer]
claudiuc has joined #ocaml
araujo has joined #ocaml
xianxu has quit [Ping timeout: 252 seconds]
hegemoOn has quit [Ping timeout: 264 seconds]
tnguyen has joined #ocaml
manizzle has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
ikaros has joined #ocaml
ollehar has joined #ocaml
venk has joined #ocaml
xianxu has joined #ocaml
jonludlam has joined #ocaml
elfring has joined #ocaml
xianxu has quit [Ping timeout: 255 seconds]
xianxu has joined #ocaml
wwilly has quit [Remote host closed the connection]
RMacy is now known as RMacy|Away
RMacy|Away has quit []
* whitequark
finds himself gasping for pure functional programming for the first time in his life
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oriba has joined #ocaml
<companion_cube>
oh noes!
<whitequark>
close encounter with a language whose idea of good design is global, implicit, persistent, implementation-dependent mutable state entrenched in all interesting pathways
<whitequark>
such as, for example, "are coordinates for most commands interpreted as incremental or absolute"
<whitequark>
"are they in inches or millimeters"
<whitequark>
well, at least the dialect of gcode I'm using has proper lexical scoping, named (opposed to numbered variables), structural control flow and recursion
jwatzman|work has joined #ocaml
arjunguha has joined #ocaml
<companion_cube>
:D
<companion_cube>
I understand the reaction then
<def-lkb>
gcode is designed for primitive interpreter, not human beings
ikaros has quit [Quit: Ex-Chat]
Kakadu has quit [Quit: Konversation terminated!]
<whitequark>
def-lkb: it seems rather advanced for primitive interpreters
<whitequark>
there's a whole slew of features which CAMs don't use or need... eg, tool radius compensation
<whitequark>
or, say, inverse time mode, or constant surface speed
<def-lkb>
ok... I used tjis only one time, with some tools to abstract away gory details
<whitequark>
actually gcode is not bad at all to write by hand
<def-lkb>
but this looks like typical superposition of ill designed features:)
<whitequark>
I just wish it was much less modal
* whitequark
should fork rs274 and call it "coffeecode", complete with a hip website
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
rand000 has quit [Quit: leaving]
elfring has quit [Quit: Konversation terminated!]
ollehar1 has quit [Ping timeout: 240 seconds]
travisbrady has quit [Quit: travisbrady]
<Enjolras>
adrien: I thing you're mis-remembering, wasn't me. Probably Armael. But i'd be happy to test a patch if needed :à
axiles has quit [Remote host closed the connection]
<adrien>
damn
<adrien>
all that time during which I could have harassed Armael
<adrien>
='(
<Enjolras>
:D
<adrien>
plus I had some doubts and thought "I could and should check it"
<adrien>
and stopped thinking right after
<adrien>
anyway, good night
<Enjolras>
nite
<adrien>
Armael: I'll harass you as soon as I can :)
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ddosia has quit [Quit: Leaving.]
xianxu has quit [Ping timeout: 240 seconds]
Thooms has joined #ocaml
Thooms has quit [Client Quit]
xianxu has joined #ocaml
Guest97126 has quit [Ping timeout: 255 seconds]
Simn has quit [Quit: Leaving]
milosn has quit [Ping timeout: 255 seconds]
cyanure__ has quit [Remote host closed the connection]
milosn has joined #ocaml
S11001001 has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
segimondu is now known as segmond
darkf has joined #ocaml
hto has quit [Ping timeout: 240 seconds]
IbnFirnas_ has quit [Read error: Connection reset by peer]
hto has joined #ocaml
IbnFirnas_ has joined #ocaml
maattdd has quit [Ping timeout: 240 seconds]
Nuki has joined #ocaml
nikki93 has joined #ocaml
Nuki has quit [Quit: Page closed]
csakatoku has joined #ocaml
Nuki has joined #ocaml
csakatoku has quit [Remote host closed the connection]
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
csakatoku has joined #ocaml
travisbrady has joined #ocaml
csakatoku has quit [Remote host closed the connection]