<shon>
This is based on the assumption that, since the first and third matches both return the same value, you really only need to check for the second case, and then just return n if that fails.
<shon>
Even if more conditions were necessary, I'd probably also prefer the 'else if' idiom, unless the pattern matching was actually do any destructuring work.
ygrek has joined #ocaml
tmtwd has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
tmtwd has quit [Ping timeout: 240 seconds]
FreeBirdLjj has joined #ocaml
kassens has joined #ocaml
mrnugget has joined #ocaml
P4Titan has quit [Remote host closed the connection]
czar_x has joined #ocaml
kassens has quit [Read error: Connection reset by peer]
govg has joined #ocaml
diphuser has quit [Quit: leaving]
infinity0 has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 245 seconds]
czar_x has left #ocaml ["Leaving"]
tmtwd has joined #ocaml
mrnugget has quit [Ping timeout: 240 seconds]
Guest82 has joined #ocaml
Guest82 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
noddy has quit [Ping timeout: 240 seconds]
fre has joined #ocaml
mengu has joined #ocaml
morfeen has joined #ocaml
MercurialAlchemi has joined #ocaml
tmtwd has quit [Ping timeout: 256 seconds]
morfeen has quit [Remote host closed the connection]
<adrien>
mephage: you can't compute that way inside a match; if you want that, an "if" would work better
<adrien>
afaiu you wanted to see if x mod y is 0 for various values of y
<adrien>
but ocaml's match is very close to "match that variable against that list of possible values"; in the list of possible values, you shouldn't make computations yourself
<mephage>
adrien: right, so a switch statement would be what I'd use in C
<adrien>
you wouldn't be able to use a switch statement that way either
<adrien>
ocaml's match is more powerful than C's switch
mengu has quit [Remote host closed the connection]
<adrien>
so you can probably turn the comparisons around a bit and get what you want
<mephage>
adrien: you're probably right about C, I just assumed I could have the value being matched as an expression
alfredo has joined #ocaml
mengu has joined #ocaml
<adrien>
I'm still too sleepy to try to write nice examples but for your current issue, match x mod 5 with | 0 -> ... | 1 -> ... | ...
<adrien>
actually it would be different :D
<adrien>
I need more sleep
<mephage>
adrien: I get what you mean, I'll try rework it that way
<mephage>
adrien: I didn't think to have the expression as part of the match arg (or whatever it's called)
<mephage>
adrien: thanks
<flux>
is it possible to reimplement Cmdliner's manual page/help functionality outside the library?
<adrien>
mephage: you can have patterns, just not expressions; moreover they'd have to be evaluated each time and that would destroy performance
jnavila has joined #ocaml
<frefity>
Does anyone know how to get the example code for pgocaml (http://pgocaml.forge.ocamlcore.org/) to build? I've tried a bunch of different ocamlbuild commands and I keep getting a syntax error on line 5
<companion_cube>
ah "it uses camlp4" :-/
<companion_cube>
PGSQL(db) is not valid OCaml, so you need to find the right way of invoking the preprocessor…
<flux>
and yes, it's the same package (verified from opam show postgresql)
<flux>
I wonder if the pgocaml "A Brief Introduction to PG'OCaml" is avilable in source form in some repo, it would be important to update that to document also the ppx branch once it's upstreamed
AltGr has joined #ocaml
<frefity>
thanks, it's installed now
morfeen has quit [Remote host closed the connection]
morfeen has joined #ocaml
<frefity>
hmm, that library doesn't seem to support concurrency
<frefity>
(at least not with lwt or async)
<flux>
you can use separate ocaml threads
<flux>
do note that you cannot use the same postgresql connection from separate threads
morfeen has quit [Ping timeout: 240 seconds]
govg has quit [Ping timeout: 240 seconds]
<frefity>
Are ocaml threads the same as system threads or are they "green" threads?
<frefity>
Nevermind, found the answer. They are "lightweight processes in the same memory space"
justicefries has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<flux>
well, they can be both, not at the same time though :)
<flux>
native binaries always use native threads. but! the native threads never run the ocaml code in parallel.
<flux>
so the "real threads" exist only for the benefit of interacting with C libraries that expect actually separate operating system threads, I imagine
<flux>
also for the benefit of not needing to hack around all blocking operations
<flux>
there is a project for bringing actual ocaml code parallellism called ocaml-multicore, and it seems to be advancing pretty nicely. perhaps this year they'll even produce a release.
<frefity>
I really hope so, but I see that it has been "almost ready" for years
<flux>
but this one actually has a lot of activity ;)
<flux>
and you could be mixing this to the previous attempts
<frefity>
I'm really enjoying the ocaml language and type system but, as many others have said, the library and tooling around it quite lacking. I'm not trying to be negative, I think there is an amazing core. I guess I've been spoilt by using mosty Go for the last 4 years where the focus is on tooling and developer ergonomics
segmond has quit [Ping timeout: 255 seconds]
<flux>
I would need to agree. It's just too tricky to setup the environment if you aren't already familiar with. and if it's for Windows, you can basically forget it ;)
<flux>
I guess the problem is that ocaml folks complacent having set up the environment for oneself years ago, that the problems in starting from scratch don't seem like a problem at all.
mephage has quit [Quit: leaving]
<frefity>
Yes, probably the same for getting up to speed and picking a standard library
<flux>
but I don't have a solution for that. the RealWorldOCaml book and opam have greatly helped, I think.
<flux>
but then the problem is that RWO drives Core and I think that the great majority of ocaml community is using that..
<frefity>
Yes, they have both helped a great deal as a beginner
<flux>
core is probably alright, but I have never used it :)
<frefity>
I felt that too. I started using core and then every time I read some ocaml code I saw they nobody was using it
FreeBirdLjj has quit [Ping timeout: 245 seconds]
Simn has joined #ocaml
kakadu has joined #ocaml
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
segmond has joined #ocaml
FreeBirdLjj has joined #ocaml
mengu has quit [Remote host closed the connection]
ocp has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
mengu has joined #ocaml
FreeBirdLjj has joined #ocaml
larhat has joined #ocaml
<kakadu>
Folks, is POPL 2017 youtubed?
mengu has quit [Ping timeout: 240 seconds]
ryanartecona has joined #ocaml
zpe has joined #ocaml
mengu has joined #ocaml
mfp has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
ryanartecona has quit [Quit: ryanartecona]
ocp has quit [Ping timeout: 276 seconds]
<ia0>
I'm also interested by the answer to "Is/Will POPL 2017 be youtubed/dailymotioned/...?", please mention my name in the answer
ocp has joined #ocaml
_andre has joined #ocaml
FreeBirdLjj has joined #ocaml
morfeen has joined #ocaml
<lyxia>
It was recorded but I have no idea what they're doing with the recordings.
FreeBirdLjj has quit [Remote host closed the connection]
sz0 has joined #ocaml
FreeBirdLjj has joined #ocaml
silver has joined #ocaml
ocalm has joined #ocaml
morfeen has quit [Remote host closed the connection]
govg has joined #ocaml
bobby_ has joined #ocaml
bobby_ has quit [Client Quit]
snowcrshd has joined #ocaml
morfeen has joined #ocaml
tmtwd has joined #ocaml
tmtwd has quit [Ping timeout: 240 seconds]
johnelse has quit [Read error: Connection reset by peer]
johnelse has joined #ocaml
mal`` has quit [Quit: Leaving]
<Drup>
frefity: use pgocaml, the camlp4 part is optional and you can use lwt with it, which makes things much better
mal`` has joined #ocaml
<frefity>
Drup, thanks, I'll have another look
<flux>
I understand the postgresql package uses the official library though, giving things like tls support..
leah2 has quit [Ping timeout: 255 seconds]
leah2 has joined #ocaml
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
rossberg has quit [Ping timeout: 264 seconds]
al-damiri has joined #ocaml
larhat has quit [Quit: Leaving.]
FreeBirdLjj has quit [Read error: Connection reset by peer]
rossberg has joined #ocaml
larhat has joined #ocaml
FreeBirdLjj has joined #ocaml
nomicflux has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 256 seconds]
frefity has quit [Ping timeout: 255 seconds]
frefity has joined #ocaml
agarwal1975 has quit [Quit: agarwal1975]
sh0t has joined #ocaml
nomicflux has quit [Quit: nomicflux]
lopex has joined #ocaml
frefity has quit [Ping timeout: 240 seconds]
sepp2k has joined #ocaml
noddy has joined #ocaml
frefity has joined #ocaml
AlfredENeuman has quit [Ping timeout: 245 seconds]
sh0t has quit [Remote host closed the connection]
agarwal1975 has joined #ocaml
AlfredENeuman has joined #ocaml
johnelse has quit [Read error: Connection reset by peer]
johnelse has joined #ocaml
morfeen has quit [Remote host closed the connection]
ryanartecona has joined #ocaml
noddy has quit [Ping timeout: 248 seconds]
sh0t has joined #ocaml
jao has joined #ocaml
frefity has quit [Ping timeout: 240 seconds]
frefity has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
gjaldon has joined #ocaml
<cheater>
if i have a file like src/foo/bar/main.ml is the module called Main or Bar?
<Drup>
Main
<Drup>
flux: flip side: postgresql uses C code
<Drup>
(and the API is really really crap)
ocp has quit [Ping timeout: 260 seconds]
noddy has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
<frefity>
Drup, yes, I'd rather use pure ocaml if possible otherwis what's the point :)
<orbifx>
does the string passed to caml_failwith get copied or taken over?
<orbifx>
i.e., can I dynamically allocate the string passed to it?
<frefity>
Drup, can you point me at any examples of using pgocaml without camlp4?
<snowcrshd>
is there anything similar to cabal sandboxes in OCaml?
<Drup>
huum, no easy ones on the top of my head, no
MercurialAlchemi has joined #ocaml
<Drup>
snowcrshd: opam switches can be used like that, but it will be quite a bit better in the next version of opam
lapinot has joined #ocaml
<lapinot>
hi, i'm seeking some ocaml abstract type guru for some advice!
<snowcrshd>
Drup: oh, that's great! Would that be opam 2.0? I think I remember hearing something about that in ICFP videos
<ia0>
def`: thanks! Do you have an idea of when? (1 week, 1 month, 1 quarter, 1 semester)
<snowcrshd>
I have an installed library that depends on uutf >= 1.0.0 and am trying to install notty, but it depends on uutf <= 0.9.4 (which is causing a conflict)
<Drup>
yeah, opam 2.0 has local switches
<snowcrshd>
how would you usually solve this? by using opam switches like you mentioned?
<Drup>
yes
<lapinot>
Is it possible to constraint the output of a functor (using `with type t = ...`) so that the (concrete) type `t` is an instance of some abstract type 'a foo. This would be like specifying, exists 'a.type t = 'a foo.
<Drup>
you create a new alias switch for a specific (set of) projects
<companion_cube>
but you can have an opaque type in the output of the functor
<companion_cube>
type foo
<companion_cube>
gah
<companion_cube>
type bar
<companion_cube>
type t = bar foo
<companion_cube>
(so you explicitely name the "'a")
<lapinot>
hmm I see, that's a good solution! And what if the constraint is on an input module (to the functor): module Make (X:X_T with type t = 'a foo) ... (* for some 'a *)
<companion_cube>
that wouldn't work
<companion_cube>
you need the same trick
fraggle-boate has quit [Ping timeout: 240 seconds]
ryanartecona has quit [Quit: ryanartecona]
<companion_cube>
X:X_T with type t = some_arg foo
<companion_cube>
where `some_arg` is a type in scope
tane has quit [Ping timeout: 245 seconds]
<lapinot>
companion_cube: thanks, i have trouble wrapping my head around it but i'm going to try
ryanartecona has joined #ocaml
noddy has quit [Ping timeout: 240 seconds]
<def`>
ia0: I got confirmation from more knowledgeable people. So they will come for sure
alfredo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<def`>
ia0: As for "when", I got "I am very late"
agarwal1975 has quit [Remote host closed the connection]
govg has quit [Ping timeout: 256 seconds]
gjaldon_ has joined #ocaml
fraggle-boate has joined #ocaml
<lapinot>
companion_cube: you meant "in scope of X"? So it's impossible to do such a constraint if X does not export the concrete value of 'a it's using?
<companion_cube>
no the concrete value, but the type must be declared
<companion_cube>
remember that `type some_arg` is a valid (opaque) declaration
slash^ has joined #ocaml
agarwal1975 has joined #ocaml
gjaldon has quit [Ping timeout: 240 seconds]
<lapinot>
yeah, sorry what i meant was export the declaration
beatdown has quit [Quit: Severed corpses make good fucks.]
<ia0>
def`: ok great! So I assume it should be soonish :-) Thanks for the info!
jnavila has quit [Quit: It was time]
shinnya has quit [Ping timeout: 240 seconds]
larhat has quit [Quit: Leaving.]
noddy has joined #ocaml
cthuluh has joined #ocaml
yetanotherion[m] has joined #ocaml
AltGr has left #ocaml [#ocaml]
zpe has quit [Remote host closed the connection]
copy` has joined #ocaml
<lapinot>
companion_cube: I got rid of my problem by transforming the functor into a function by using first-class modules (actually no, but that was the first step which solved everything) so that I could use `fun (type a) (module X: ... with type t = a foo) ...` which is exactly what I wanned
<lapinot>
Was my use-case really strange or are locally abstract types on functors something that could be interesting?
tane has quit [Quit: Leaving]
<lapinot>
(note: my use-case is not real life, it just comes from a somewhat badly designed assignement where the global architecture of the code is given)
noddy has quit [Ping timeout: 252 seconds]
agarwal1975 has quit [Quit: agarwal1975]
agarwal1975 has joined #ocaml
govg has joined #ocaml
noddy has joined #ocaml
larhat has joined #ocaml
sz0 has quit [Quit: Connection closed for inactivity]
smondet has joined #ocaml
orbifx has quit [Ping timeout: 256 seconds]
<companion_cube>
I don't know, I don't think I've ever needed this
jnavila has joined #ocaml
octachron has joined #ocaml
ygrek has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
orbifx has joined #ocaml
pigeonv has joined #ocaml
pigeonv has quit [Quit: WeeChat 1.6]
pigeonv has joined #ocaml
KV has joined #ocaml
leah2 has quit [Ping timeout: 240 seconds]
<adrien>
hannes: afaiu, omemo gets you support for muc
freechips has joined #ocaml
<freechips>
hey guys im writing an interpreter
<freechips>
im making an expression type
<freechips>
i can do something like this:
leah2 has joined #ocaml
<freechips>
type Expr = Var of string | Function of string*expr
<freechips>
but not like this:
<freechips>
type Expr = Var of string | Function of Var*expr
<freechips>
why is that?
<pigeonv>
Var isn't a type
<freechips>
*expr is not capitalized sorry
<freechips>
so i should first declare type Var = string?
<pigeonv>
neither can you do this: type t = 42 * string
<companion_cube>
freechips: without the capital
<pigeonv>
yup
maffo has joined #ocaml
maffo has quit [Client Quit]
<companion_cube>
types are not capitalized; constructors are
<freechips>
alright thanks, im still getting the hang of ocaml. very interesting language btw
kakadu has quit [Quit: Konversation terminated!]
noddy has quit [Ping timeout: 240 seconds]
<orbifx>
does anyone understand this:
<orbifx>
Values do not match:
<orbifx>
val binding : ?create:bool -> cppobj -> string -> variant_fn_t -> t
<orbifx>
is not included in
<orbifx>
val binding :
<orbifx>
?create:bool -> obj:cppobj -> name:string -> fn:variant_fn_t -> t
<pigeonv>
labels don't match
<pigeonv>
I guess that's the issue here
<orbifx>
why would that be an issue?
<pigeonv>
no idea
<pigeonv>
but I think I've already seen something like this...
<pigeonv>
let f : int -> int = fun ~x:int -> 42;;
<pigeonv>
this fails
<pigeonv>
(just tested)
<pigeonv>
so I guess that's the same
<companion_cube>
labels don't match, so it's not the same type
<orbifx>
if I remove the labels from the signature in the mli it works
<orbifx>
but the labels were the same?!
<orbifx>
let binding ?(create=false) obj name fn = binding_stub create obj name fn
<orbifx>
val binding: ?create:bool -> obj:cppobj -> name:string -> fn:variant_fn_t -> t
<pigeonv>
what we mean by label is the identifier before the colon
<orbifx>
i figured, yes, they are the same
<orbifx>
create, obj, name, fn
<pigeonv>
so if you want them to match, just remove the labels in the mli
<pigeonv>
just write something like "val binding: ?create:bool -> cppobj -> string -> variant_fn_t -> t"
<orbifx>
I did that, it worked, but I don't understand why this happens.. why can't I name them something in the interface?
<pigeonv>
in the interface, you only specify type
<pigeonv>
types*
<pigeonv>
in each prototype
<companion_cube>
orbifx: they were not the same, see `obj`
<orbifx>
other values have names just fine.. is it screwed by the optional parameter?
TheLemonMan has joined #ocaml
<orbifx>
actually I think I know what it is.. the other values work because they are "external"
<pigeonv>
I guess not
<pigeonv>
you just can't make OCaml unify something with labels and something else without
<pigeonv>
the optional argument is fine
<companion_cube>
if your function is `let f ~x ~y z = …`, the type should be `val f : x:a -> y:b -> c -> foo`
<orbifx>
I'm not using labelled parameters, just one optional
<orbifx>
they others doens't have labels
<pigeonv>
so why do you use labels in the type declaration (val)?
<pigeonv>
`val f : int -> int` is any function taking and returning an int
<pigeonv>
the name of its argument is only important when compiling this function, actually
<orbifx>
can i not "name" the parameters?
<pigeonv>
not in the mli
<pigeonv>
you can add comments, though
vicfred has joined #ocaml
jnavila has joined #ocaml
<pigeonv>
just have a look at OCaml's standard library ;)
<orbifx>
I wonder how other values in the library worked then :/
<companion_cube>
but don't look at external declarations -_-
<companion_cube>
they are magic
<companion_cube>
you can give whatever type you want
_andre has quit [Quit: leaving]
<companion_cube>
it's not checked
<pigeonv>
haha
<companion_cube>
it's very simple: if you write `let f ~x y = z`, the type is `val f : x:a -> b -> c`
<companion_cube>
if you write `let f x y = z`, it's `val f : a -> b -> c`
<companion_cube>
nothing else
<orbifx>
I get the signatures of labelled functions, it's just that external threw me off... all that magic dazzled me :P
<orbifx>
thanks
<companion_cube>
you really can give any type to external
<companion_cube>
it's on the same level as Obj.magic
<companion_cube>
joke's on you if you put the wrong type
vicfred has quit [Read error: Connection reset by peer]
morfeen has quit [Remote host closed the connection]
fre2 has joined #ocaml
fre has quit [Ping timeout: 252 seconds]
sz0 has joined #ocaml
justicefries has joined #ocaml
jao has quit [Ping timeout: 276 seconds]
ousado_ has joined #ocaml
mengu has joined #ocaml
KV_ has joined #ocaml
ousado_ has quit [Changing host]
ousado has joined #ocaml
KV has quit [Ping timeout: 240 seconds]
noddy has joined #ocaml
KV_ has quit [Ping timeout: 240 seconds]
ocp has joined #ocaml
kakadu has joined #ocaml
snowcrshd has quit [Ping timeout: 260 seconds]
justicefries has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
slash^ has quit [Read error: Connection reset by peer]
<flux>
cool, so my program nowadays dies with at '#0 0x003065bc in caml_oldify_mopup ()' every few minutes
<flux>
I only added conduit/websocket as a new dependency.. it already used fftw3 and pulseaudio, but I don't recall it crashing before
<flux>
and conduit/websocket doesn't have C code.
<flux>
(or Obj)
<companion_cube>
what about pulseaudio ?
<flux>
I assume it uses C library
justicefries has joined #ocaml
<companion_cube>
yeah, and Lennart's code is not the most stable
<flux>
I guess that's the most likely reason
<companion_cube>
you can Gc.compact() very often to see where it triggers the fault
<flux>
well, more likely the pulseaudio ocaml bindings..
<flux>
however, my program continously records audio and thus allocates quite a bit
<flux>
and the pulseaudio bindings were done in an easy copying way, didn't seem likely they would have this kindof behavior
<flux>
but I guess what Gc.compact might be the way
justicefries has quit [Client Quit]
<flux>
unless it slows down it too much so that it starts to affects its behavior..
<flux>
an ocaml-specific valgrind plugin would be great :)
zpe has joined #ocaml
<flux>
the problems seem to coincide too much with slacko RTM support (wip), which has ping/pong every 10 seconds..
morfeen has joined #ocaml
<flux>
well I thought of trying to isolate the problem and tried a loop doing only slack RTM.. and immediately bang but maybe for some other reason :) #1 0x76e0b4b4 in OPENSSL_cpuid_setup () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0
morfeen has quit [Ping timeout: 240 seconds]
<flux>
curiously only under debugger, and in fact my code did nothing because I omitted to call main :). must be some pretty interesting code there..
ocp has quit [Ping timeout: 255 seconds]
jnavila has quit [Ping timeout: 240 seconds]
jbrown has joined #ocaml
tane has joined #ocaml
<Leonidas>
flux: doesn't that point at openssl being a possible culprit?
<Leonidas>
I suppose when loading openssl there is a considerable amount of init code running.
<Leonidas>
On an unrelated note, how would I go about copying a record with a mutable field?
<Leonidas>
I tried functional copies with out replacing anything which works but triggers an amusingly incorrect warning
<Leonidas>
also it does not work it the type is abstract b/c I need to specify at least one field for the update
<Leonidas>
*if the type is abstract
KV has joined #ocaml
vicfred has joined #ocaml
tane has quit [Ping timeout: 258 seconds]
<octachron>
Leonidas, if the type is abstract, you cannot know, you cannot know how to copy without some supplementary information (e.g. a copy function)
<Leonidas>
octachron: is there a reason this is not possible? From a technical POV it's just copying some bits without changing anything.
<Leonidas>
something like let f = {g} or similar
* Leonidas
is also quite surprised to never have thought of this in the first place
<octachron>
Leonidas, is it? How does the compiler know if you mean a deep copy or a shallow copy or any intermediary form of copying?
<Leonidas>
octachron: ok, so it's because the exact semantics of what to copy aren't universally clear
<Leonidas>
This I can understand :)
sz0 has quit [Quit: Connection closed for inactivity]
tane has joined #ocaml
igitoor has quit [Ping timeout: 258 seconds]
igitoor has joined #ocaml
igitoor has quit [Changing host]
igitoor has joined #ocaml
kakadu has quit [Remote host closed the connection]
freechips has quit [Quit: WeeChat 1.7]
igitoor has quit [Read error: Connection reset by peer]
igitoor has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
ocabot_ has quit [Remote host closed the connection]
ocabot_ has joined #ocaml
sepp2k has quit [Ping timeout: 260 seconds]
igitoor has quit [Ping timeout: 240 seconds]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
igitoor has joined #ocaml
igitoor has quit [Changing host]
igitoor has joined #ocaml
zpe has quit [Remote host closed the connection]
jbrown has quit [Ping timeout: 255 seconds]
<copy`>
In the case of functional record update the other fields are copied shallow, so even if `let f = {g}` worked, it wouldn't be different from `let f = g`
tane has quit [Ping timeout: 240 seconds]
jbrown has joined #ocaml
octachron has quit [Quit: Leaving]
<orbifx>
is value_default the monadic bind for ocaml's option?