<d_bot>
<arctumn> well i'm expecting an integer value as i'm only rotating integers XD
<companion_cube>
hmm, rotating 1 by 45° diesn't give an int
<companion_cube>
:)
<companion_cube>
(1,0) i should say
<d_bot>
<arctumn> well i'm only doing 90 180 270 360 rotations
<d_bot>
<arctumn> and i want the full result since i'm going to use result to add it to other integers
<companion_cube>
hmm in that case you wouldn't need floats at all? :)
<companion_cube>
just a pattern match
Tuplanolla has quit [Ping timeout: 256 seconds]
<d_bot>
<arctumn> i'm not understanding, how would a pattern matching would rotate?
yusufa has joined #ocaml
<yusufa>
how do you create multiple independent instances of a variable in ocaml?
<yusufa>
by variable i mean record?
<d_bot>
<glennsl> yosufa: what do you mean "independent instances"? Just a copy of the outermost record, or a deep clone?
<yusufa>
so say i have: type x = {mutable a:int; mutable b:int};;
<yusufa>
and then: let inst = {a=3; b=2};;
<yusufa>
now i want 2 independent copies of "inst"
<yusufa>
when i do something like "let a = inst" and "let b = inst"
<yusufa>
every time i modify a, it also modifies b
<yusufa>
i just want to modify one of them
<yusufa>
d_bot does this make sense?
<d_bot>
<glennsl> yeah it does. I don't think there's a general way of doing it using a single function.
<d_bot>
<glennsl> I think the easiest would be `let copy x = {x with a = x.a}`
<yusufa>
isn't that slow though
<yusufa>
how can i have something mutable with an initialization
<yusufa>
kind of like what a class would do in C or Java
<d_bot>
<glennsl> You could probably write a generic function using `Marshal` too, but ew...
<yusufa>
so what's the right way to do this? :D
<d_bot>
<glennsl> yosufa: why slow? you asked for a copy. that's a copy.
<d_bot>
<glennsl> as for initializer, what makes that different from a function?
<yusufa>
well it doesn't do it in place
<yusufa>
say i want to call the thing multiple times?
<d_bot>
<glennsl> you want to copy in place? what would that do?
<yusufa>
no, i want to modify a field in place
<yusufa>
like maybe i have a player with some xp
<yusufa>
and i want to modify the xp from time to time
Haudegen has quit [Ping timeout: 265 seconds]
<yusufa>
doesn't make too much sense to create a new player and just change the xp every time
<d_bot>
<glennsl> you don't need to create a new player every time. but you need to create a new player if you want to modify two players independently
<d_bot>
<glennsl> that's what `copy` does
<yusufa>
yeah i want to modify two players independently
<yusufa>
after all i do want multiple players right
<yusufa>
:)
<yusufa>
so there's no workaround for this?
<d_bot>
<glennsl> with `let b = copy a` you can modify `a` and `b` independently as normal.
<d_bot>
<glennsl> given the definition of `copy` I gave above
<d_bot>
<glennsl> there's no syntax to just make a copy, but there is syntax to make a copy and update one or more fields, which is what `copy` does.
<d_bot>
<glennsl> it updates the one field only because it has to in order to make the copy.
<d_bot>
<glennsl> awkward I know, but it was designed first and foremost with immutability in mind.
<d_bot>
<glennsl> another option is to use objects instead of records, which has a generic copy function in `Oo.copy`, and sounds like it might suit your use case better.
<yusufa>
cool, but I did hear that some people never use objects
<yusufa>
so what's the deal with that
<yusufa>
:)
<companion_cube>
why not make a function to produce the record?
<companion_cube>
and call it twice?
<d_bot>
<glennsl> I would assume it's been modified in the meantime?
<d_bot>
<glennsl> objects are rarely used because they're rarely the best tool for the job.
<mrvn>
except for GUIs, GUIs just screasm for objects. :)
<d_bot>
<glennsl> I disagree 🙂 imperative UIs do, declarative UIs don't, and the future looks more and more declarative
<d_bot>
<glennsl> Think react.js, Elm, flutter and such
<mrvn>
don't you still want inheritance in a declarative UI?
<d_bot>
<glennsl> I think you can accomplish most of what you'd want inheritance for using composition instead.
<mrvn>
composition is kind of functional inheritance
mxns has joined #ocaml
<mrvn>
I find it really helps if every gui element has a size and draw method and such.
<d_bot>
<glennsl> you don't need inheritance to have that though
<d_bot>
<glennsl> But the concept of inheritance in OO tends to be lumped together with other concepts, like subtyping, default implementations
FreeBirdLjj has quit [Remote host closed the connection]
<d_bot>
<glennsl> sorry, shouldn't edit with IRC bridge...
<mrvn>
I've used declarative control flow in C++ recently for resource handling. Look like this e.g.: int fd = open("foo"); AT_EXIT { close(fd); } ... Could be nice if ocaml could do something similar.
<mrvn>
I guess Gc.finalise comes closest
<d_bot>
<glennsl> you could probably implement that using algebraic effect handlers, whenever that lands
sagax has quit [Read error: Connection reset by peer]
mxns has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
amiloradovsky has quit [Remote host closed the connection]
vicfred has quit [Quit: Leaving]
yusufa has quit [Ping timeout: 245 seconds]
madroach_ has joined #ocaml
madroach has quit [Ping timeout: 256 seconds]
mfp has quit [Ping timeout: 264 seconds]
steenuil__ has quit [Read error: Connection reset by peer]
urek has quit [Read error: Connection reset by peer]
urek has joined #ocaml
mxns has quit [Ping timeout: 268 seconds]
mxns has joined #ocaml
narimiran has joined #ocaml
vicfred has joined #ocaml
<d_bot>
<Andrew123> can someone please help me figure out how to use a .env file in dune testing? since I'm testing a lib, the .env in the root folder is not getting copied into _build, so a Not_found error is thrown by the Dotenv parser. do you have any tips on what to do?
<d_bot>
<rgrinberg> Howe are you tests set up in dune?
<d_bot>
<Andrew123> Here is my folder structure
<d_bot>
<Andrew123> root------|
<d_bot>
<Andrew123> main.ml
<d_bot>
<Andrew123> |
<d_bot>
<Andrew123> .env
<d_bot>
<Andrew123> |
<d_bot>
<Andrew123> testing -|
<d_bot>
<Andrew123> unit_test.ml
<d_bot>
<Andrew123> |
<d_bot>
<Andrew123> Lib-----|
<d_bot>
<Andrew123> code.ml
<d_bot>
<Andrew123> I currently have
<d_bot>
<Andrew123> (test
<d_bot>
<Andrew123> (name unit_test)
<d_bot>
<Andrew123> (libraries lib ounit2))
<d_bot>
<Andrew123>
<d_bot>
<Andrew123> (rule
<d_bot>
<Andrew123> (deps ../.env)
<d_bot>
<Andrew123> (target unit_test.ml)
<d_bot>
<Andrew123> (action (copy ${<} _build/default/testing))) in dune
<d_bot>
<Andrew123> Currently I'm getting this Error: This action has targets in a different directory than the current one,
<d_bot>
<Andrew123> this is not allowed by dune at the moment:
waleee-cl has quit [Quit: Connection closed for inactivity]
wingsorc_ has joined #ocaml
wingsorc has quit [Remote host closed the connection]
osa1 has quit [Quit: osa1]
osa1 has joined #ocaml
bartholin has joined #ocaml
bartholin has quit [Client Quit]
_whitelogger has joined #ocaml
<d_bot>
<droo> dune sucks
vicfred has quit [Quit: Leaving]
_whitelogger has joined #ocaml
mxns has quit [Ping timeout: 268 seconds]
shawnw__ has joined #ocaml
shawnw__ is now known as shawnw
<d_bot>
<rgrinberg> I think you can just add `(deps ../.env)` to the `test` stanza.
mxns has joined #ocaml
mxns has quit [Ping timeout: 268 seconds]
narimiran has joined #ocaml
urek has quit [Ping timeout: 240 seconds]
<d_bot>
<Andrew123> @rgrinberg thank you so much, I really appreciate it!! I was stuck on this for a while.
wonko7 has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
zv has joined #ocaml
mxns has quit [Ping timeout: 272 seconds]
Tuplanolla has joined #ocaml
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
zv has quit [Ping timeout: 260 seconds]
shawnw has quit [Quit: Leaving]
neiluj has joined #ocaml
neiluj has quit [Changing host]
neiluj has joined #ocaml
shawnw has joined #ocaml
_whitelogger has joined #ocaml
Anarchos has joined #ocaml
Haudegen has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
borne has joined #ocaml
steenuil has joined #ocaml
andreypopp has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
mfp has joined #ocaml
tane has joined #ocaml
urek has joined #ocaml
urek__ has joined #ocaml
urek has quit [Ping timeout: 264 seconds]
wingsorc_ has quit [Quit: Leaving]
borne has quit [Ping timeout: 264 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 268 seconds]
jnavila has joined #ocaml
mbuf has joined #ocaml
<mbuf>
If I have multiple sub-directories that each have an individual dune file, say a/dune b/dune c/dune, how can I build all of them from the top-level with dune? What should be the contents of the top-level dune file?
andreypopp has quit [Quit: Connection closed for inactivity]
mbuf has quit [Ping timeout: 246 seconds]
wonko7 has quit [Ping timeout: 240 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 268 seconds]
shawnw has quit [Ping timeout: 272 seconds]
waleee-cl has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
jbrown has quit [Ping timeout: 240 seconds]
jbrown has joined #ocaml
troydm has joined #ocaml
raver has quit [Remote host closed the connection]
mxns has joined #ocaml
mxns has quit [Ping timeout: 240 seconds]
gareppa has joined #ocaml
snowpanda has joined #ocaml
gareppa has quit [Quit: Leaving]
wonko7 has joined #ocaml
Jeanne-Kamikaze has joined #ocaml
inkbottle has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
jbrown has quit [Ping timeout: 260 seconds]
jbrown has joined #ocaml
hnOsmium0001 has joined #ocaml
garfr has joined #ocaml
<garfr>
if I want to iterate over a seq, and return another value if a certain value is found, ignoring the rest of seq, what is the best construct to use?
aaaaaa_ has joined #ocaml
aaaaaa_ has quit [Client Quit]
aaaaaa_ has joined #ocaml
aaaaaa_ has quit [Client Quit]
ArthurStrong has joined #ocaml
raver has joined #ocaml
gareppa has joined #ocaml
<oni-on-ion>
garfr, map_find ?
ArthurStrong has left #ocaml [#ocaml]
mxns has joined #ocaml
<garfr>
oni-on-ion: Perfect, thanks!
Jesin has quit [Quit: Leaving]
<garfr>
Is there a good way to convert a Stack to a list and iterate over it?
<d_bot>
<xvw> there is `Stack.iter` or you can convert a Stack to a seq using `Stack.to_seq`
<garfr>
Sure, but then the seq has to be converted to a list. Is this a good idea?
narimiran has quit [Ping timeout: 260 seconds]
Jesin has joined #ocaml
gareppa has quit [Quit: Leaving]
vicfred has joined #ocaml
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
mxns has quit [Ping timeout: 268 seconds]
<octachron>
garfr, seq are made to be iterated on, do you have a specific reason to go through an intermediary list?
amiloradovsky has joined #ocaml
<garfr>
I realized this as well, and just implemented my own version of find_map for seq
<Armael>
garfr: you might be interested in the OSeq library (in opam) that provides a bunch of useful combinators on seqs
GuerrillaMonkey has joined #ocaml
Jeanne-Kamikaze has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 272 seconds]
mxns has joined #ocaml
<d_bot>
<Andrew123> I'm having issues with testing on an sqlite database: after the first attempted insertion, subsequent insertions are rejected due to an IOErr. Does anyone know how to run the tests sequentially to prevent the .db file from locking? I'm currently using @dune runtest -j 1, but it doesn't have any effect on the outcome.
mxns has quit [Ping timeout: 268 seconds]
mxns has joined #ocaml
GuerrillaMonkey has quit [Quit: Leaving]
jnavila has quit [Ping timeout: 256 seconds]
amiloradovsky has quit [Remote host closed the connection]