<minusoneplusone>
i wrote about the difference here
<minusoneplusone>
`let f = lazyfun n -> n + 1 in f 1` returns 2 just like it would in a normal fun
<minusoneplusone>
but uses lazy evaluation.
<minusoneplusone>
in a normal `fun` (eager evaluation) the symbol n is bound to the value 1 just as soon as the call to the function f happens
<minusoneplusone>
in lazy evaluation the AST expression is bound instead of a reduced value, and it is carried on in the evaluation until it is looked up in the evaluation of the function body
<zozozo>
So basically, call by name ?
<companion_cube>
minusoneplusone: if you're doing a minicaml, why not have lazy values, rather than lazy functions?
mfp has quit [Ping timeout: 240 seconds]
<minusoneplusone>
i have lazy values
<minusoneplusone>
with `let lazy`
<minusoneplusone>
that work correctly
<minusoneplusone>
should i drop lazy functions completely? and just use lazy values? (arguments are always evaluated in an eager way but the function is defined as lazy) ???
bitwinery has quit [Remote host closed the connection]
bitwinery has joined #ocaml
jaar has quit [Ping timeout: 268 seconds]
tsuyoshi has joined #ocaml
ggole has quit [Quit: Leaving]
<tsuyoshi>
I'm trying to get some old code compiling, and I'm running into this new Bytes/String distinction
<tsuyoshi>
it makes sense to have read-only strings, but the Bytes type is still using chars... I don't get it
<tsuyoshi>
I would think the point was to move to utf-8 strings and then have a unicode code point type? is the "char" in ocaml meant to be a byte, i.e. an integer 0-255?
<companion_cube>
`char` is a byte, yes
<companion_cube>
for a unicode point, there's `Uchar.t`
<companion_cube>
(in the stdlib, or in `uchar` on old versions)
<tsuyoshi>
ok, I understand
<tsuyoshi>
should I be using Bytes at all?
<companion_cube>
if you mutate strings or do IO, sure
<companion_cube>
(typically, for managing IO buffers)
<companion_cube>
otherwise, normal values should be strings, if you carry text around
<tsuyoshi>
well I guess my question is, should I be mutating strings?
<companion_cube>
now you should really really not!
<tsuyoshi>
like if I convert a string into bytes, mutate it, convert it back into a string
<companion_cube>
I mean, -safe-string is the bomb (and it's the default now)
<tsuyoshi>
oh ok
<companion_cube>
you should not do that with `Bytes.unsafe_to_string` :D
<companion_cube>
I mean, the rule is simple: a string must not be mutated
<tsuyoshi>
am I right in thinking the long-term plan is to have utf-8 strings?
<companion_cube>
bytes->string is only useful when you promise never to use the bytes again
<companion_cube>
they're already utf-8, in a sense… or they should be
<tsuyoshi>
they used to be latin-1 (haven't used ocaml in about 10 years)
<tsuyoshi>
but I'll just change this code to stop mutating stuff
<companion_cube>
ah that's dead now (latin1)
<companion_cube>
string literals should be utf8
TC01 has quit [Ping timeout: 240 seconds]
Hrundi_V_Bakshi has joined #ocaml
TC01 has joined #ocaml
jnavila has joined #ocaml
<tsuyoshi>
huh... String module is pretty bare-bones
<Armael>
you can use the "astring" library for an extended (ascii) string library, and the uu* libraries by daniel bunzli for unicode manipulation
<tsuyoshi>
this old code uses camomile, how does that fit in? should I migrate away from it?
<Armael>
ah, in that case I think you can probably stick to camomile
jao has quit [Ping timeout: 240 seconds]
porchetta has quit [Ping timeout: 268 seconds]
<tsuyoshi>
oh, |> is in stdlib now, nice
porchetta has joined #ocaml
bartholin has joined #ocaml
porchetta has quit [Ping timeout: 250 seconds]
<companion_cube>
it's been a while :)
<companion_cube>
and @@ too
porchetta has joined #ocaml
<narimiran>
wait, there was a time when ocaml didn't have |> ?
<companion_cube>
yep
<tsuyoshi>
it was very common to just put a definition for |> at the top of a source file
minusoneplusone has joined #ocaml
<narimiran>
so one day we might even get `>>` :) (yeah, companion_cube, i use CCFun.%> a lot :))
<companion_cube>
ahahah I don't
<companion_cube>
oh well :D
<tsuyoshi>
it's really amazing how fast the ocaml compiler is
<delysin>
is batteries used that much anymore?
<Armael>
not that much no
<Armael>
well it's quite solid but doesn't evolve that much nowadays
kakadu has quit [Ping timeout: 245 seconds]
kakadu_ has joined #ocaml
rosterok has joined #ocaml
narimiran has quit [Ping timeout: 252 seconds]
kakadu has joined #ocaml
kakadu_ has quit [Ping timeout: 268 seconds]
vicfred has quit [Remote host closed the connection]
vicfred has joined #ocaml
vicfred has quit [Max SendQ exceeded]
vicfred has joined #ocaml
vicfred has quit [Max SendQ exceeded]
vicfred has joined #ocaml
gravicappa has quit [Ping timeout: 246 seconds]
minusoneplusone has quit [Ping timeout: 268 seconds]
madroach_ has quit [Read error: Connection reset by peer]
madroach has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
madroach has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
jao has joined #ocaml
vicfred has quit [Quit: Leaving]
rosterok has quit [Quit: Connection closed for inactivity]
ziyourenxiang__ has joined #ocaml
jao has quit [Remote host closed the connection]
madroach has quit [Quit: leaving]
jao has joined #ocaml
smazga has quit [Quit: leaving]
tane has quit [Quit: Leaving]
kakadu has quit [Remote host closed the connection]