<Radditz>
I thought the type of assignment is unit
<adrien_oww>
= is not assignment but test there
<adrien_oww>
assignment is: let var = value ...
<ggole>
:= is assignment
<Radditz>
oh
<Radditz>
so its not like in java
<Radditz>
===
<Radditz>
==
<Radditz>
and =
<Radditz>
I see
japesinator has joined #ocaml
talzeus has quit [Remote host closed the connection]
<Radditz>
that's what confused me, thank you
<ggole>
There's ==, but it's identity
<ggole>
(For seeing if two mutable values are the same object.)
<Radditz>
I understand, because in java, assignment is the type of the value, if you do a = true, the type is boolean, and value is true
<Radditz>
so you can do a=b=true, a and b of same type
<Radditz>
that makes sense, thank you
arjunguha has joined #ocaml
talzeus has joined #ocaml
arj has joined #ocaml
<arj>
I have several local private functions that have pattern matching directly on the arguments. Now, ocaml complains that pattern matching is not complete. However, I know that this case never happens, but for the type system this fact is not visible. Is there any possibility to get rid of this points without making pattern matching explicit, e.g. match p with | MyCase -> foo | _ -> failwith "Should never happen" ?
yacks has joined #ocaml
<arj>
Some kind of assert for the type system?
_________ is now known as Guest
ikaros has joined #ocaml
<adrien_oww>
_ -> assert false
<adrien_oww>
is the common "solution"
Radditz has left #ocaml []
Guest has quit [Quit: Computer has gone to sleep.]
ygrek_ has joined #ocaml
<arj>
adrien_oww: this solution is not possible when doing argument pattern matching, isn't it? e.g. foo (x :: xs) = ...
<adrien_oww>
ah
<adrien_oww>
no, it's not
<adrien_oww>
foo = function
<arj>
any possibility here?
<adrien_oww>
| x :: xs -> ...
<adrien_oww>
| _ -> assert false
<arj>
ehm sorry, yeah forgot the let.
<adrien_oww>
no prob
<adrien_oww>
but you can rewrite the last argument that way and handle the case you want easily
<adrien_oww>
otherwise, you can keep "l" as your argument and then do "List.hd" and "List.tl" in your code
<arj>
but pattern matching is on the first and second argument. so function doesn't help much.
<arj>
I didn't get the part with keeping "|" >
<arj>
?
<adrien_oww>
what do you mean?
<ggole>
GADTs can be used to indicate "that can't happen" for some cases
<arj>
you wrote: ' you can keep "l" as your argument'. I didn't get that.
<adrien_oww>
I wouldn't advise arj to use GADTs :)
<ggole>
However, the type has to be written to be a GADT, and GADTs are pretty complicated.
<adrien_oww>
arj: j, k, *l*, m, n; not | :P
<adrien_oww>
I meant
<adrien_oww>
let foo l =
<adrien_oww>
let x = List.hd l in
Vinnipeg has quit [Quit: Leaving.]
<arj>
ah, bad font :D
<adrien_oww>
let xs = List.tl l in
<adrien_oww>
...
<adrien_oww>
although it's not terribly cute
<arj>
I am familiar with GADTs and i wanted to keep it small...
<arj>
thus I didn't want to use GADTs.
<adrien_oww>
generally speaking however, you might prefer to make the thing visible to the type system
<arj>
looks like I that's the only solution.
<arj>
-I
<kaustuv>
What is the problem with just ignoring the match nonexhaustive warnings?
<adrien_oww>
it's way better in the long run
<arj>
kaustuv: you miss the really important warnings within the ones you know.
<ggole>
Sometimes I think that a let* and match* which muffle exhaustiveness warnings would be useful
<arj>
ggole: I agree!
<kaustuv>
Give a user a "trust me" tool and they will abuse it for everything
<kaustuv>
and soon we will end up with Haskell
<ggole>
The alternative is writing | _ -> assert false everywhere: not exactly wonderful
<kaustuv>
but it's at least documentation
<ggole>
(Although you get to feel the pain of sloppily written code a bit more, which may be somewhat valuable.)
talzeus has quit [Remote host closed the connection]
<ggole>
Also, let* and match* would not be 'trust me this is ok' in the sense of Obj.magic
<kaustuv>
I actually advise against having a | _ -> assert false. That makes the code brittle with respect to future evolution. What you should do is write | pat1 | pat2 | ... -> assert false, where pat1... patn enumerate the impossible constructions
<ggole>
That's nice until you are writing ten functions over a type with fifty constructors
<ggole>
In many situations, of course, that is good advice.
<adrien_oww>
kaustuv: there's a warning that catches the _ clauses
aurynj has joined #ocaml
<kaustuv>
If you have a large number of constructors and need to destruct it often, write a map object and override the cases you care about
<ggole>
kaustuv: there's also many situations in which future evolution is simply irrelevant
<ggole>
Inria is not going to add another constructor to the list type.
<companion_cube>
:D
<kaustuv>
Lists constructors are not painful to enumerate
<flux>
type bool = false | true | FileNotFound (* required by client *)
<arj>
flux: what?! why not wrap an option or another type around?
<flux>
(it was a reference to an old thedailywtf article)
<arj>
ah ... :)
<ggole>
I always wondered if that was real...
RMacy has joined #ocaml
<flux>
well, false | true | Unknown could even make sense. look at SQL :)
<companion_cube>
flux: :)
RMacy is now known as RMacy|Away
<companion_cube>
nah, it doesn't make sense in SQL
RMacy|Away is now known as RMacy
<flux>
it's not much different from NaN
<flux>
does NaN not make sense?
<ggole>
options are cleaner for that
<ggole>
NaN is a bit problematic
<flux>
maybe it should be a sum type in OCaml
<ggole>
It breaks code that assumes sane ordering rules, for example
<ggole>
No law of trichotomy
<kaustuv>
false | true | undefined is exactly what you have in Haskell
<companion_cube>
kaustuv: we only describe values
<companion_cube>
undefined is not a value
<companion_cube>
it's an expression that has no normal form
<kaustuv>
sure it is
<companion_cube>
well, if you evaluate it you get an exception :)
<kaustuv>
yes, because Haskell thinks errors are values!
<Drup>
(and undefined is not of type bool)
<ggole>
Isn't undefined of type 'a?
<Drup>
yes
<ggole>
(Or whatever the Haskell equivalent is.)
ikaros has quit [Quit: Ex-Chat]
<Drup>
undefined is pretty much equivalent to assert false
<Drup>
except haskell is lazy, so it's not evaluated directly
<kaustuv>
There are many undefineds. In fact, all the undefineds of a given type can be laid out in a nice partial order
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartbes has quit [Quit: No Ping reply in 180 seconds.]
bartbes has joined #ocaml
avsm has joined #ocaml
kaustuv has left #ocaml []
uggwar has quit [Ping timeout: 245 seconds]
<ggole>
Hmm, named constants do not mix well with pattern matching :/
struktured has quit [Ping timeout: 240 seconds]
cago has left #ocaml []
<companion_cube>
ggole: sadly
ontologiae has joined #ocaml
<ggole>
Would lexically distinguishing them make sense?
<ggole>
(I'm not suggesting this as a change to the language, just wondering.)
<companion_cube>
it's not easy, because pattern-matching is a binding construct
<companion_cube>
you need to distinguish named constants from new variables, so a new syntax is needed
<ggole>
That's what I meant
<ggole>
match foo with Bar (x, +x+) or something
mgodshall has joined #ocaml
<whitequark>
quasiquoting of expressions in pattern matching?
<ggole>
That's the lexical convention for constants in Lisp, you'd probably pick something else.
<ggole>
whitequark: that'd work, but it implies a lot more besides
mort___ has joined #ocaml
<companion_cube>
ggole: I don't know how difficult that would be to add
nikki93 has joined #ocaml
aurynj has quit [Quit: Leaving]
<companion_cube>
but you at least need to specify which equality predicate you use
<ggole>
ie let f x thing = match thing with <<Bar (x, x)>> seems to imply checking the equality of the args of Bar with x
<ggole>
With <<...>> being quasiquotation
<ggole>
Kinda Prology
<Drup>
ggole: you could probably add it as syntax extension
<arj>
Drup: yes I know it is not gonna happen. But sometimes I still miss it ;-)
<ggole>
Mmm. Might not generate good code though.
<Drup>
just unfold "| +const -> ..." into "| some_name when some_name = const -> ..."
<Drup>
with a carefully generated weird name
<ggole>
Yeah.
nikki93 has quit [Ping timeout: 244 seconds]
<Drup>
(js_of_ocaml do that for type constraints)
<ggole>
Or the constant itself, if those are available at expansion time
<Drup>
it's a bit of a shame the markup for extension point is not lightweight :x
soule has joined #ocaml
mika1 has quit [Quit: Leaving.]
<ggole>
Looks like it does generate relatively poor code... but that could probably be fixed.
<Drup>
?
<Drup>
why "| some_name when some_name = const -> ..." is poor ?
<soule>
Hi, I was wondering if anyone could help me with an oasis configuration problem. I am on OSX, and I am compiling a c file. When I do, I get the following error: clang: warning: argument unused during compilation: '-fno-defer-pop'. I think what I need to do is change the configuration for bytecomp_c_compiler to not use the -fno-defer-pop flag, but I don't know how to do that in my oasis file. Thank you
<ggole>
If you have a bunch of match clauses containing constants like Foo (1, 2), and a bunch like Foo (x, y) when x = 1 && y = 2, the first will generate a nice decision tree and the second won't.
<Drup>
oh
<Drup>
right
soule has left #ocaml []
<ggole>
It's fixable: I suspect it's just that nobody has cared about that use case.
avsm has quit [Quit: Leaving.]
RMacy has quit []
mmachenry has joined #ocaml
avsm has joined #ocaml
baz_ has joined #ocaml
njcomsec has joined #ocaml
lostcuaz has joined #ocaml
japesinator has left #ocaml []
<flux>
hmm, OCaml library of choice for retrieving monotonic time in Linux?
arjunguh_ has joined #ocaml
<Drup>
retrieving monotonic time ?
<flux>
a time-stamp that doesn't get affecter by changing system time
arjunguha has quit [Ping timeout: 272 seconds]
<flux>
so binding for clock_gettime(CLOCK_MONOTONIC, ..
<Drup>
hum, there is calendar, but it may be a bit overkill :D
<flux>
how would that help anyway?
<flux>
I mean I want to take a time stamp
<flux>
and then later take another
<flux>
and know how many seconds have passed in between
<flux>
(even if system time gets adjusted during the interval)
<Drup>
yeah, calendar can do that, you just use the UTC timezone when asking for the current time
<flux>
it's not going to use gettimeofday for it?
<Drup>
I don't think so, but you should check ^^
<flux>
I don't mean that the time changes because the time zone changes, rather because someone runs 'ntpdate' in the background...
<Drup>
oh
<Drup>
I don't know
<ggole>
There's a libary for Linux system/libc calls iirc
<flux>
the calendar library doesn't come with any c code, so I think it won't help..
arjunguh_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<flux>
well, binding a single C function wouldn't be that bad
arjunguha has joined #ocaml
<flux>
or I'll just play dangerously and use Unix.gettimeofday ;)
nikki93 has joined #ocaml
<adrien_oww>
clock_gettime is fairly trivial to bind
<adrien_oww>
and for native code, you can have your .c, build the .o, and link directly
<adrien_oww>
dirty but works
<adrien_oww>
(for native code)
tlockney_away is now known as tlockney
nikki93 has quit [Ping timeout: 240 seconds]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arjunguha has joined #ocaml
<flux>
it takes surprisingly long to install core and its dependencies..
michael_lee has quit [Ping timeout: 264 seconds]
<adrien_oww>
hihihi
demonimin_ has quit [Ping timeout: 240 seconds]
arjunguha has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kakadu has joined #ocaml
arj has quit [Quit: Leaving.]
ikaros has quit [Quit: Ex-Chat]
jwatzman|work has joined #ocaml
arjunguha has joined #ocaml
syntropy has quit [Quit: Page closed]
arjunguh_ has joined #ocaml
arjunguha has quit [Ping timeout: 264 seconds]
boogie has joined #ocaml
EmilPer has left #ocaml []
mmachenry has quit [Quit: Leaving.]
samae has joined #ocaml
<samae>
Hi there, I try to give an installation prefix to ocp-build with the "-install-destdir" option
mmachenry has joined #ocaml
<samae>
but it stills wants to install in "/usr/lib/ocaml/site-lib"
<samae>
: /
<samae>
I need this to package an ocaml project for my favorite distro
<whitequark>
flux: "surprisingly" ?
arjunguh_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<flux>
white, well, usually compiling ocaml stuff takes no time at all ;)
nikki93 has joined #ocaml
yacks has quit [Quit: Leaving]
nikki93_ has joined #ocaml
nikki93 has quit [Ping timeout: 244 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
madroach has quit [Quit: leaving]
avsm has quit [Quit: Leaving.]
<samae>
Anyone familiar with ocp-build ?
madroach has joined #ocaml
mort___ has quit [Ping timeout: 264 seconds]
tobiasBora has joined #ocaml
<pippijn>
flux: you haven't compiled my projects..
<Drup>
samae: since ocp-build is not released and that basically nobody except its creator is using it, no :p
<samae>
Drup aaaaaaaah! Darn, send an email I should then. Thanks for your answer
<Drup>
(actually, the said creator is hanging around in the channel sometimes :D)
<samae>
and what would his/her pseudo be then?
<adrien>
guess:
<adrien>
!
<samae>
AltGr: ?
<Drup>
he's not here right now
<AltGr>
Yes ?
<samae>
AltGr: are you a dev of ocp-build?
<AltGr>
ah, no, that's not me, although I put the fancy color output there
<samae>
ok
<AltGr>
he doesn't seem to be around
<AltGr>
IIRC you have to give all the --install-{lib,etc.} options in the latest release
avsm has joined #ocaml
angerman has quit [Quit: Gone]
nikki93_ has quit [Remote host closed the connection]
smerz has joined #ocaml
smerz_ has joined #ocaml
<samae>
AltGr: ok. And how would you do set those paths at the last minute? I'm not the developper of the project, just packaging
<Drup>
(what are you trying to package ?)
<ggole>
"We will get 1000+ core machines within a few years - they are so bloody fast that we are having problems thinking of what we can use the CPU cycles for so please don't write efficient programs - otherwise we won't need the 1K core machines :-)" Heh
<Drup>
and the sequential part is still the bottleneck, yup.
<ggole>
Yes, sequential performance gets *more* important as you get more parallelism... many people don't seem to get that.
<ggole>
Still, an interesting perspective. (That's Joe Armstrong.)
<Drup>
(actually, the "don't write efficient programs" can be a good tactic : to compute the voronoi decomposition of a n*m grid into k sets, don't try to be clever, just throw n*m stupid task that test the distance to all the k points into a GPU)
<Drup>
(well, done, you just outperformed all the clever CPU-based algorithme :p)
tobiasBora has quit [Quit: Konversation terminated!]
<samae>
Drup: spoc!
bicgena has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
<AltGr>
samae: sorry, got to go for tonight
<AltGr>
I'll be here tomorrow
jonludlam has quit [Ping timeout: 246 seconds]
Snark has quit [Quit: leaving]
zpe has joined #ocaml
mmachenry has quit [Quit: Leaving.]
mmachenry has joined #ocaml
<mmachenry>
I just wrote a package using oasis and checked in the configure, Makefile, myocamlbuild, setup.ml, etc. My friend checked it out and tried to build it and got "Ocamlbuild knows of no rules that apply to a target named src/pcf.mly" what files should I be checking in when I use oasis? What is wrong with my build? https://github.com/mmachenry/pcf
<adrien>
you should check the _whole_ error
<adrien>
in ocamlbuild, the "mly" extension is the last one tried usually (iirc)