tremon has quit [Remote host closed the connection]
alexherbo2 has quit [Remote host closed the connection]
Stumpfenstiel has quit [Ping timeout: 252 seconds]
honeydatax has quit [Quit: Leaving]
Tuplanolla has quit [Quit: Leaving.]
Haudegen has quit [Quit: Bin weg.]
Haudegen has joined #ocaml
Haudegen has quit [Client Quit]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
raskol has quit [Ping timeout: 246 seconds]
<discocaml>
<softwaresirppi> guys why not `match` be a binary operator? like `if x matches [] then "nothing" else "something"`. why does it have to be a separate construct orthogonal to if expressions>
<discocaml>
<softwaresirppi> guys why not `match` be a binary operator? like `if x matches [] then "nothing" else "something"`. why does it have to be a separate construct orthogonal to if expressions?
<discocaml>
<softwaresirppi> match expressions cant handle conditions in cases, if expressions cant handle pattern matching
<discocaml>
<softwaresirppi> whats the pragmatic way!
euphores has quit [Quit: Leaving.]
bibi_ has quit [Quit: Konversation terminated!]
euphores has joined #ocaml
<discocaml>
<softwaresirppi> let rec zip x y = match x, y with
<discocaml>
<softwaresirppi> | [], y -> y
<discocaml>
<softwaresirppi> | x, [] -> x
<discocaml>
<softwaresirppi> | x :: xs, y :: ys -> x :: y :: zip xs ys;;
<discocaml>
<softwaresirppi> ```
<discocaml>
<softwaresirppi> ```
<discocaml>
<softwaresirppi> let rec zip x y = match x, y with
<discocaml>
<softwaresirppi> | [], y -> y
<discocaml>
<softwaresirppi> | x, [] -> x
<discocaml>
<softwaresirppi> | x :: xs, y :: ys -> x :: y :: zip xs ys;;
<discocaml>
<softwaresirppi> ```
<discocaml>
<softwaresirppi> if you know a better way, please let me know!
Tuplanolla has joined #ocaml
bartholin has joined #ocaml
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
<discocaml>
<contificate> There could be many alternatives you don't consider if you wanted `match` like that. For simple nullary constructors, you already have this with comparison: `if x = [] then ..`. Your `zip` function looks pretty standard (well not standard in the OCaml sense, as I believe `List.combine` raises an exception if the lengths don't match).
<discocaml>
<softwaresirppi> oh i see
<discocaml>
<softwaresirppi> the thing im not clear about is if expressions and match expressions
<discocaml>
<softwaresirppi> why is it designed this way
<discocaml>
<softwaresirppi> lol
<discocaml>
<contificate> It's convenient to have a dedicated construct for dispatching on boolean conditions
<discocaml>
<softwaresirppi> is there any pages or articles to justify the design decisions?
<discocaml>
<contificate> that's literally all it is
<discocaml>
<softwaresirppi> ugh thats it?
<discocaml>
<softwaresirppi> alright then!
<discocaml>
<softwaresirppi> so its safe to say IF is inferior to MATCH.
<discocaml>
<contificate> match is more general, yes
<discocaml>
<contificate> you would get odd looks from people if you use `match` in place of `if` for boolean things, to be honest
<discocaml>
<softwaresirppi> i wish pattern matching is more sophisticated... lol for example...
<discocaml>
<softwaresirppi> ```
<discocaml>
<softwaresirppi> match x with
<discocaml>
<softwaresirppi> | x mod 2 = 0 -> "even"
<discocaml>
<softwaresirppi> | _ -> "odd"
<discocaml>
<softwaresirppi> ```
<discocaml>
<contificate> you have that with guards
<discocaml>
<softwaresirppi> "pattern match"... more like "does it solve this equation"
<discocaml>
<softwaresirppi> WHAT IS THATT
<discocaml>
<contificate> the match format is: `<pat> [when <expr>] -> <expr>`
<discocaml>
<softwaresirppi> SO I CAN STRUCTURALLY MATCH A PATTERN AND ALSO EVALUATE A CONDITION!
<discocaml>
<softwaresirppi> wowwwwwwwwwwwwwwww
<discocaml>
<contificate> you can use match as a shorthand for chains of `if`s as well, since you coud conceivable just match wildcard in every position and use guards to test conditions top-to-bottom
<discocaml>
<softwaresirppi> !!!
<discocaml>
<softwaresirppi> THANKS FOR LETTING ME KNOW
<discocaml>
<softwaresirppi> i literally said this before
<discocaml>
<softwaresirppi> interesting
sailorCa- has quit [Remote host closed the connection]
sailorCa- has joined #ocaml
<discocaml>
<lukstafi> Note that it should be rather easy to implement a binary `matches` operator via ppx. The benefit of including it in the language, other than popularizing it, would be potential pattern matching optimizations -- ideally pattern matching should not be just case-by-case condition checking, but some combination of "jump table" and "decision tree".
tremon has joined #ocaml
pi3ce has joined #ocaml
<discocaml>
<softwaresirppi> jump table isnt the same as decision tree??
Serpent7776 has quit [Ping timeout: 252 seconds]
<discocaml>
<contificate> jump table is a concrete implementation concern
<discocaml>
<contificate> what you find with compilers like LLVM is they have a bottom-up algorithm for partitioning the multi-way branches into those that are clumped together and can be done with a jump table and those which are done with binary search
<discocaml>
<contificate> I can't speak to OCaml's impl, I know that strmatch.ml emits things that do binary search over the words of strings, so I expect tag dispatch is roughly the same - maybe there's jump tables as well, not sure
<discocaml>
<softwaresirppi> decision tree's implementation is jump tables. Yes, makes sense.
<discocaml>
<contificate> decision trees are also DAGs in practice
<discocaml>
<octachron> OCaml pattern matching are compiled to an optimized backtracing automata (originally to guarantee code size).
<discocaml>
<softwaresirppi> guys i came across this function keyword!! can i use it without let? `let f = function` this feels alien to me
<discocaml>
<softwaresirppi> implicitly one argument and pattern matched
<discocaml>
<softwaresirppi> um
<discocaml>
<contificate> you can use it in the higher-order case, yes
<discocaml>
<contificate> you can imagine it's equivalent to `fun x -> match x with ..`
<discocaml>
<contificate> and that `let f x y = ...` is `let f = fun x -> fun y -> ..`
<discocaml>
<contificate> you get used to it, and then do it automatically when you know you'll just be immediately casing on some argument
toastal has joined #ocaml
<discocaml>
<softwaresirppi> oh it makes much more sense now
<discocaml>
<softwaresirppi> i dont know why i even asked it
<discocaml>
<softwaresirppi> ugh so trivial
<discocaml>
<softwaresirppi> thank you
<discocaml>
<softwaresirppi> so function is better than fun. match is better than if.
<discocaml>
<softwaresirppi> i like this
<discocaml>
<Kali> function isn't "better than" fun, they are for two different purposes
<discocaml>
<Kali> not every function is a pattern patch
<discocaml>
<Kali> not every function is a pattern match
<discocaml>
<softwaresirppi> Tell me a single case where `function x -> expression` works equivalent to `fun x -> expression`
<discocaml>
<softwaresirppi> Oh does it suffer a performance hit?!
<discocaml>
<softwaresirppi> I thought caml compiler is smarter than that
raskol has joined #ocaml
<bartholin>
let hd = function [] -> None | x :: _ -> Some x versus let hd l = match l with [] -> None | x :: _ -> Some x
<bartholin>
the first version is arguably simpler
zozozo has quit [Read error: Connection reset by peer]
<discocaml>
<Kali> `fun x -> expr` can always be written as `function x -> expr` because `fun x -> match x with x -> expr` is equivalent to it, but not every `function` can be written as `fun` because not every expression is a pattern match
<discocaml>
<softwaresirppi> That's what I said too? Function better than fun?
<discocaml>
<softwaresirppi> Why are you guys arguing for my point against me 😂
gareppa has joined #ocaml
<discocaml>
<softwaresirppi> Oh so you're saying there are some `fun` that can't be achieved with `function`?
<discocaml>
<softwaresirppi> YES factual
<discocaml>
<Kali> actually i amend my statement, not every fun can be written as function
<discocaml>
<Kali> due to `fun (type a) -> ...`
<discocaml>
<Kali> which has no equivalent for `function`
<discocaml>
<Kali> neither is better than the other
<discocaml>
<Kali> they are intended for different purposes
<discocaml>
<Kali> it would be weird to write a non-pattern match expression as a `function`
<discocaml>
<Kali> even if you just care about character count, fun is shorter when you're not matching
Serpent7776 has joined #ocaml
toastal has left #ocaml [Error from remote client]
Serpent7776 has quit [Ping timeout: 245 seconds]
<discocaml>
<softwaresirppi> what does it do btw!?
<discocaml>
<softwaresirppi> i see
<discocaml>
<gooby_clown> From my understanding, create an opaque type variable that won't be unified with stuff
<discocaml>
<Kali> it introduces a locally abstract type
deavmi has quit [Quit: No Ping reply in 180 seconds.]
deavmi has joined #ocaml
<discocaml>
<softwaresirppi> i find it weird that Exceptions are cased `Foo_bar_baz`
<discocaml>
<softwaresirppi> capitalized snakeyyy
<discocaml>
<gooby_clown> Snake case is in general the OCaml standard I feel
<discocaml>
<gooby_clown> Pretty cute
<discocaml>
<softwaresirppi> C influence
pi3ce has quit [Read error: Connection reset by peer]
<discocaml>
<gooby_clown> Maybe Pascal rather
pi3ce has joined #ocaml
<discocaml>
<gooby_clown> Since it's the syntactic ancestor of OCaml
<discocaml>
<softwaresirppi> godfather pascal
<discocaml>
<gooby_clown> Since it's the syntactic ancestor of OCaml (or all MLs for that matter)
<discocaml>
<softwaresirppi> @gooby_clown what are your fav ocaml libs?
<discocaml>
<gooby_clown> containers, dream, ppxlib, from the top of my head
<discocaml>
<softwaresirppi> containers? STL for ocaml!?!
<discocaml>
<softwaresirppi> oh so you do web development in ocaml!
<discocaml>
<softwaresirppi> how was the experience in this javascript infested world?
<discocaml>
<gooby_clown> Wym by STL xd
<discocaml>
<gooby_clown> I don't do it professionally (some people here do however), but OCaml webdev is pretty comfy actually, seeing as how the language can also be compiled to JS, and ReasonML (an alternate syntax for OCaml) includes JSX natively
<discocaml>
<softwaresirppi> lol C++ standard template lib
<discocaml>
<softwaresirppi> sounds very good
<discocaml>
<gooby_clown> So you can sort of have a full-stack OCaml setup with dream+cacti on the backend and e.g. reason + melange + melange-react on the frontend
<discocaml>
<softwaresirppi> what do you think about owl and data science with ocaml?
<discocaml>
<softwaresirppi> im a freshman... so im thinking of trying out stuff 😅
<discocaml>
<softwaresirppi> im an undergrad... so im thinking of trying out stuff 😅
<discocaml>
<gooby_clown> I haven't tried it, but I think it would be nice to have a numpy-equivalent for OCaml, even if just to spite Pythonistas (although they ofc don't care about what happens in the OCaml world)
<discocaml>
<gooby_clown> Want to do your thesis in OCaml?
<discocaml>
<softwaresirppi> thinking of writing a parser for a language
<discocaml>
<softwaresirppi> idk why i feel python is overrated... but it doesnt feel very good.
<discocaml>
<softwaresirppi> maybe i got too comfortable with it?
<discocaml>
<gooby_clown> As a uni project or? If you just need a parser for something else, you could look at menhir
<discocaml>
<softwaresirppi> the problems i had are 1. lack of tail call optimizations 2. functional programming features are half-baked 3. map, filter and stuff returns an iterable which can only be used once
<discocaml>
<softwaresirppi> yeah uni project
<discocaml>
<softwaresirppi> cant i just use parsing combinators and hack my way out 😅 ?
<discocaml>
<softwaresirppi> gooby gooby
<discocaml>
<softwaresirppi> do you use tmux?
<discocaml>
<softwaresirppi> or whats your setup?
<discocaml>
<gooby_clown> You can yeah, or menhir
<discocaml>
<gooby_clown> Fedora, Konsole, Kate, I don't use tmux since Kate has tabs and stuff
<discocaml>
<softwaresirppi> sure ill give it a go
<discocaml>
<gooby_clown> If you prefer combinators OCaml had angstorm btw
<discocaml>
<softwaresirppi> gooby but its v0.16
<discocaml>
<gooby_clown> Also I'm doing my thesis in OCaml too, feel like it's good that the language is niche since it leaves a lot of ideas fresh
<discocaml>
<softwaresirppi> doesnt it mean its not stable yet?
<discocaml>
<softwaresirppi> a breath of fresh air out of C++ JAVA BULLSHEIITTT
<discocaml>
<softwaresirppi> a breath of fresh air out of C C++ JAVA PYTHON BULLSHEIITTT
<discocaml>
<softwaresirppi> i shouldnt dunk on python and C
<discocaml>
<softwaresirppi> what are you building?
<discocaml>
<gooby_clown> OCaml community is small so things move slowly, I think it should be fine
<discocaml>
<gooby_clown> A system for runtime monitoring of programs where effects and ppx are used for instrumentation
<discocaml>
<softwaresirppi> big communities might be a curse as well
<discocaml>
<gooby_clown> Monitoring the execution of a program really, you can write the specification in a formal logic language of sorts and a program should obey it with regards to some semantics
<discocaml>
<softwaresirppi> DAMN
<discocaml>
<softwaresirppi> thats cooler
<discocaml>
<gooby_clown> Think of alerts, but you can have monitoring state so that you could express sequencing and more complex conditions
<discocaml>
<gooby_clown> The hardest part is probably how to present this to non-FP folks x)
<discocaml>
<softwaresirppi> understandable pain
<discocaml>
<gooby_clown> Wbu what are you planning to do
<discocaml>
<softwaresirppi> trying to parse a human language (for dealing with mistakes, autocorrect, explainers, ...)
<discocaml>
<softwaresirppi> am i making lsp for a human language LOL
<discocaml>
<softwaresirppi> trying to parse a human language (for dealing with mistakes, autocorrect, explainers, translations...)
<discocaml>
<gooby_clown> Pretty cool ay
<discocaml>
<gooby_clown> Are you going to try to do it in OCaml
<discocaml>
<softwaresirppi> fk yeah
<discocaml>
<softwaresirppi> actually im reading the grammar texts now
<discocaml>
<softwaresirppi> i should understand em then think about writing a parser lol
<discocaml>
<softwaresirppi> gooby have you felt like ocaml does anything bad?
<discocaml>
<softwaresirppi> like unfixable badness
toastal has joined #ocaml
<discocaml>
<gooby_clown> I mean, I don't see anything as unfixable, but the fact the compiler is not relocatable (the reason you need to recompile OCaml for every new switch) is pretty fundamental from my understanding and will be hard to change, even though it sucks
<discocaml>
<gooby_clown> Other than that nothing comes to mind
<discocaml>
<softwaresirppi> cool
<discocaml>
<softwaresirppi> ocaml seems too good to be true
<discocaml>
<ovecjoe> I'm seriously enjoying this conversation @gooby_clown and @softwaresirppi 🫡
<discocaml>
<Kali> yeah, this is also my biggest annoyance with ocaml
<discocaml>
<softwaresirppi> lol ghost
<discocaml>
<Kali> my computer isn't very strong so making a new switch takes a looooong time
<discocaml>
<gooby_clown> Right? Need to sit there for 15 mins just waiting for something that feels unnecessary
<discocaml>
<Kali> for me it's more like 45 min xd
<discocaml>
<Kali> my computer is a decade old laptop
<discocaml>
<ovecjoe> Hi @softwaresirppi
<discocaml>
<ovecjoe> I still don't understand this, but I hope I will soon 😅
<discocaml>
<softwaresirppi> Hii
<discocaml>
<gooby_clown> I heard nix can help if you haven't tried it already
<discocaml>
<gooby_clown> Although it's more like patchwork
<discocaml>
<softwaresirppi> It's more like pip env for python
<discocaml>
<ovecjoe> Wow... That is longer than the time it will take me to get over the shock that it takes that long haha 😅
<discocaml>
<softwaresirppi> It has its own way to handle multiple packages... Doesn't it conflict with opam
<discocaml>
<Kali> based on the posts in the nix channel that has its own set of problems
<discocaml>
<softwaresirppi> Oh wait you install multiple opams!
<discocaml>
<ovecjoe> Really need to check out `nix`. Been hearing it for some time. I don't know what it is or what it does.
<discocaml>
<Kali> but ocaml is so great that it's worth it
<discocaml>
<softwaresirppi> It's an OS with declarative configs
<discocaml>
<softwaresirppi> And reproducible
<discocaml>
<ovecjoe> Oh I see.
<discocaml>
<gooby_clown> You are thinking of nixos
<discocaml>
<softwaresirppi> :ocaml:
<discocaml>
<gooby_clown> Nix is a package manager
<discocaml>
<._null._> That's NixOS, Nix is just a package manager (that you can use OS-wide, but not necessarily)
<discocaml>
<softwaresirppi> You guys use that outside of nixos?
<discocaml>
<gooby_clown> I don't but some people do
<discocaml>
<gooby_clown> And I heard it can help with OCaml
<discocaml>
<contificate> 15 mins for a switch? are you sure about that, GOoby
<discocaml>
<ovecjoe> So far, I must say that I haven't been thrown off by a language since Python, until I started learning OCaml... It is just so different and it is making me enjoy the weird feeling, hoping that it gets less weird everyday.
<discocaml>
<gooby_clown> I meant it more as a figure of speech, it's a few mins in reality I think, but sitting there waiting makes it seem longer
<discocaml>
<contificate> how often are you creating new switches? I do it every now and then for an OCaml variant, but other than that, almost never
toastal has quit [Ping timeout: 260 seconds]
<discocaml>
<ovecjoe> Oh nice... Is it like `apt` or like `bun`?
<discocaml>
<gooby_clown> On average rarely, but I just make a new switch for any new project I think will have non-basic deps, and recently it happened I was creating multiple projects and cloning them onto a different machine so it was kinda annoying
<discocaml>
<gooby_clown> I don't like installing stuff into the global switch since `opam list` length blows up fast
<discocaml>
<._null._> Is that a problem ?
<discocaml>
<gooby_clown> Just doesn't feel tidy
<discocaml>
<gooby_clown> It's not really a technical issue or anything
<discocaml>
<contificate> I wish the compiler was more general
<discocaml>
<contificate> the way it works is that arch-specific subfolders get included when you build it
<discocaml>
<contificate> meaning you can't cross-compile easily
<discocaml>
<contificate> which seems like a kind of bizarre limitation, but I guess not much of the compiler is modular
<discocaml>
<contificate> have you seen the interfaces for things?
<dh`>
that was the norm for compilers until recently
<discocaml>
<gooby_clown> No, what about them
<discocaml>
<contificate> what is recently?
<discocaml>
<contificate> LLVM could do this in like 2005
<dh`>
5-10 years maybe? it was unusual when clang just built in all targets at once and nobody else followed suit for a while
<discocaml>
<contificate> well sure but I mean we have first class modules and it's not viewed as something worth pursuing to support this
<discocaml>
<contificate> should be able to have cross compilation bintuils etc. for GCC and then be able to emit aarch64 from the x86_64 compiler
<discocaml>
<contificate> it's not important but it makes it harder to want to contribute support for other backends
<discocaml>
<contificate> they're not what you might expect
<dh`>
it's a major reorg for a compiler that wasn't designed that way
<dh`>
(I'm not saying I disagree with you that it would be nice, note)
<discocaml>
<contificate> I don't think it's that major, but maybe I'm delusional
<discocaml>
<contificate> the fact that you can do it by inclusion because they satisfy the interfaces
<discocaml>
<contificate> is proof you can do it dynamically as well
<discocaml>
<contificate> the other stuff around it the problem
<discocaml>
<contificate> but if you perf the ocamlopt invocation, there's really not a lot going on
<discocaml>
<contificate> at least compared to other compilers
<discocaml>
<contificate> like, Gooby, the coloring.mli is `val allocate_registers: unit -> int array`
<discocaml>
<gooby_clown> Do you have an example? A module name is enough so I can find the code
<discocaml>
<gooby_clown> Ah
<discocaml>
<gooby_clown> What would be the general version of it
<dh`>
maybe it can be done with first-class modules instead of having to functorize everything
<discocaml>
<contificate> yeah, that's what I'm saying
<dh`>
my guess is that you end up having to pass the modules all over the place though
<dh`>
idk
<discocaml>
<contificate> I'm not overly familiar with the compiler, only a few small bits
<dh`>
I don't think I have ever looked at the compiler for serious :-)
<discocaml>
<contificate> but I remember when the aarch64 target was relatively new and I was like "well I'm not gonna bootstrap this on my raspberry pi"
<dh`>
but have written quite a few others
<discocaml>
<contificate> and I don't have Apple products
<discocaml>
<contificate> is your name initials
neuroevolutus has joined #ocaml
<discocaml>
<contificate> sounding a lot like a researcher in effect handlers with that recent compilers comment
<dh`>
hmm, I guess you can't /whois from discord can you
<dh`>
no, I'm most recently a researcher in parsing and program synthesis
Guest4 has joined #ocaml
raskol has joined #ocaml
<discocaml>
<contificate> I will need to get an IRC client
<discocaml>
<contificate> so, like @companion_cube I can moonlight as an IRC poster
<discocaml>
<gooby_clown> IRC is kinda comfy when you are doing something else because it's less distracting than Discord
<discocaml>
<contificate> yeah, I used it many years ago with weechat or something - nice TUI client
<discocaml>
<contificate> but then all the freenode stuff happened
neuroevolutus has quit [Quit: Client closed]
Guest4 has quit [Quit: Client closed]
contificate has joined #ocaml
Serpent7776 has joined #ocaml
contificate has quit [Quit: WeeChat 4.4.2]
contificate has joined #ocaml
<companion_cube>
That's why we're on libera
<contificate>
exactly
neuroevolutus has joined #ocaml
zozozo has joined #ocaml
gareppa has quit [Quit: WeeChat 4.1.1]
raskol has quit [Ping timeout: 252 seconds]
YuGiOhJCJ has joined #ocaml
neuroevolutus has quit [Ping timeout: 256 seconds]
szkl has quit [Quit: Connection closed for inactivity]