decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
nullcone has quit [Quit: Connection closed for inactivity]
bartholin has joined #ocaml
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
amiloradovsky has joined #ocaml
bartholin has quit [Ping timeout: 258 seconds]
Anarchos has joined #ocaml
olle has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
amiloradovsky has quit [Ping timeout: 240 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 265 seconds]
dhil has joined #ocaml
berberman has joined #ocaml
berberman_ has quit [Ping timeout: 272 seconds]
ptival[m] has joined #ocaml
<ptival[m]>
hi everyone, I'm trying to install https://github.com/ocaml/num/blob/v1.3/num.opam (using nix and dune), but I'm getting "Fatal error: exception Opaline.No_install_file", any idea what could be going wrong?
laokz has quit [Ping timeout: 265 seconds]
Haudegen has quit [Quit: Bin weg.]
Anarchos has joined #ocaml
laokz has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
_whitelogger has joined #ocaml
djellemah has joined #ocaml
<Leonidas>
nooo, you can't just write a shitton of useful self-contained libraries!!! dbunzli: ocaml libraries go brr
<Leonidas>
> Left-pad support in is Jstr.pad_start
<Leonidas>
shots fired
<kevinsjoberg>
I'm going through the FUN MOOC by Université de Paris and just implemented a split function that takes a list l and should return a tuple (front, back) where l = back @ List.rev back. I have a working solution but it's not particularly efficient.
<kevinsjoberg>
I just started learning OCaml like 2 days ago, so have patience. :)
<Fardale>
kevinsjoberg: I don't understand the split function, "l = back @ List.rev back" I guess one of the two back should be front, the first one ?
<kevinsjoberg>
Fardale: Yep, you're right. Let me update the gist with the description I got.
<kevinsjoberg>
Fardale I've updated the gist now. I'd be happy to clarify if it's still unclear. :)
<kevinsjoberg>
So basically `l` (the list) is composed as front @ List.rev back. The goal is two return a pair, where the first element is front, and the second element is back (e.g., back with the reverse undone).
<Fardale>
kevinsjoberg: your code is not correct but most of the idea to write the split function are there
<ptival[m]>
kevinsjoberg: so, you should be able to stop right away when reaching the cutpoint, by making sure to have your "front" accumulator already in the correct order
<kevinsjoberg>
Fardale: It's not? It passes the tets.
<kevinsjoberg>
ptival[m]: Yep, that's pretty much what I'm doing. But I still have to reverse them both. That's the part I dont like.
<kevinsjoberg>
s/tets/tests/
<Fardale>
Then maybe I still don't undestand the split function
<ptival[m]>
in your code, it seems you are naming "back" the front of your list, this is confusing
<Fardale>
But applying rev to both list seems not correct
<ptival[m]>
oh "l = back @ List.rev front" what?
<octachron>
Your function is already O(n). The back list is really reversed in the specification?
Anarchos has joined #ocaml
<ptival[m]>
I expected "List.rev front @ back"
<Fardale>
kevinsjoberg: "l = back @ List.rev front" looks strange to me, I would expect List.rev front @ back
<kevinsjoberg>
octachron: It is, that's the part I found confusing as well. Especially since the queue data structure was defined as front @ List.rev back in the beginning.
<Fardale>
I was wrong your solution matches the specification and it pretty much how I will do it
<d_bot>
<ggole> Hmm, there's a nice way to do List.rev front @ back using racing pointers.
<kevinsjoberg>
I agree with you all that I don't understand why the split function compose the list as back @ List.rev front. front @ List.rev back makes sense to me and that's how it's defined in the beginning. Is it due to performance?
<d_bot>
<ggole> Dunno if it's actually any faster.
<Fardale>
kevinsjoberg: the only thing I would do differently is to remove "let cutpoint = List.length l / 2 in" by starting from length l/2 downto 0
<octachron>
List.rev_append front back (which is List.rev front @ back) is faster/naively tail-recursive.
<kevinsjoberg>
Fardale: Isn't that what I'm doing now? Or how do you define "starting from length i / 2 downto 0"? I don't know how I would start from a specific point in the list except going from zero up until a certain point.
<d_bot>
<ggole> The reason for the order of the lists is (probably?) due to how the queue is going to work, btw
<kevinsjoberg>
What rubs me the wrong way is that the function skeleton appen was marked as rec, but as you see, I don't recursively call append itself, but helpers. So perhaps there is an implementation I'm not seeing here...
<kevinsjoberg>
s/appen/append/
mxns has joined #ocaml
<Fardale>
kevinsjoberg: is it explicitly ask to have a tail recursive function?
<kevinsjoberg>
Nope.
<Fardale>
what is the first element of the list return by append l1 l2?
<Fardale>
and what is the tail?
<d_bot>
<ggole> What do you mean, skeleton? Were you asked to write a recursive append?
<Fardale>
@ggole I think you have this "let rec append l1 l2 =" given in the exercice which suppose append to be recursive
<kevinsjoberg>
I got the definition let rec append l1 l2 = “implement”.
<kevinsjoberg>
@Fardale: yep, exactly.
<d_bot>
<ggole> I see. Well, there is a natural but non-tail recursive definition of append that involves deconstructing the first argument, and my guess is they intended you to figure out that one.
<Fardale>
kevinsjoberg: The @ is only need for discord user, which means message send by d_bot our bridge to discord
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<kevinsjoberg>
Oh, my bad.
<d_bot>
<ggole> Would you like me to spoil that one, or do you want to have a shot?
<kevinsjoberg>
Alright. Didn’t think about a non tail recursive one. Let me think about it for a sec. 🙂
<kevinsjoberg>
@ggole well, that was easy. A lot easier when you don't think about tail recursion.
<d_bot>
<ggole> This is pretty much the definition in the OCaml stdlib, by the way.
<kevinsjoberg>
@ggole oh, really. Thought it would be a bit more non-trivial.
<kevinsjoberg>
The next task was to implement combine which takes two lists and return a list of pairs where each pair is the element from each list. Ignoring tail recursion this was really easy as well.
<kevinsjoberg>
Perhaps I've been thinking about this the wrong way. I'm always trying to start out with a tail-recursive implementation.
<d_bot>
<ggole> There's a family of functions which are like that, so learning to recognise those is a good thing
<d_bot>
<ggole> The characteristic is 'constructor replacement', you're forming the constructors of the input list but with some differences
<d_bot>
<ggole> The usual two approaches are non-tail recursion and accumulator/reverse, take your pick.
<kevinsjoberg>
Yeah, I guess I'm too inexperienced to know when a non-tail recursion implementation is fine and when it's not. I'm constantly thinking tail recursion = better, so let's aim for that.
<kevinsjoberg>
I've basically done OCaml for 2 days now. Coming from a background in imperative programming and OO (mostly Ruby). I'm have a lot of fun, but it's really a different way of thinking. :)
<kevinsjoberg>
Appreciate all help I'm getting here. It's super valuable.
<d_bot>
<ggole> That will give you some practice at the accumulator/reverse approach for sure.
<d_bot>
<psafont> @craigfe the svg in the readme of progress is broken when using firefox, showing huge, cut-off letters, not sure why
<Armael>
hmm, it works for me (on firefox nightly)
<d_bot>
<psafont> it's broken on both on stable and developer for me
<d_bot>
<psafont> might be related to wayland and scaling of the screen
<Fardale>
Works fine for me with stable and wayland
<Fardale>
Actually there are really small glitches
<companion_cube>
it's broken for me on stable
osa1 has quit [Remote host closed the connection]
<d_bot>
<craigfe> I use the developer version myself, and it seems mostly fine if a little glitchy / containing small artefacts
<d_bot>
<craigfe> I haven't found a terminal recording workflow that I like; it's a bit sad
<companion_cube>
asciinema is sweet
<companion_cube>
(it does require a bit of work to host the result yourself though)
<d_bot>
<craigfe> in the end, I settled for not showing off the UTF-8 rendering (which works fine in my terminal, but is definitely not supported by any tool I tried), and even that left me with artefacts
<d_bot>
<craigfe> I ended up doing asciinema + an SVG conversion tool
<companion_cube>
oh, interesting
<d_bot>
<craigfe> but even just stock Asciinema did not handle UTF-8 rendering properly
<d_bot>
<craigfe> (and I've had that issue in the past)
<companion_cube>
hum asciinema shouldn't really care about rendering, should it?
<companion_cube>
I mean, it's just text to it I imagine, if it's utf8
<Armael>
seems like you need an svg backend to your library :p
<d_bot>
<craigfe> hmm, Asciinema is surely the thing that's doing the rendering 😛
<d_bot>
<craigfe> i.e. it records the terminal actions and provides a font / color scheme to those actions
<companion_cube>
well, the terminal is the one rendering fonts, right?
<companion_cube>
my understanding is that asciinema replays using ansi escape sequences or something similar
<companion_cube>
the font is still the terminal's
<Armael>
well, so asciinema is acting like a terminal emulator, rather than taking scheenshots of your terminal, no?
<Armael>
so it has to do the rendering
<d_bot>
<psafont> the font is whichever the browser shows
<companion_cube>
ahhhh sorry, I was thinking of asciinema replay, also in the terminal
<companion_cube>
the web version, indeed, has to do more work
<d_bot>
<craigfe> What I really want is a tool where I can decoratively specify a terminal interaction, and then compile that directly to an SVG by running the interaction
<d_bot>
<craigfe> in the style of e.g. cypress tests
<d_bot>
<craigfe> these animations are cool to create, but a pain to maintain otherwise
<d_bot>
<craigfe> particularly if I need to run it through 4 different tools (including an online upload step) to get what I want
<Putonlalla>
How can I load every module in a directory into `utop`?
<Putonlalla>
There are hundreds and some of them depend on each other.
<d_bot>
<craigfe> anyway, thanks for the report @psafont; I'll try to figure out something better in future 🙂 (suffice it to say that the example does actually look cool and non-glitchy in my terminal 😉)
<d_bot>
<psafont> it's very pretty in chromium 😉
<companion_cube>
so we should blame chrome for that :P
spew has joined #ocaml
<Putonlalla>
I get an `Unbound module` error if I just try to `open` them.
<companion_cube>
is it in a dune project? if so, `dune utop the/dir/` should work
<companion_cube>
(if the directory is a dune library, more specifically)
<octachron>
Putonlalla, you can build a library and then either use dune utop or load_rec the library
<Putonlalla>
It's not a Dune project, because the source files are generated by another tool.
caente has joined #ocaml
<companion_cube>
ah, well
<Putonlalla>
I think `#load_rec` should do the trick, thanks.
<octachron>
You can use dune with generated source files
<Putonlalla>
I spent a week trying to get Dune to build the project, but it didn't have enough features.
<octachron>
That's look quite complex indeed. Note you don't need to let dune handle the source file generation and you can plug it in just for the last stage compilation.
<Putonlalla>
I'd still need to let Dune know about the list of source files I care about.
<Putonlalla>
That is, some way to say "these modules and all their transitive dependencies".
laokz has quit [Quit: Leaving]
<ptival[m]>
this got lost in other messages, 2nd attempt: I'm trying to install https://github.com/ocaml/num/blob/v1.3/num.opam (using nix and dune), but I'm getting "Fatal error: exception Opaline.No_install_file", any idea what could be going wrong?
<octachron>
True, but generating the dune file with the list of transitive dependencies is doable, but it sounds like the advantages of using dune becomes really thin at this point.
raver has quit [Read error: Connection reset by peer]
<companion_cube>
dune still gives you `dune utop` and a proper installation
<Putonlalla>
This is true.
<companion_cube>
makefiles can do the basics (produce a .exe) but where they truly tend to struggle is the other files (META, .cmti, installing the .cmx, etc.)
<octachron>
ptival[m], the num library doesn't have an install file. It might be the issue?
<ptival[m]>
octachron: what's an install file in this context?
berberman_ has joined #ocaml
berberman has quit [Ping timeout: 272 seconds]
<octachron>
it is a "*.install" file that is generated by the build system and describes which files should be installed
berberman_ has quit [Max SendQ exceeded]
berberman has joined #ocaml
gareppa has joined #ocaml
berberman has quit [Max SendQ exceeded]
berberman has joined #ocaml
berberman has quit [Max SendQ exceeded]
berberman has joined #ocaml
berberman has quit [Max SendQ exceeded]
berberman has joined #ocaml
<ptival[m]>
I see, so this may be more of an opaline problem than a num problem
hnOsmium0001 has joined #ocaml
gareppa has quit [Quit: Leaving]
Haudegen has quit [Quit: Bin weg.]
osa1 has quit [Remote host closed the connection]
Tuplanolla has joined #ocaml
olle has quit [Ping timeout: 265 seconds]
jgjl has joined #ocaml
dan64 has joined #ocaml
<dan64>
In 'let x = SOME_VALUE and y = SOME_OTHER_VALUE', is it possible to have SOME_OTHER_VALUE refer to 'x' without nesting 'let' statements?
<companion_cube>
no, that's exactly the point of nested let statements :)
<dan64>
companion_cube: Gotcha, thanks.
<dan64>
Is there some other way to this (analogous to let* in Common Lisp)?
<companion_cube>
not that I know of
<companion_cube>
nested lets are perfectly fine
<dan64>
companion_cube: Gotcha, thanks again.
Haudegen has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
olle has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 272 seconds]
mxns has joined #ocaml
chripell has quit [Ping timeout: 265 seconds]
yomimono has quit [Ping timeout: 256 seconds]
yomimono has joined #ocaml
waleee-cl has joined #ocaml
mxns has quit [Ping timeout: 264 seconds]
larou has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
berberman_ has joined #ocaml
berberman has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
zebrag has quit [Remote host closed the connection]
zebrag has joined #ocaml
jbrown has quit [Ping timeout: 244 seconds]
narimiran has quit [Quit: leaving]
dhil has quit [Ping timeout: 240 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
larou has quit [Quit: Connection closed]
larou has joined #ocaml
dhil has joined #ocaml
chripell has joined #ocaml
Anarchos has joined #ocaml
<larou>
hello, is this channel active?
<companion_cube>
somewhat
<larou>
is it more for learning, or help with bugs?
<companion_cube>
discussing about OCaml
<dan64>
Is there a way to query for documentation from the ocaml REPL? E.g., something like `help(print)` in Python or `(documentation 'length 'function)` in Common Lisp.
<companion_cube>
no particular other orientation afaik
<companion_cube>
dan64: no, documentation doesn't exist at runtime
amiloradovsky has joined #ocaml
<companion_cube>
take a look at `odig` though (from the terminal, not the repl)
<dan64>
I'll check it out. Thanks.
<larou>
what about ocaml?
<companion_cube>
what do you mean
Hrundi_V_Bakshi has joined #ocaml
<larou>
you said the channel is for; "discussing about OCaml" - so i asked what you discuss about ocaml...
<larou>
how to make it better, how it works, what it does, what it should do, why it does what it does, what?
<d_bot>
<kanishka> depending on your needs, you can use discuss.ocaml.org for more detailed questions or post useful community announcments; #ocaml to ask questions or generally talk about anything ocaml; ocaml discord #beginners or #general to ask questions or observe discussion
chripell has quit [Ping timeout: 258 seconds]
<larou>
hmm, ok
<larou>
can you do suspended traversals?
<d_bot>
<ostera> like lazy folds?
<larou>
hmm, kind of
<larou>
what about cyclic free structures?
<d_bot>
<ostera> first time i hear that term, could you give me an example?
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<companion_cube>
larou: Ocaml code is generally less abstract
<companion_cube>
and less lazy
Serpent7776 has quit [Quit: leaving]
<larou>
i dont mind strict by default
<larou>
i can just use the state encoding
chripell has quit [Ping timeout: 260 seconds]
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
chripell has joined #ocaml
Anarchos has joined #ocaml
dhil has quit [Ping timeout: 246 seconds]
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
dhil has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
raver has joined #ocaml
Anarchos has joined #ocaml
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
larou has quit [Quit: Connection closed]
larou has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<larou>
i was working on a project in haskell and it wanst really getting anywhere
<larou>
i thought i could try a similar language to see if there was anyone interested in the project, or if there were any language tools or libraries that could be useful
<larou>
so far i have found that mostly imperative languages dont really support even the most basic things i rely on in haskell
<larou>
such as not supporting Sum datatypes, which means representing recursive datatypes becomes far too difficult
<larou>
im not really sure where ocaml fits, in terms of support for language features common to haskell
<larou>
most of the project depends on expressing abstractions using the typesystem
<larou>
dependent languages dont seem really any better
jbrown has joined #ocaml
mxns has quit [Ping timeout: 265 seconds]
jbrown has quit [Ping timeout: 272 seconds]
test_nick has joined #ocaml
<companion_cube>
well, OCaml isn't too good at complex type magic
<companion_cube>
it's good at providing you with sum types, pattern matching, and polymorphism
<companion_cube>
but you might really miss higher constructs (like `traverse`)
<larou>
what? you cant express higher order functions? why?
<companion_cube>
you have higher order functions
<larou>
or do you just mean traverse isnt part of the prelude
<companion_cube>
you don't have type constructors
<companion_cube>
you cannot write the type of `traverse`
JSharp has quit [Ping timeout: 272 seconds]
<larou>
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
<larou>
which part?
rfv has quit [Ping timeout: 272 seconds]
cemerick has quit [Ping timeout: 272 seconds]
<companion_cube>
basically all of it :D
<larou>
argh
<companion_cube>
`t` and `f` are type constructors
<larou>
that sounds pretty bad...
<companion_cube>
basically only haskell and scala can express that kind of thing
rfv has joined #ocaml
<larou>
so how does your type system work at all!?
<companion_cube>
you can write stuff like `map : ('a -> 'b) -> 'a list -> 'b list`
<companion_cube>
List.map, actually
JSharp has joined #ocaml
<larou>
so you cant have classes over parametric types?
<companion_cube>
there are no classes anyway, so, no
<larou>
urgh
<companion_cube>
(you can do stuff like that with functors, though)
<larou>
how do you have functors with no classes?
<larou>
its built in?
_bushido_ has joined #ocaml
<companion_cube>
not the same notion of functor
<companion_cube>
functors are modules parametrized by other modules
<larou>
hmm
<larou>
i can kind of see how thats like classes
<larou>
in haskell we have "backpack" which does this
<larou>
and basically is another way to do classes
<companion_cube>
right, well, OCaml modules are the state of the art of such things :)
cemerick has joined #ocaml
<larou>
ok
<companion_cube>
it's a bit more manual than typeclasses though
test_nick has left #ocaml [#ocaml]
<companion_cube>
but it can be neat
<larou>
so i *can* write traverse, somehow
<larou>
neat how?
<companion_cube>
(e.g. `ocamlgraph` is pretty nice)