<discocaml>
<dmitrig> right -- if only primitives like constructor applications and "local-returning" functions can allocate in the current region, then reasoning about stack usage is nice and local
<discocaml>
<dmitrig> on the other hand doesn't that mean that eg `let local x = List.init 10 succ in ...` just heap allocates and gives `x` a local mode?
<discocaml>
<dmitrig> a bigger issue might be that you would want a `.. -> t @ local` version of each library function that allocates and returns data
<companion_cube>
Yeah I think it does
<companion_cube>
You need exclave
<companion_cube>
And I think you always want local if it makes sense, it's not a situation where you want both like with lwt?
<companion_cube>
Idk
<companion_cube>
Or you can use exclave perhaps
<companion_cube>
Hmm
<discocaml>
<dmitrig> re: "always local" -- my understanding of `exclave` is that it means, operationally "allocate on the caller's stack and return." I.e. you can't write a single function that returns on the heap or stack, depending on the calling context, though primitives seem to do this. Could be that it's easy to emit different code for primitive allocations depending on the context, but you'd have to generate two versions of each user function (or decide whe
<companion_cube>
It'd be nice to be polymorphic over allocations :p
<discocaml>
<dmitrig> > which isn't practical
<discocaml>
<dmitrig> actually it's not clear why that wouldn't be practical .. presumably they added a whole other stack for functions that touch locals to manage, wouldn't it take "just" another argument to pass where to return values
<discocaml>
<dmitrig> anyway, highly likely I'm misunderstanding and talking nonsense. Skimmed the proposal here and I'm still not sure::
dinosaure has quit [Read error: Connection reset by peer]
gwizon has quit [Ping timeout: 248 seconds]
gwizon has joined #ocaml
<discocaml>
<zahadoom13> Hello! I have a general guidance question. Is this the place to ask?
<discocaml>
<zahadoom13> I'll just ask.... should I explore ReScript, OCaml, or Reason? I'm mostly a C# + TypeScript + React developer, I also know F# reasonably well, and C. I like functional programming style.
<discocaml>
<zahadoom13> I want to build a hobby project. It will require some non-trivial, though a not too complicated back-end, and I would like a pretty frontend. Also, I'd like to ditch MSFT. I'd like a good robust development experience while working on the backend. I'd also like a seamless experience when building the front-end. Id like to be able to define types for DTOs be able to throw them in a DB, or just send them to the web client and have them work t
<discocaml>
<zahadoom13> Oh, and I'm not going the Node+TS route. that's way too annoying for a hobby project.
<discocaml>
<zahadoom13> Ideally I would just want to be able to use OCaml on the back-end, and the front-end, and have it play along with the javascript ecosystem. Is that possible?
<discocaml>
<froyo> if you (ideally) want ocaml on both ends, there's melange and there's js_of_ocaml
<discocaml>
<froyo> reason is just a different syntax for ocaml, so whatever applies here applies there
<discocaml>
<froyo> admittedly rescript is a lot more focused on that js dev experience and the ecosystem surrounding it. it just deviates a bit from ocaml and many of the goodies ocaml has post version 4.06 aren't available to you
<discocaml>
<zahadoom13> is reason actively maintained? does it have a community? it looks like it mostly dried out.... 😦
amk has quit [Ping timeout: 256 seconds]
perrierjouet has quit [Quit: WeeChat 3.8]
amk has joined #ocaml
bartholin has quit [Quit: Leaving]
perrierjouet has joined #ocaml
Anarchos has joined #ocaml
neiluj has joined #ocaml
<neiluj>
Hi!
<neiluj>
how to ensure a functor matches a signature if one of its input modules is not equal to the signature's input module?
<neiluj>
here is the error: functor (El : $S1) (H : A__.S.B) -> ...
<neiluj>
is not included in
<neiluj>
functor (El : $T1) (H : S/2.B) -> ...
<neiluj>
where $S1=$T1
<discocaml>
<NULL> What does that equal sign mean for you to give two different names ?
<octachron>
You should include the full error message, rather than the part that says that the error is on the second functor argument.
<neiluj>
Modules do not match:
<neiluj>
functor (E : $S1) (B : A__.S.B) -> ...
<neiluj>
is not included in
<neiluj>
functor (E : $T1) (B : S/2.B) -> ...
<neiluj>
1. Module types $S1 and $T1 match
<neiluj>
2. Module types do not match:
<neiluj>
A__.S.B
<neiluj>
does not include
<neiluj>
S/2.B
<neiluj>
so it seems that some declarations are missing in A__.S.B
<neiluj>
so you cannot put a functor whose input modules are subsets of the signature's input modules
<neiluj>
it would work for subsets
<neiluj>
supersets*
<neiluj>
right?
<octachron>
Functor are contravariants in their arguments.
<octachron>
The signature constraint can require more arguments in functor, but you have to list the requirement of the actual functor implementation.
<octachron>
Consider an implementation of type `F(X:sig val x:int end -> struct let y = X.x end`
<octachron>
You can restrict it to `functor (X:sig val x:int val y:int end) -> sig val y:int end` because having a more rich module as argument is not an issue (the supplementary items would be simply unused)
<octachron>
But you can't remove the `x` `functor (X:sig end) -> ...` otherwise the body of the functor would be non-sensical.
<neiluj>
aha! thanks octachron
spip has joined #ocaml
gwizon has quit [Quit: Lost terminal]
neiluj has quit [Ping timeout: 240 seconds]
neiluj has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
bgs has joined #ocaml
bartholin has joined #ocaml
Anarchos has quit [Ping timeout: 256 seconds]
Anarchos has joined #ocaml
<Anarchos>
how to create an out_channel to write in a string ?
Anarchos has quit [Ping timeout: 240 seconds]
Anarchos has joined #ocaml
<discocaml>
<hockletock> let oc = Out_channel.open_text "filename"
<discocaml>
<hockletock> channels are buffered by default so you won't see them written to until the channel is full, flushed, or closed
<discocaml>
<hockletock> buffer* is full
<Anarchos>
how to output an int in network order followed by a string, in a string ?
<companion_cube>
Create bytes of length n+4 and use set_int32_ne or something like that, before copying the string into the bytes at offset 4
<Anarchos>
companion_cube ne is native endian. for network it should be be i guess ?
<companion_cube>
Hmm i forgot which one is network
<companion_cube>
I tend to use _le for little endian
<Anarchos>
companion_cube "The TCP/IP standard network byte order is big-endian."
<companion_cube>
Ah well
<companion_cube>
Then just use _be
<Anarchos>
yes
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<discocaml>
<froyo> zahadoom13: I haven't used reason or melange myself, I imagine rescript docs would cover what you'd find missing in melange. as for reason, i imagine it only needs to be maintained as far as new syntactic additions happen in ocaml. otherwise it'd be the same community and ecosystem. Have you seen this: https://melange.re ?