hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
adelbertc has quit [Quit: Connection closed for inactivity]
wiredsister has quit [Remote host closed the connection]
seangrove has quit [Remote host closed the connection]
dsheets has joined #ocaml
nicoo has quit [Ping timeout: 240 seconds]
dsheets has quit [Ping timeout: 250 seconds]
Simn has quit [Quit: Leaving]
copy` has joined #ocaml
avarsh has quit [Quit: Leaving]
noddy has quit [Ping timeout: 276 seconds]
NingaLeaf has joined #ocaml
silver has quit [Read error: Connection reset by peer]
gasche has left #ocaml [#ocaml]
hxegon has joined #ocaml
hxegon has quit [Client Quit]
hxegon has joined #ocaml
johnelse has quit [Ping timeout: 246 seconds]
johnelse has joined #ocaml
dsheets has joined #ocaml
zhs has joined #ocaml
zhs has quit [Client Quit]
dsheets has quit [Ping timeout: 250 seconds]
johnelse has quit [Ping timeout: 276 seconds]
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nicholasf has joined #ocaml
johnelse has joined #ocaml
nicholasf has quit [Ping timeout: 244 seconds]
hxegon has joined #ocaml
nicoo has joined #ocaml
mistermetaphor has joined #ocaml
dsheets has joined #ocaml
mistermetaphor has quit [Remote host closed the connection]
dsheets has quit [Ping timeout: 250 seconds]
mistermetaphor has joined #ocaml
nicholasf has joined #ocaml
NingaLeaf has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
badon has quit [Disconnected by services]
badon_ has joined #ocaml
badon_ is now known as badon
cdidd has quit []
cdidd has joined #ocaml
copy` has quit [Quit: Connection closed for inactivity]
Kyo91 has quit [Read error: Connection reset by peer]
Kyo91 has joined #ocaml
mistermetaphor has quit [Remote host closed the connection]
cdidd has quit [Ping timeout: 252 seconds]
slash^ has joined #ocaml
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cdidd has joined #ocaml
A1977494 has joined #ocaml
matason has joined #ocaml
MercurialAlchemi has joined #ocaml
dsheets has joined #ocaml
A1977494 has quit [Quit: Leaving.]
dsheets has quit [Ping timeout: 250 seconds]
ggole has joined #ocaml
wolfcore has quit [Ping timeout: 244 seconds]
TheLemonMan has joined #ocaml
matason has quit [Ping timeout: 276 seconds]
wolfcore has joined #ocaml
adelbertc has joined #ocaml
ggole_ has joined #ocaml
Simn has joined #ocaml
ggole has quit [Ping timeout: 260 seconds]
leyyin has joined #ocaml
matason has joined #ocaml
pierpa has joined #ocaml
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
cdidd has quit [Ping timeout: 252 seconds]
loli-pyon has quit [Remote host closed the connection]
pyon has joined #ocaml
cdidd has joined #ocaml
FreeBirdLjj has joined #ocaml
Bahman has joined #ocaml
cdidd has quit [Ping timeout: 260 seconds]
matason has quit [Ping timeout: 250 seconds]
cdidd has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
bba has joined #ocaml
cdidd has quit [Ping timeout: 276 seconds]
nicholasf has quit [Remote host closed the connection]
Nahra has joined #ocaml
cdidd has joined #ocaml
Sorella has quit [Quit: Connection closed for inactivity]
hunteriam has joined #ocaml
toolslive has quit [Ping timeout: 250 seconds]
cdidd has quit [Ping timeout: 252 seconds]
malc_ has joined #ocaml
toolslive has joined #ocaml
silver has joined #ocaml
nicholasf has joined #ocaml
dsheets has joined #ocaml
nicholasf has quit [Ping timeout: 268 seconds]
dsheets has quit [Ping timeout: 250 seconds]
matason has joined #ocaml
adelbertc has quit [Quit: Connection closed for inactivity]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
pierpa has quit [Read error: No route to host]
A1977494 has joined #ocaml
pierpa has joined #ocaml
M-martinklepsch has joined #ocaml
martinkl_ has joined #ocaml
<martinkl_>
hello. I'm just getting started with OCaml and I'm trying to figure out how to get the last character of a string. Anyone has any pointers? :
<martinkl_>
:)
<fds>
Do you know how to get a character from a string?
<fds>
Do you know how to get the length of a string?
<M-martinklepsch>
oh right. length and s[i] would also work I guess
<M-martinklepsch>
I'm coming from clojure so I'm thinking of strings as sequences, which in turn just makes me reach for last
<ggole_>
Make sure to check for the empty string first
FreeBirdLjj has quit [Read error: Connection reset by peer]
<M-martinklepsch>
let last_char s = s[(String.length s)];;
<lyxia>
it's s.[i]
<M-martinklepsch>
oh :)
<M-martinklepsch>
lyxia: thanks, was thinking it might be an issue with typing
<lyxia>
yw
<lyxia>
also String.length s is out of bounds
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
Bahman has quit [Quit: Ave atque vale]
<M-martinklepsch>
yeah, realized that I need to subtract 1
nicholasf has joined #ocaml
zhs has joined #ocaml
<M-martinklepsch>
so in the case of an empty string, what's a reasonable return value? In one case it returns a character and in the other it needs to return some other type, how do I specify that type-wise?
<companion_cube>
for an empty string you shoudl raise an exception, OR return `char option` instead of char
<sgronblo_>
where can I find pi?
<ggole_>
A nice thing to do if you raise an exception is indicate that in the name, eg, last_exn
<sgronblo_>
I have Core available
tane has joined #ocaml
<ggole_>
I think 4.0 *. atan 1.0 is the usual workaround
<ggole_>
Core might have a more accurate constant stashed somewhere though
<companion_cube>
wtf, I never realized we did not have π in the stdlib
<ggole_>
Yeah, there should be a value in Pervasives or maybe a constants module
<sgronblo_>
core is so huge, and i havent figured out how to search it
<M-martinklepsch>
ggole, how do you mean? should I define a custom exception somewhere? as in: raise (No_last_char "");;
<ggole_>
Takes bare bones a little too far
<companion_cube>
ggole_: a Float module would have been best
<ggole_>
M-martinklepsch: no, just name the function that raises so that it is very obvious that it handles situations by raising an exception
<sgronblo_>
M-martinklepsch: i also recommend `char option` option
<companion_cube>
M-martinklepsch: exception EmptyString;; let string_last s = if s="" then raise EmptyString else ....
<ggole_>
Oh yeah, Float.pi or Float.e would be reasonable.
<companion_cube>
and Float.max, Float.cos, etc.
<companion_cube>
instead of putting them in pervasives
<sgronblo_>
but now we dont have anything at all?
<ggole_>
Well, max is polymorphic
<ggole_>
But yeah, a Float module seems sensible.
hunteriam has quit [Quit: Connection closed for inactivity]
yegods has joined #ocaml
<sgronblo_>
any idea why Core has flipped the parameters for things like List.map?
yegods has quit [Ping timeout: 252 seconds]
<companion_cube>
not really flipped, it uses labels
yegods has joined #ocaml
A19774941 has joined #ocaml
A1977494 has quit [Ping timeout: 244 seconds]
<sgronblo_>
hmm, not List.map I think
<sgronblo_>
oh wait
<sgronblo_>
it does use labels, never mind
badon has quit [Disconnected by services]
badon_ has joined #ocaml
badon_ is now known as badon
yegods has quit [Read error: Connection reset by peer]
<lyxia>
M-martinklepsch: there are a lot of useless brackets
<lyxia>
String.length s = 0
<lyxia>
s.[String.length s - 1]
<lyxia>
all of them actually
<ggole_>
M-martinklepsch: it might be a touch cleaner to have let ends_with str char = let len = String.length str in len > 0 && str.[len - 1] = char
<ggole_>
The advantage is avoiding the out of bounds condition
<ggole_>
While it doesn't matter much for this small program, it would be easy to forget to guard a call to last
<M-martinklepsch>
lyxia (IRC): thanks removed them
<M-martinklepsch>
ggole_ (IRC): so I was thinking that string_last is better from a general programming POV because it's more general, I see your point about the out of bound stuff though
<lyxia>
M-martinklepsch: what does the second clause of all_uppercase achieve?
<M-martinklepsch>
lyxia (IRC): without it "123" would be conceived as all uppercase. Really it should be a check if any letters occur in the string
<M-martinklepsch>
(but that was my quick solution)
<lyxia>
I see
<lyxia>
I don't have anything more to add.
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 260 seconds]
cdidd has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
yegods_ has joined #ocaml
darkf has quit [Quit: Leaving]
Simn has quit [Ping timeout: 276 seconds]
copy` has joined #ocaml
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 252 seconds]
noddy has joined #ocaml
dsheets has joined #ocaml
cdidd has quit [Ping timeout: 268 seconds]
yegods has joined #ocaml
yegods_ has quit [Read error: Connection reset by peer]
cdidd has joined #ocaml
sh0t has joined #ocaml
matason has quit [Quit: leaving]
nicholasf has quit [Remote host closed the connection]
nicholasf has joined #ocaml
bba has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
cdidd has quit [Ping timeout: 250 seconds]
<M-martinklepsch>
So, I'm implementing basic list-operations... got stuck on reverse. A solution I found here: https://ocaml.org/learn/tutorials/99problems.html is confusing me. The inner aux function has an acc argument but then also takes another list somehow?
cdidd has joined #ocaml
abruanese has quit [Quit: ZNC 1.6.1+deb1 - http://znc.in]
<apache2>
is there a way for 'struct .. end' section to refer to its signature, for example including a type? it feels a bit strange to have the type definition two times
<companion_cube>
apache2: no
<apache2>
hmm perhaps the type should be wrapped in a module of its own?
<companion_cube>
M-martinklepsch: rev [1;2;3] = aux [] [1;2;3] = aux [1] [2;3] = aux [2;1] [3] = aux [3;2;1] [] = [3;2;1]
shinnya has joined #ocaml
<apache2>
let module MyUnion = struct type t = A | B end in module MyModule : sig include MyUnion end = struct include MyUnion end ? is this blasphemy?
<apache2>
or something like that?
<companion_cube>
I don't think that's going to work
abruanese has joined #ocaml
<M-martinklepsch>
companion_cube (IRC): I do get how it works, I just don't understand the syntax of the "inner" function definition
<M-martinklepsch>
like the let rec ... declares the acc argument but where is the second specfied? is that implicit via the function's match like thing?
<ggole_>
apache2: seems a bit unnecessary? If you just want to avoid duplication the definition of the type, leave it in MyUnion and then use it in MyModule
<apache2>
but I want to expose it in the signature of MyModule
<ggole_>
type t = MyModule.t?
<apache2>
oh, sorry, I forgot to mention that MyModule is a functor and MyUnion's type depends o na type from the module argument
<apache2>
let module MyUnion = struct type t = A | B end in let module MyModule : sig include module type of MyUnion end = struct include MyUnion end in MyModule.A;;
<companion_cube>
M-martinklepsch: `let rec foo a = function ...` is the same as `let rec foo a b = match b with ...`
<apache2>
The type constructor MyModule.t would escape its scope
<M-martinklepsch>
companion_cube (IRC): I see. so if there would be three args it would be let rec foo a b = function-matching-c?
yegods has quit [Remote host closed the connection]
<apache2>
M-martinklepsch: "function" takes an argument and passes it to a match statement. "fun" takes an argument and passes it to the right-hand side of a let-binding, so to speak.
<companion_cube>
M-martinklepsch: it's a possibility, but not mandatory
mistermetaphor has joined #ocaml
<companion_cube>
`function` is used to directly match on the last argument
<apache2>
let rec foo a b = .. for example let rec foo a = fun b -> ...
<ggole_>
apache2: I see, but I don't think that problem has anything to do with include
<ggole_>
let module MyUnion = struct type t = A | B end in MyUnion.A will give you the same error
<apache2>
ah because it's being returned. got you.
<apache2>
let module MyUnion = struct type t = A | B end in let module MyModule : sig include module type of MyUnion end = struct include MyUnion end in match MyModule.A with A -> true | _ -> false;; this works
<sgronblo_>
can OCaml infer record types even if I don't declare those types explicitly?
<flux>
no, all record types must be predefined
<sgronblo_>
would let f a = a.foo; let g = f { foo = "bar" } work even without an explicit definition that type blah = { foo : bar } ?
<sgronblo_>
flux: ah i see, ok
<sgronblo_>
thanks
<flux>
however, this work as well: type ('a, 'b, 'c, 'd) record = { a : 'a; b : 'b; c : 'c; d : 'd }
<flux>
there are object values that work without defining them beforehand
<flux>
let f a = a#foo let g = f (object method foo = 42 end)
<sgronblo_>
also can i use ocaml keywords as valid record proprety names?
<sgronblo_>
such as end?
<flux>
no
<sgronblo_>
ok
<flux>
keywords can be used only in their syntactic meaning. very few languages do it differently.
* ggole_
points at lisp
<flux>
actually I was thinking of sql but not even there it seems to work
<flux>
and lisp.. does lisp even have keywords?
<ggole_>
Doesn't really matter too much since you can always whack a _ on the end
<flux>
or '!
<ggole_>
Does that work with keywords?
<ggole_>
Ah, it does
<ggole_>
Yeah, that's a bit more idiomatic.
ggole_ has quit []
ggole has joined #ocaml
jackweirdy has joined #ocaml
<M-martinklepsch>
is aux an abbreviation for a specific thing?
cdidd has quit [Ping timeout: 244 seconds]
<ggole>
auxiliary
hxegon has joined #ocaml
<ggole>
Usually used as an unhelpful but short name for an inner loop of some sort
<M-martinklepsch>
cool, thx
mistermetaphor has quit [Remote host closed the connection]
bba has joined #ocaml
bba_ has joined #ocaml
bba has quit [Read error: Connection reset by peer]
<M-martinklepsch>
Why can't I pass + as a function into another function
<ia0>
You most probably want to write (+) (a plus between parentheses)
<ggole>
It's a purely syntactic thing. + is a value just like any other.
aantron_ has quit [Remote host closed the connection]
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<M-martinklepsch>
with an interface like this: val filter : f:('a -> bool) -> 'a list -> 'a list, why does the order of labeled arguments matter?
<M-martinklepsch>
ia0 (IRC): that works, yeah
<M-martinklepsch>
ggole (IRC): if it's a value like any other why are the parentheses needed? like I can pass other functions without parentheses — are these not values like others somehow?
<ggole>
To distinguish the value + from the application + in a list of arguents.
<ggole>
eg, should f + 1 be an addition or calling f passing + as the argument?
<ggole>
For names that are not infix operators this problem does not occur, so no parens are needed.
noddy has quit [Ping timeout: 260 seconds]
<M-martinklepsch>
right, that's what I was just wondering. so basically there is some special handling needed for for infix operators
<ggole>
At the syntax level, yes
<M-martinklepsch>
ok cool. thanks for all your explanations ggole (IRC) :)
bba_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<M-martinklepsch>
regarding the ordering of labeled arguments, I assume that's related to currying?
<ggole>
I'm not quite sure what you mean
bba has joined #ocaml
yegods has quit [Ping timeout: 250 seconds]
Sorella has joined #ocaml
yegods has joined #ocaml
Simn has joined #ocaml
<M-martinklepsch>
an interface like this: val filter : f:('a -> bool) -> 'a list -> 'a list
<M-martinklepsch>
if I define filter like this: let rec filter l ~f = the compiler complains
bba has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<zozozo>
M-martinklepsch: sure, since you don't respect the order of arguments
<zozozo>
labelling arguments doesn't mean you can shuffle them around arbitrarily
rgrinberg has joined #ocaml
bba has joined #ocaml
<M-martinklepsch>
zozozo (IRC): I assumed labelling removes this requirement
cdidd has joined #ocaml
<zozozo>
if i remember correctly, labelled arguments can be shuffled with other labelled arguments as long as there isn't a non-labelled arguments between
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<zozozo>
for instance if you have a: val f : a:int -> b:int -> int, then you can do something like let a = 1 in let b = 2 in f ~b ~a
<zozozo>
but non-labelled arguments sort of act as a barrier
<zozozo>
well,a ctually, I'm wrong, :p
<zozozo>
M-martinklepsch: what version of the compiler do you use ?
<zozozo>
ok, so forget what I said
<M-martinklepsch>
in any case I'm mixing labelled and non-labelled
<ggole>
M-martinklepsch: the type mismatch there is because labelled arguments can be applied in an unlabelled way, so let f ~x ~y = ... and let f ~y ~x = ... do not have the same type
yegods has quit [Read error: Connection reset by peer]
slash^1 has joined #ocaml
bba has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<flux>
m-martinklepsch, you could write out the two special cases of 'append' to be much faster with less code :)
<M-martinklepsch>
flux (IRC): ok, thx, let me take another look :)
<flux>
(on second though, I guess it doesn't get any shorter, but the [], [] case can be handled with matches [], xs and xs, [] )
<_y>
M-martinklepsch, you can — and should — make your functions tail-recursive too ;-)
<_y>
(‘~f:f’ can be shortened ‘~f’)
<flux>
(and on actual try it did come shorter ;-))
<M-martinklepsch>
_y (IRC): how do you define tail recursive?
<M-martinklepsch>
flux (IRC): I'm not sure I understand what you mean by differently handling [], []
<flux>
m-martinklepsch, match l1, l2 with [], xs -> xs | xs, [] -> xs handles the case of [], [] properly as well
<_y>
M-martinklepsch, a recursive function is tail-recursive if the recursive call is the last operation the function performs (in other words, if the recursive call is the return value of the function)
<_y>
like ‘concat’ or ‘reverse’ in your code
<M-martinklepsch>
also can it be done faster or not? writing append I definitely felt like it's inefficient to add both lists to an entirely new list but I didn't come up with a better way
<_y>
but not like ‘length’ nor ‘append’
<flux>
the giveaway of 'append' is that don't use append if you worry about complexity :)
<flux>
but, to shop some food ->
<_y>
it’s better because the compiler can
<_y>
it’s better because the compiler do optimize tail-rec calls into a loop, which saves the cost of function calls and the use of the stack
<_y>
the usual trick is to use an accumulator value, just like you did for ‘reverse’
dsheets has quit [Remote host closed the connection]
<M-martinklepsch>
_y (IRC): ok, so if I understand correctly map and filter are also not properly tail recursive, yes?
<_y>
indeed M-martinklepsch
<_y>
in your code, ‘length’ can be easily made tail‐rec
<_y>
however, if you use an accumulator for the other functions (‘append’, ‘map’, ‘filter’), you would have to reverse it (or the original list) at some point
<_y>
so the performance gain is not that high (still better i think?), but still it makes the function allocate only one stack chunk, instead of one per recursive call
<Simn>
I had a situation recently where I had two subsequent tail-recursive operations and the second one didn't care about the input order. I still occasionally look at that code and be happy it worked out like that.
<_y>
which is very appreciable since OCaml’s stack is not that big (calling a non‐tail‐rec function (i·e· the standard ‘List.map’…) on a large list will cause a stack overflow)
toolslive has quit [Ping timeout: 250 seconds]
tane has quit [Ping timeout: 250 seconds]
<_y>
also, i wonder if optimizing something like ‘let f x = let f_aux acc y = (* something not using x *) in f_aux 0 x’ into ‘let f = let f_aux acc y = (* … *) in fun x -> f_aux 0 x’ has any impact?
<_y>
since in theory the first code would have to recreate a closure each time f is called, whereas the second code only create a (local) function at toplevel
<Simn>
I'm not sure if that's optimizing or pessimizing.
<zozozo>
_y: well, free variable analysis could and should detect that f_aux does not need x and thus optimize the closure allocation away, at least I hope
<ggole>
Closed functions will not be allocated even if they are nested.
<ggole>
Prior to flambda there are still many situations in which manual transformations can avoid closure allocations, though.
<_y>
M-martinklepsch, yes
<M-martinklepsch>
_y (IRC): thanks.
<_y>
ok ggole
<_y>
but if i have, say, ‘let f x y = let aux z = x + z in aux y’, would that mean that aux is allocated as soon as i feed x to f?
<ggole>
No, it would (assuming it isn't inlined away) be allocated in the body of f
<ggole>
By body I mean after the =
<ggole>
Perhaps you are thinking of let f = let aux z = x + z in fun y -> aux y
<ggole>
Er, let f x = ...
toolslive has joined #ocaml
<_y>
that is the rewriting that i would have done indeed
tane has joined #ocaml
<ggole>
That's not necessarily a better idea, though
<ggole>
Because you will have a closure construction anyway
<ggole>
(For the fun y -> ...)
<_y>
can’t the compiler η-reduce this (after type‐checking)?
<ggole>
But additionally you will probably incur partial application costs since the formerly "2-ary" function is now a 1-ary function that returns a function
<ggole>
This is speaking rather loosely since in ML all functions are unary, but the way that optimisations are done to make ML acceptably efficient work that way
zhs has quit [Quit: Page closed]
<ggole>
In short, let f x y = let aux z = x + z in aux y is the better way to write this.
<_y>
okay
noddy has joined #ocaml
<_y>
a funny way i found recently of getting rid of this nested helper‐function‐with‐accumulator is to add the accumulator to the final function as an optional argument
<Simn>
I always feel like I should wash my hands when using optional arguments.
<ggole>
Hmm, that changes the interface. I'm not really all that comfortable with doing that unless there is a good reason.
<ggole>
I suppose if it is internal code it doesn't matter too much, but then you get into a situation where you are writing code that is published in a signature and code that isn't differently. Not really fantastic.
<_y>
i guess the compiler do optimize recursive calls with an argument provided for the optional parameter (i·e· avoid constructing the option and destructing it)
<_y>
but indeed it changes the interface and exposes internals
<ggole>
I wouldn't expect it too.
<ggole>
(Maybe with flambda.)
<_y>
oh :-(
<ggole>
ocamlopt is pretty simple
hxegon has joined #ocaml
<_y>
i have so much questions and uncertainty about optimizations performed in OCaml
<ggole>
Recently it got some more sophisticated machinery though, so it will be interesting to see how that affects the ways in which OCaml code can be written while remaining efficient.
<ggole>
If in doubt, assume it isn't done.
nicholasf has quit [Remote host closed the connection]
<_y>
oops, *so many
shinnya has quit [Ping timeout: 276 seconds]
noddy has quit [Ping timeout: 276 seconds]
noddy has joined #ocaml
cdidd has quit []
dsheets has joined #ocaml
<ggole>
_y: it can be helpful to write a little test program and look at the output of the compiler
<ggole>
All of the stages can be easily dumped, although they take a little work to read
yegods has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 250 seconds]
noddy has quit [Ping timeout: 260 seconds]
yegods has joined #ocaml
cdidd has joined #ocaml
noddy has joined #ocaml
fraggle_ has quit [Read error: Connection reset by peer]
fraggle_ has joined #ocaml
cdidd has quit [Ping timeout: 246 seconds]
<_y>
yes, i’m not able yet to understand what is written, my bad
<_y>
by the way, will trmc definitely be included at some point, or is it still under debate?
noddy has quit [Ping timeout: 240 seconds]
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<ggole>
I'm not sure.
<ggole>
It would be nice to have.
noddy has joined #ocaml
<_y>
i naively think so too
<_y>
but apparently the performance gain is not that clear
<_y>
and it would break weird things with continuations that are unknown to me
noddy has quit [Ping timeout: 246 seconds]
noddy has joined #ocaml
yegods has quit [Ping timeout: 260 seconds]
cdidd has joined #ocaml
sh0t has quit [Ping timeout: 250 seconds]
dsheets has joined #ocaml
cdidd has quit [Ping timeout: 244 seconds]
noddy has quit [Ping timeout: 260 seconds]
cdidd has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
rntz has joined #ocaml
nicholasf has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Kakadu has joined #ocaml
nicholasf has quit [Ping timeout: 276 seconds]
hcarty has joined #ocaml
<rntz>
hi, where would you say is the best reference documentation for (1) ocaml itself; (2) the ocaml standard libraries; (3) jane street's Core library?
<hcarty>
rntz: (1) The language manual is well written (2) and includes documentation for the standard library. I've heard the .mli files are the best documentation for Core but I don't know if that is still true
<hcarty>
companion_cube: I'll have more time to spend on this later in the week, but a few lwt-pipe thoughts. It may be worth splitting out the IO piece into a separate, optional module to make lwt-pipe usable from js/mirage/other exotic places
<hcarty>
companion_cube: And now that the result type is pulled out of the generic pipe type it may be worth replacing 'a step with 'a option
<companion_cube>
oh, wait, you mean Lwt_io is not available on mirage?
<companion_cube>
hmmm
<companion_cube>
why not
<companion_cube>
so I should remove the IO part for now, I guess
<companion_cube>
or it can wait a bit ;_
<companion_cube>
;)
<hcarty>
companion_cube: No rush!
<hcarty>
Just getting thoughts out
<hcarty>
I'm not sure if Lwt_io is available on mirage or js_of_ocaml or not
<companion_cube>
the s/step/option is done
<hcarty>
So fast, thanks companion_cube :-)
<companion_cube>
:p
slash^ has quit [Read error: Connection reset by peer]
<companion_cube>
in the toplevel, you should #require "str";;
<companion_cube>
in a compiled program, depends on your build system
<companion_cube>
(with ocamlbuild, it would be -pkg str or, in _tags, true: package(str))
yegods has joined #ocaml
<rntz>
hcarty: thanks
<companion_cube>
Drup: do you know if lwt_io is available on mirage or jsoo?
<Drup>
it's in lwt.unix, right ?
<companion_cube>
yeah... :/
<companion_cube>
so absolutely no IO without lwt.unix
dsheets has joined #ocaml
<M-martinklepsch>
companion_cube (IRC): whats the difference between #require and open?
<companion_cube>
open is a matter of scope, within the language
<companion_cube>
`open A` means you can access A's values without qualifying them
<companion_cube>
#require, otoh, is a compilation construct, to load a library
dsheets has quit [Ping timeout: 250 seconds]
sh0t has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
<hcarty>
companion_cube: PR with pipe <-> stream conversion. Does that approach seem sane?
<companion_cube>
looks pretty reasonable
<companion_cube>
I'm only not sure about what happens if `of_stream s` is closed early
<hcarty>
companion_cube: Good point - I think the async exception handler would be called
<hcarty>
I'll update to handle that case
<companion_cube>
thanks :)
<hcarty>
I'm also planning to add a val from : 'a option -> ('a, _) t function, like Lwt_stream.from
noddy has joined #ocaml
<companion_cube>
sure
<_y>
M-martinklepsch, as a side note, many people out there would tell you *not* to use Str for regexes, but to use the library re (available on opam) instead
<companion_cube>
(yeah, that too)
<hcarty>
I need to go and I'm not sure how to handle the early-close condition safely. I'll come back to it later in the week
<hcarty>
companion_cube: ^
<companion_cube>
something like a hook, on the pipe, that cancels the producer thread
<companion_cube>
there is a "on_close" argument that should be used in this purpose, imho
dsheets has joined #ocaml
ggole has quit []
dsheets has quit [Remote host closed the connection]
dsheets has joined #ocaml
hcarty has quit [Ping timeout: 250 seconds]
<_y>
companion_cube, i’d love a parameter ?(by = 1) to {Gen,Sequence}.int_range ;-)
<companion_cube>
ah! that would indeed be relevant
<companion_cube>
(of course -- woudl remain the same)
<companion_cube>
would you feel like implementing it? PRs welcome :)
<companion_cube>
(otherwise open an issue and I'll do it some time)
lollancf37 has quit [Quit: leaving]
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 276 seconds]
natimic has joined #ocaml
<_y>
companion_cube, if i find out how to contribute, yes :-)
<_y>
i’ve never done that sort of things before
<companion_cube>
oh!
hxegon has joined #ocaml
<_y>
but looks like it’s two lines to change
dsheets has quit [Remote host closed the connection]
yegods has quit [Remote host closed the connection]
<M-martinklepsch>
_y (IRC): thanks I'll give re a try. actually I couldn't figure out how to get str working at all
noddy has quit [Ping timeout: 240 seconds]
leyyin has quit [Quit: So Long, and Thanks for All the Fish]
<M-martinklepsch>
that said where can I find api docs for re? Essentially I'm trying to write a very basic tokenizer, any pointers appreciated. Still not very familiar navigating the ocaml ecosystem
<companion_cube>
hmmm, good question actually, so far I've been reading the .mli -_-
yegods has joined #ocaml
Ch0c0late has joined #ocaml
malc_ has quit [Quit: ERC (IRC client for Emacs 25.0.50.2)]
<M-martinklepsch>
is anyone here using emacs/tuareg? I'm using it's live evaluation/repl stuff which is great but I'm not sure if I need to change anything to add additional libraries like re to the environment
uggwar has joined #ocaml
manizzle has quit [Ping timeout: 246 seconds]
A1977494 has joined #ocaml
<_y>
M-martinklepsch, if you git clone the source (instead of downloading via opam), you can ask ‘make’ to build the doc
<_y>
after that you get a local copy of the doc as html
<_y>
and you can throw the rest away
A19774941 has quit [Ping timeout: 260 seconds]
<M-martinklepsch>
_y (IRC): I think I'm ok with reading the interfaces, probably something I should get comfortable with anyways
noddy has joined #ocaml
<_y>
M-martinklepsch, why not, if that’s not to messy with inclusions and everything
dsheets has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
yegods has quit [Ping timeout: 276 seconds]
nicholasf has joined #ocaml
nicholasf has quit [Remote host closed the connection]
yegods has joined #ocaml
nicholasf has joined #ocaml
hxegon has quit [Quit: My Mac has gone to sleep. ZZZzzz…]