flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.01.0 http://bit.ly/1851A3R | http://www.ocaml.org | Public logs at http://tunes.org/~nef/logs/ocaml/
kyrylo has quit [Ping timeout: 245 seconds]
zpe has joined #ocaml
csakatoku has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
ygrek has joined #ocaml
thomasga has joined #ocaml
introom has joined #ocaml
ollehar has quit [Ping timeout: 252 seconds]
Simn has quit [Quit: Leaving]
thomasga has quit [Ping timeout: 264 seconds]
ygrek has quit [Ping timeout: 264 seconds]
tulloch has joined #ocaml
ygrek has joined #ocaml
talzeus_ has joined #ocaml
talzeus__ has joined #ocaml
talzeus_ has quit [Ping timeout: 240 seconds]
csakatoku has quit [Remote host closed the connection]
csakatoku has joined #ocaml
Nahra has quit [Ping timeout: 245 seconds]
Nahra has joined #ocaml
thomasga has joined #ocaml
nikki93_ has quit [Remote host closed the connection]
nikki93 has joined #ocaml
tulloch has quit [Ping timeout: 264 seconds]
arjunguha has joined #ocaml
thomasga has quit [Read error: Operation timed out]
csakatoku has quit [Remote host closed the connection]
wolfnn has quit [Quit: Leaving.]
lostcuaz has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arjunguha has joined #ocaml
thomasga has joined #ocaml
jao has quit [Ping timeout: 260 seconds]
thomasga has quit [Ping timeout: 246 seconds]
tulloch has joined #ocaml
tulloch has quit [Ping timeout: 260 seconds]
ggole has joined #ocaml
csakatoku has joined #ocaml
shinnya has quit [Quit: ZNC - http://znc.in]
hellome has quit [Remote host closed the connection]
nikki93 has quit [Remote host closed the connection]
csakatoku has quit [Remote host closed the connection]
tulloch has joined #ocaml
nikki93 has joined #ocaml
csakatoku has joined #ocaml
yacks has joined #ocaml
dant3 has quit [Remote host closed the connection]
dant3 has joined #ocaml
dant3 has quit [Read error: Operation timed out]
thomasga has joined #ocaml
milosn has joined #ocaml
Eyyub has joined #ocaml
nikki93 has quit [Remote host closed the connection]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arjunguha has joined #ocaml
arjunguha has quit [Client Quit]
arjunguha has joined #ocaml
milosn has quit [Quit: leaving]
ygrek has quit [Ping timeout: 245 seconds]
thomasga has quit [Ping timeout: 272 seconds]
csakatoku has quit [Ping timeout: 245 seconds]
csakatoku has joined #ocaml
nikki93 has joined #ocaml
SrPx has joined #ocaml
lostcuaz has quit [Quit: Textual IRC Client: www.textualapp.com]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<SrPx> Hello, may I ask a few questions? I'm looking for a very simple language that is as close to untyped lambda calculus as possible, that offers a very fast compiler from it to machine code. I want to use that language as a compiler target for my toy functional language. Would you guys recommend anything?
Kakadu has joined #ocaml
MiggyX has joined #ocaml
talzeus__ has quit [Read error: Connection reset by peer]
<MiggyX> Hi guys, does anyone know if there is a full libpcap binding for OCaml? I've so far only been able to find ocaml-format... :)
ygrek has joined #ocaml
yacks has quit [Quit: Leaving]
csakatok_ has joined #ocaml
dant3 has joined #ocaml
csakatoku has quit [Ping timeout: 272 seconds]
tulloch has quit [Ping timeout: 272 seconds]
ygrek has quit [Ping timeout: 272 seconds]
dant3 has quit [Ping timeout: 246 seconds]
dant3 has joined #ocaml
nisstyre has quit [Quit: Leaving]
thomasga has joined #ocaml
ygrek has joined #ocaml
<MiggyX> Kakadu, looks like that was pcap-format before it was renamed. I guess I can try and follow chapter 19 from real world haskell and see if I can implement part of libpcap :)
<Kakadu> ALso you can try to ask in mail-list
<MiggyX> thanks - just trying to get my teeth into it. Seems a really neat language :)
<Kakadu> the best language I've ever seen :)
<MiggyX> Do you use it professionally?
kyrylo has joined #ocaml
<Kakadu> nope
<Kakadu> If you study OCaml you should be ready: If you tell some people that you know something about functional programming, they will think that you are a psycho
<MiggyX> lol, I use Erlang in my day job :)
<MiggyX> it's great for "big" apps, but not so useful when you want a single executable :)
<Kakadu> Well, you are in better situation than me :)
thomasga has quit [Read error: Operation timed out]
tulloch has joined #ocaml
kyrylo has quit [Ping timeout: 264 seconds]
AltGr has joined #ocaml
dant3 has quit [Remote host closed the connection]
dant3 has joined #ocaml
tulloch has quit [Ping timeout: 272 seconds]
<smondet_> MiggyX: there was a binding to libpcap (for capture) a while ago (I used it a lot)
<MiggyX> smondet_, any idea what it was called?
<smondet_> `pcap` :)
<MiggyX> ah :)
<smondet_> i knew I had it somewhere: http://seb.mondet.org/promiwag/doc/Build.html
<smondet_> (look for MLpcap on the page)
<smondet_> ah the link to MLpcap is dead :-/
dant3 has quit [Remote host closed the connection]
dant3_ has joined #ocaml
thomasga has joined #ocaml
<smondet_> MiggyX: debian still has the source: http://packages.qa.debian.org/m/mlpcap.html
tulloch has joined #ocaml
_5kg has quit [Read error: Connection reset by peer]
<MiggyX> smondet_, nice, thanks!
tovarish has joined #ocaml
_5kg has joined #ocaml
ulfdoz has joined #ocaml
<MiggyX> wonder why they stopped maintaining it...
<smondet_> it was a pretty dirty binding
<MiggyX> I was thinking of doing it with Ctypes and Foreign
<smondet_> maybe a modern binding would not hurt indeed
<smondet_> using bigarray instead of that ugly hack with strings
<MiggyX> from what I've read, bigarray doesn't have to copy data whereas strings do... ?
<smondet_> I haven't touched it in a few years but I remember the pcap buffers could easily make the process segfault
<MiggyX> oh?
<smondet_> yes, but in the case of mlpcap, they used strings while avoiding one copy or something
<MiggyX> that sounds painful :)
<smondet_> and the website that had some little documentation is down :D
<MiggyX> well the libpcap api is pretty straight forward... famous last words and all that ;)
<ousado> why would strings have to be copied?
SrPx has quit [Ping timeout: 272 seconds]
<companion_cube> o/
<smondet_> ousado: strings in ocaml are moved around by the GC, they have their length encoded and so on, unlike C ones
<smondet_> MiggyX: http://anonscm.debian.org/gitweb/?p=pkg-ocaml-maint/packages/mlpcap.git;a=blob;f=tests/pcap_loop.ml;h=e55cedec61eb5512532991d5abf03fcfc6ef1291;hb=HEAD
<ousado> right
<ousado> the GC
<ousado> wasn't thinking of that
<MiggyX> nice, thanks :)
<smondet_> MiggyX: the guy uses String.unsafe_get in the pcap_loop callback because of that hack on the string type
<ousado> is it true that ocaml strings are actually arrays of refs?
<companion_cube> not they're not
<smondet_> ousado: no
<companion_cube> they are arrays of bytes
<MiggyX> hmm, hopefully with Ctypes I can do something a bit cleaner
<ousado> they say "Efficient strings are so important for the efficiency of so many programs that each character of an OCaml string is actually a reference; see References below."
<ousado> but that sounds like a bad idea
<tovarish> maybe they just mean that strings are mutable
gasche_ has quit [Ping timeout: 245 seconds]
<tovarish> (you can change any char of a string)
<ousado> yes, but they mention mutability separately
<tovarish> but internally they haven't references, just a good old char *
dant3_ has quit [Remote host closed the connection]
<MiggyX> might be useful to add some types to it too, so you can pass in a packet and match on whether it's ethernet and then IP and then TCP / UDP etc. Would be simple checks but might make coding with it much ncier
<MiggyX> nicer
<smondet_> MiggyX: I would say that identifying/parsing packets is the job of another (independent) library
<smondet_> (you cannot reliabliy identify UDP packets withouta full IP parsing + GRE tunnels + a lot of corner cases + ...)
pminten has joined #ocaml
demonimin has quit [Ping timeout: 246 seconds]
Simn has joined #ocaml
<MiggyX> Fair enough - I guess I'm thinking simpler use cases then :)
kyrylo has joined #ocaml
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
kyrylo has quit [Ping timeout: 252 seconds]
dant3 has joined #ocaml
tulloch has quit [Ping timeout: 272 seconds]
zpe has quit [Ping timeout: 264 seconds]
demonimin has joined #ocaml
thomasga has quit [Quit: Leaving.]
pik has joined #ocaml
<pik> hello world
<pik> I'm in trouble with ulex
<pik> is there a simple way to have multibytes unicode characters in the regexps other than using codepoint ?
<pik> (which are not quite human readable)
smondet_ is now known as smondet
netsecparano has joined #ocaml
<pik> oh it is actually working when the input buffer is treated as latin1...
_andre has joined #ocaml
csakatok_ has quit [Remote host closed the connection]
pik has quit [Quit: Page closed]
csakatoku has joined #ocaml
ygrek has quit [Ping timeout: 272 seconds]
milosn has joined #ocaml
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
csakatoku has quit [Remote host closed the connection]
zpe has joined #ocaml
tulloch has joined #ocaml
csakatoku has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
tulloch has quit [Ping timeout: 252 seconds]
csakatoku has quit [Ping timeout: 272 seconds]
gasche has joined #ocaml
dant3 has quit [Remote host closed the connection]
Eyyub has quit [Ping timeout: 252 seconds]
dant3 has joined #ocaml
introom has quit [Ping timeout: 265 seconds]
Eyyub has joined #ocaml
nikki93 has quit [Remote host closed the connection]
introom has joined #ocaml
pminten has quit [Quit: Leaving]
MiggyX has quit [Quit: Leaving]
ulfdoz has quit [Ping timeout: 272 seconds]
Thooms has joined #ocaml
ulfdoz has joined #ocaml
dant3 has quit [Remote host closed the connection]
arjunguha has joined #ocaml
zpe has joined #ocaml
k4nar_ has joined #ocaml
demonimin_ has joined #ocaml
ousado_ has joined #ocaml
zpe has quit [Ping timeout: 265 seconds]
pippijn_ has joined #ocaml
ia0_ has joined #ocaml
adrien_ has joined #ocaml
osnr_ has joined #ocaml
Thooms` has joined #ocaml
aggelos_ has joined #ocaml
Druup has joined #ocaml
rwmjones_ has joined #ocaml
rainbyte16 has joined #ocaml
Drup has quit [Ping timeout: 272 seconds]
pippijn has quit [Ping timeout: 272 seconds]
ia0 has quit [Ping timeout: 272 seconds]
aggelos has quit [Ping timeout: 272 seconds]
adrien has quit [Ping timeout: 272 seconds]
IbnFirnas_ has quit [Ping timeout: 272 seconds]
osnr has quit [Ping timeout: 272 seconds]
Thooms has quit [Ping timeout: 272 seconds]
demonimin has quit [Ping timeout: 272 seconds]
ousado has quit [Ping timeout: 272 seconds]
rwmjones has quit [Ping timeout: 272 seconds]
rainbyte has quit [Ping timeout: 272 seconds]
k4nar has quit [Ping timeout: 272 seconds]
IbnFirnas_ has joined #ocaml
IbnFirnas_ has quit [Changing host]
IbnFirnas_ has joined #ocaml
dant3 has joined #ocaml
tov has quit [Excess Flood]
dant3 has quit [Read error: Connection reset by peer]
tov has joined #ocaml
dant3 has joined #ocaml
NoNNaN has joined #ocaml
Thooms` has quit [Quit: WeeChat 0.3.8]
dant3 has quit [Remote host closed the connection]
tovarish has quit [Quit: Leaving]
dant3 has joined #ocaml
rand000 has joined #ocaml
Eyyub has quit [Quit: Lost terminal]
Eyyub has joined #ocaml
skchrko has joined #ocaml
ollehar has joined #ocaml
darkf has quit [Quit: Leaving]
talzeus_ has joined #ocaml
strobegen has joined #ocaml
strobegen has quit [Remote host closed the connection]
talzeus__ has joined #ocaml
Eyyub has quit [Quit: Lost terminal]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
talzeus_ has quit [Ping timeout: 272 seconds]
<bernardofpc> I am facing huge alloc's with ZArith
<bernardofpc> i have written a (very naïve) digit-extraction algorithm by repeated division
<bernardofpc> (all this base 10, so the digits go to an int list)
<bernardofpc> I have relatively huge numbers, with something like 20k digits
<bernardofpc> I guess that OCaml-ZArith will allocate the blocs for huge numbers direcly in the major heap
dant3 has quit [Remote host closed the connection]
<companion_cube> wow, 20k digits
<bernardofpc> the problem is that it apparentl y does not "free" all the intermediate numbers from the big division
<bernardofpc> each number uses ~ 1k-64bit words
<bernardofpc> so the overhead if no number gets free'd is 20k * 1k * 64 bits = 160 M
<bernardofpc> (divide by 2 to get the right arith sequence sum)
arjunguha has joined #ocaml
<ggole> bernardofpc: if the numbers are temporary, it seems like you should rearrange things such that they are unreachable as soon as possible.
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bernardofpc> ggole: http://ocaml.xelpaste.net/8850 -> I guess the numbers should be gone after each iteration, don't they ?
<ggole> Yeah, looks like it.
malo has quit [Quit: Leaving]
<bernardofpc> http://ocaml.xelpaste.net/8851 -> Before each print_stat, I did a Gc.major () to ensure the major heap is "clean"
ulfdoz has quit [Ping timeout: 272 seconds]
talzeus__ is now known as talzeus_
<bernardofpc> yet I get something like 2M words in it after producing a list of 10k digits
dant3 has joined #ocaml
<bernardofpc> and each successive call to this function (in a for i = 1 to 10 loop, i not bound inside) makes this += 2M
<ggole> Sounds like a leak.
<ggole> What is zarith, exactly?
<ggole> Is it a C library?
dant3 has quit [Ping timeout: 272 seconds]
pminten has joined #ocaml
dant3 has joined #ocaml
mreca has joined #ocaml
tovarish has joined #ocaml
pippijn_ is now known as pippijn
saml has joined #ocaml
arjunguha has joined #ocaml
rand000 has quit [Ping timeout: 252 seconds]
ulfdoz has joined #ocaml
tulloch has joined #ocaml
dant3 has quit [Remote host closed the connection]
<bernardofpc> zarith is an interface to gmp, written in C, I guess
<bernardofpc> I mean, it has caml_z.c which has many functions using CAMLprim, Long_Val &c, and z.mlp z.mlip which I guess are the caml interfaces
<ggole> Right.
<ggole> I would guess that it has a bug.
mcclurmc has joined #ocaml
rand000 has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thomasga has joined #ocaml
lostcuaz has joined #ocaml
pango has quit [*.net *.split]
esden has quit [*.net *.split]
tautologico has quit [*.net *.split]
thomasga has quit [Ping timeout: 264 seconds]
pminten has quit [Quit: Leaving]
pango has joined #ocaml
esden has joined #ocaml
tautologico has joined #ocaml
dant3 has joined #ocaml
arjunguha has joined #ocaml
Kakadu has quit [Quit: Page closed]
Simn has quit [Ping timeout: 246 seconds]
Druup is now known as Drup
demonimin_ has quit [Ping timeout: 264 seconds]
tulloch has quit [Ping timeout: 272 seconds]
Simn has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pminten has joined #ocaml
dant3 has quit [Remote host closed the connection]
dant3 has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
metasyntax has joined #ocaml
arjunguha has joined #ocaml
mcclurmc has joined #ocaml
dant3 has quit [Ping timeout: 248 seconds]
<bernardofpc> ggole: sounds like it... but I can't find a way to submit a bug to their page https://forge.ocamlcore.org/projects/zarith/... is there some other ?
<ggole> Check on github, maybe
<ggole> I'm afraid I'm not familiar with the library.
<companion_cube> doesn't work?
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kakadu has joined #ocaml
<bernardofpc> I find no place to report a bug
<bernardofpc> s/place/link/
<bernardofpc> maybe I'd have to sign in ?
ollehar has quit [Ping timeout: 252 seconds]
<companion_cube> possibly
introom has quit [Ping timeout: 252 seconds]
demonimin has joined #ocaml
<bernardofpc> grmbl
netsecparano has quit [Ping timeout: 272 seconds]
mjf42_ has joined #ocaml
dant3 has joined #ocaml
mjf42_ has quit [Read error: Connection reset by peer]
rainbyte16 has quit [Quit: Leaving]
rainbyte has joined #ocaml
mjf42_ has joined #ocaml
mjf42_ has quit [Client Quit]
avsm has joined #ocaml
mjf42_ has joined #ocaml
mjf42_ has quit [Client Quit]
mjf42_ has joined #ocaml
dant3 has quit [Ping timeout: 272 seconds]
mjf42_ has quit [Client Quit]
arjunguha has joined #ocaml
mjf42_ has joined #ocaml
mjf42_ has quit [Client Quit]
mjf42_ has joined #ocaml
mjf42_ has quit [Client Quit]
mjf42_ has joined #ocaml
<dsheets> is it possible to fake generative functors somehow?
<dsheets> I've got an edsl with a polymorphic opaque data type and I put each edsl program in a functor which takes a module with the signature of the language
<companion_cube> you mean functors of which distinct applications give incompatible types?
<dsheets> companion_cube, yes
mcclurmc has quit [Remote host closed the connection]
<companion_cube> if you cast the functor's output into a signature that has an opaque type...
<companion_cube> module type FOO = sig type t end;; module A = (F(X) : FOO);; module B = (F(X) : FOO);; <--- A.t and B.t are incompatible
<dsheets> hmmm... that is an interesting idea. i will play with that
mcclurmc has joined #ocaml
<dsheets> i think that may solve my problem, companion_cube, thanks
pminten has quit [Quit: Leaving]
mcclurmc has quit [Ping timeout: 272 seconds]
malvarez has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thomasga has joined #ocaml
tulloch has joined #ocaml
tulloch has quit [Ping timeout: 272 seconds]
axiles has joined #ocaml
Axord has quit [Quit: I'm sure it's perfectly safe]
tane has joined #ocaml
dant3 has joined #ocaml
dant3 has quit [Read error: Connection reset by peer]
dant3 has joined #ocaml
<avsm> dsheets: also note in 4.02.0dev http://caml.inria.fr/mantis/view.php?id=5905
dant3 has quit [Read error: Operation timed out]
Eyyub has joined #ocaml
mcclurmc has joined #ocaml
<dsheets> avsm, hmmm yes... i need to study this behavior more closely. right now, i have a mutability/closure problem that i can't seem to shake
<dsheets> thanks for the link
talzeus_ has quit [Read error: Connection reset by peer]
ollehar has joined #ocaml
malvarez has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
rand000 has quit [Ping timeout: 272 seconds]
mcclurmc has quit [Ping timeout: 272 seconds]
malvarez has joined #ocaml
pminten has joined #ocaml
tovarish has quit [Quit: Leaving]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
avsm has quit [Quit: Leaving.]
philed has joined #ocaml
dant3 has joined #ocaml
arjunguha has joined #ocaml
malvarez|2 has joined #ocaml
malvarez has quit [Read error: Connection reset by peer]
philed has left #ocaml []
dant3 has quit [Ping timeout: 272 seconds]
avsm has joined #ocaml
pminten has quit [Quit: Leaving]
avsm has quit [Client Quit]
malvarez|2 has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
malvarez has joined #ocaml
boogie has joined #ocaml
thomasga1 has joined #ocaml
thomasga has quit [Read error: Connection reset by peer]
dant3 has joined #ocaml
dant3 has quit [Ping timeout: 265 seconds]
Eyyub has quit [Read error: Operation timed out]
jao has quit [Ping timeout: 240 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
Thooms has joined #ocaml
Thooms has quit [Remote host closed the connection]
snyp has joined #ocaml
Thooms has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellazh has joined #ocaml
malvarez has quit [Read error: Connection reset by peer]
malvarez has joined #ocaml
arjunguha has joined #ocaml
ellazh has quit [Remote host closed the connection]
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wladron has joined #ocaml
wladron has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
ulfdoz has quit [Ping timeout: 246 seconds]
dant3 has joined #ocaml
snyp has quit [Quit: K Bye]
dant3 has quit [Ping timeout: 272 seconds]
ggole has quit []
ollehar has quit [Ping timeout: 252 seconds]
tovarish has joined #ocaml
hellome has joined #ocaml
smerz has joined #ocaml
ulfdoz has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_andre has quit [Quit: leaving]
malvarez has quit [Read error: Connection reset by peer]
malvarez has joined #ocaml
malvarez has quit [Read error: Connection reset by peer]
malvarez has joined #ocaml
ollehar has joined #ocaml
rand000 has joined #ocaml
smerz_ has joined #ocaml
skchrko has quit [Quit: Leaving]
malvarez has quit [Ping timeout: 248 seconds]
arjunguha has joined #ocaml
dant3 has joined #ocaml
dant3 has quit [Ping timeout: 240 seconds]
avsm has joined #ocaml
avsm has quit [Client Quit]
avsm has joined #ocaml
avsm has quit [Quit: Leaving.]
rand000 has quit [Ping timeout: 272 seconds]
rand000 has joined #ocaml
avsm has joined #ocaml
pango has quit [Ping timeout: 246 seconds]
pango has joined #ocaml
dant3 has joined #ocaml
dant3 has quit [Ping timeout: 260 seconds]
Kakadu has quit []
lostcuaz has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
lostcuaz has quit [Ping timeout: 252 seconds]
tovarish has quit [Quit: Leaving]
lostcuaz has joined #ocaml
pango has quit [Read error: Operation timed out]
pango has joined #ocaml
mjf42_ has quit [Quit: Ex-Chat]
lostcuaz has quit [Ping timeout: 252 seconds]
dRbiG has joined #ocaml
WraithM has quit [Quit: leaving]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
axiles has quit [Remote host closed the connection]
dant3 has joined #ocaml
lostcuaz has joined #ocaml
dant3 has quit [Ping timeout: 252 seconds]
WraithM has joined #ocaml
mcclurmc has joined #ocaml
saml has quit [Quit: Leaving]
mcclurmc has quit [Remote host closed the connection]
nisstyre has joined #ocaml
dant3 has joined #ocaml
dant3 has quit [Ping timeout: 253 seconds]
arjunguha has joined #ocaml
arjunguha has quit [Client Quit]
mcclurmc has joined #ocaml
tane has quit [Quit: Verlassend]
AltGr has left #ocaml []
kyrylo has joined #ocaml
darkf has joined #ocaml
kyrylo has quit [Quit: Don't give up! Tell ya neighbour, tell ya friend...]
mreca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kyrylo has joined #ocaml
zpe has joined #ocaml
arjunguha has joined #ocaml
thomasga1 has quit [Quit: Leaving.]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
pango has quit [Ping timeout: 272 seconds]
zpe has quit [Ping timeout: 272 seconds]
rkallos has joined #ocaml
<rkallos> I'm a beginner with using OCaml, and I am trying to implement a small library for music theory. I would like to define a type note that is represented as a string, but with the first character being between A and G, and the rest of the characters in the string consisting of "b" or "#". I'm a little stumped on turning this into OCaml code at the moment, and would appreciate any help or tips.
<tautologico> why not use an ADT instead of string?
<tautologico> type note = C | D | E | F | G | A | B
<tautologico> type modifier = Flat | Sharp | Exact
NoNNaN has quit [Remote host closed the connection]
<rkallos> Would that enable me to represent notes with more than 1 accidental? I would like to be able to discern between C#### and E, despite them being enharmonically equivalent
dant3 has joined #ocaml
tulloch has joined #ocaml
<tautologico> of course
<tautologico> I was thinking about defining a full note as a pair note, modifier
mcclurmc has quit [Remote host closed the connection]
<tautologico> but in that case you can define it as a pair note, list of modifiers/accidentals
<tautologico> type base_note = C | D | E | F | G | A | B
<tautologico> type accidental = Flat | Sharp
<tautologico> type note = (base_note, accidental list)
<tautologico> empty list means no accidentals
<tautologico> avoids erroneous states that could appear in your program by a string representation
dant3 has quit [Ping timeout: 240 seconds]
<rkallos> That sounds pretty much perfect! Thanks! I'll play around with it :)
<rkallos> Now if I wanted to write a function to strip a note of its accidentals, how would I access and return the base_note of the note?
Thooms has quit [Read error: Operation timed out]
<tautologico> use pattern matching
<tautologico> match note with (base, acc) -> ...
<tautologico> on ... you can use the base note
<tautologico> if you prefer you could define note as a record instead of a tuple, but with 2 components a tuple works well enough
<rkallos> So essentially: let strip_note note = match note with | (base, acc) -> base?
<tautologico> in this case there's a shorter way:
<tautologico> let strip_note, _ = note
<tautologico> the match is usually used in the start of a function to use the base note in the rest of it
mcclurmc has joined #ocaml
tulloch has quit [Ping timeout: 245 seconds]
<rkallos> I don't think I understand the shorter way, as I've yet to encounter the _
<tautologico> _ is just a way to ignore a part of a pattern
<tautologico> if you won't use the second component of the pair, you can use _ to avoid binding it to a variable
<tautologico> let already does pattern matching, so it's not necessary to use match explicitly
<rkallos> So using that shorter definition above, I would be able to call strip_note (C [Sharp]) and have it return (C [])?
<tautologico> not as a function
<tautologico> sorry, misunderstood
<tautologico> a function would be
<tautologico> let strip_note (base, _) = base
<tautologico> then strip_note (C, [Sharp]) would return just C
<rkallos> Ah, that looks much better :)
<rkallos> I'm getting an error with my note type declaration:
<rkallos> [type_kind] expected after "="
<rkallos> type note = (pitch_class, accidental list);;
<tautologico> yeah, sorry
<tautologico> type note = pitch_class * accidental list
<tautologico> (x, y) builds a tuple value
<tautologico> for a tuple type you need to use *
<rkallos> Ah! I see :)
<rkallos> We'll see how this format works for chords and other bigger musical constructs, but so far things work well enough for me to continue!
mcclurmc has quit [Remote host closed the connection]
<rkallos> Thanks for all of your help, tautologico!
rkallos has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
avsm has quit [Quit: Leaving.]
<tautologico> np
rand000 has quit [Quit: leaving]
pango has joined #ocaml
tulloch has joined #ocaml
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zpe has joined #ocaml
WraithM has quit [Quit: Lost terminal]
WraithM has joined #ocaml
dant3 has joined #ocaml
avsm has joined #ocaml
zpe has quit [Ping timeout: 272 seconds]
dant3 has quit [Ping timeout: 252 seconds]
smerz has quit [Ping timeout: 246 seconds]
smerz_ has quit [Ping timeout: 272 seconds]
madroach has quit [Ping timeout: 252 seconds]
madroach has joined #ocaml
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MiggyX has joined #ocaml
arjunguha has joined #ocaml
<MiggyX> hi guys, I'm playing with Ctypes and Foreign to try and get a little libpcap binding working. Hitting a bit of an issue though... one of the functions returns either a char* containing the device name or a null pointer. OCaml tries to convert it to a string, which gives a segfault. I was wondering if anyone could point me in the right direction for handling this issue? :)
<avsm> MiggyX: use string_opt instead of string
lasts__ has joined #ocaml
avsm has quit [Quit: Leaving.]
lasts_ has quit [Ping timeout: 246 seconds]
PM has quit [Ping timeout: 246 seconds]
tulloch has quit [Remote host closed the connection]
fusillia has joined #ocaml