adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
brettgilio has joined #ocaml
toppler has joined #ocaml
oni-on-ion has quit [Ping timeout: 245 seconds]
ygrek_ has quit [Ping timeout: 240 seconds]
oni-on-ion has joined #ocaml
spew has quit [Quit: Connection closed for inactivity]
jimt has joined #ocaml
nullifidian_ has joined #ocaml
nullifidian has quit [Ping timeout: 265 seconds]
wyn44 has joined #ocaml
toppler has quit [Ping timeout: 245 seconds]
wyn44 has quit [Ping timeout: 240 seconds]
toppler has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
silver has quit [Read error: Connection reset by peer]
Ptival has joined #ocaml
toppler has quit [Ping timeout: 240 seconds]
toppler has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
wyn44 has joined #ocaml
wyn44 has quit [Ping timeout: 268 seconds]
toppler has quit [Ping timeout: 245 seconds]
toppler has joined #ocaml
tormen has joined #ocaml
tormen_ has quit [Ping timeout: 265 seconds]
mfp has quit [Ping timeout: 265 seconds]
zolk3ri has quit [Remote host closed the connection]
toppler has quit [Ping timeout: 276 seconds]
nullifidian__ has joined #ocaml
nullifidian_ has quit [Ping timeout: 240 seconds]
toppler has joined #ocaml
wyn44 has joined #ocaml
wyn44 has quit [Ping timeout: 240 seconds]
retropikzel has joined #ocaml
bitwinery has joined #ocaml
bitwinery has quit [Remote host closed the connection]
bitwinery has joined #ocaml
_whitelogger has joined #ocaml
toppler has quit [Ping timeout: 252 seconds]
retropikzel has quit [Remote host closed the connection]
gravicappa has joined #ocaml
jkq has joined #ocaml
toppler has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
toppler has quit [Ping timeout: 268 seconds]
nullifidian has joined #ocaml
mbuf has joined #ocaml
narimiran has joined #ocaml
nullifidian__ has quit [Ping timeout: 276 seconds]
toppler has joined #ocaml
wyn44 has joined #ocaml
wyn44 has quit [Ping timeout: 265 seconds]
barockobamo has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
Serpent7776 has joined #ocaml
toppler has quit [Ping timeout: 268 seconds]
jmiven has quit [Quit: bye]
jmiven has joined #ocaml
ravenousmoose has joined #ocaml
toppler has joined #ocaml
bitwinery has quit [Quit: Leaving]
Haudegen has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
nullifidian_ has joined #ocaml
bartholin has quit [Remote host closed the connection]
philtor has quit [Ping timeout: 268 seconds]
zmt00 has quit [Read error: Connection reset by peer]
zmt00 has joined #ocaml
toppler has quit [Ping timeout: 240 seconds]
philtor has joined #ocaml
wyn44 has joined #ocaml
stan[m] has joined #ocaml
ravenousmoose has quit [Ping timeout: 246 seconds]
wyn44 has quit [Ping timeout: 268 seconds]
barockobamo has quit [Ping timeout: 265 seconds]
<Leonidas> narimiran: using List.nth is usually an antipattern in any case
<narimiran> Leonidas: ok, how to do it idiomatically? convert it to an array?
<Leonidas> narimiran: if there is significance in the order of the elements in that list, probably encoding your data in a tuple is a better way
<Leonidas> narimiran: the access pattern of lists is usually x :: xs aka head vs tail for processing them.
<narimiran> Leonidas: ok, let's say that i have `'a list list` which is the result of `read_lines_l` (creating a list or lines), and then splitting each line on whitespace, so each line is split in the same amount of elements
<narimiran> i'll still have to convert that list to a tuple
<narimiran> `match line with [a; b; c] -> (a, b, c) | _ -> fail_with "wrong input"`?
<Leonidas> narimiran: but each line might have a different amount of whitespace?
<narimiran> let say it is well-formatted
<Leonidas> in such case I would write a splitting function that returns the right tuple
<Leonidas> instead of going through a list
<Leonidas> Probably an ('a * 'b, 'c) result though
toppler has joined #ocaml
<octachron> Converting the list to an array or a tuple (or a record) if the size is statistically known seems a valid path too.
barockobamo has joined #ocaml
<Leonidas> since I would view the splitting of the line as "parsing", thus having the wrong amount of whitespace be a syntax error in the input and thus a result. I wouldn't parse it successfully only to fall over later over an exception in List.nth
<Leonidas> but yeah, if the elements in the list have even more significance, a record would be possibly even better; depending on the usecase!
<narimiran> here is an example of what i have and what i have done (warning: i'm ocaml beginner): http://ix.io/20Xv
<narimiran> (yeah, that's advent of code task :))
<Leonidas> what do each of those columns mean?
<narimiran> i know that using `Str` would be probably better than this hack of mine to remove empty strings from the created list
<Leonidas> I would write a `parse_line : string -> int * int * int Or_error.t` function
<Leonidas> Don't use Str, it is terrible
<narimiran> Leonidas: it is AoC task where the numbers are "the side lengths of each triangle it describes"
<narimiran> Leonidas: heh, ok, what to use for regex then?
<Leonidas> narimiran: type triangle { a : int; b : int; c : int }
<Leonidas> narimiran: `re` probably, but I don't actually think regular expressions make sense here
<narimiran> ok, i'm asking generally
<Leonidas> narimiran: your "list" has a very definite length, 3, a triangle with 2 or 4 sides makes very little sense, so you should encode a triangle in a way where nonsensical combinations should not appear
<octachron> For this kind of very limited parsing, Scanf works well: "Scanf.sscanf line "%d %d %d" (fun (a,b,c) -> a, b ,c)" .
<narimiran> octachron: oooh, i really like `scanf` in Nim, i haven't used it in ocaml yet, but it might be exactly what i need here. thanks!
malina has quit [Ping timeout: 240 seconds]
tizoc has quit [Quit: Coyote finally caught me]
tizoc has joined #ocaml
gravicappa has quit [Ping timeout: 265 seconds]
<narimiran> ok, i refactored my code to create list of `{ a : int; b : int; c : int }` with the help of `sscanf`. thank you Leonidas and octachron!
<narimiran> but unfortunately that won't do the trick for the second part of that task, where you need to transpose your input and then basically do `CCList.sublists_of_len 3
<Leonidas> I am not sure what the task is, since you're describing it by means of (non-working) solutions, instead of what you actually want to do
<narimiran> :D
<narimiran> here you go: https://adventofcode.com/2016/day/3 but you won't see part2 until you solve part1
<narimiran> so for the same input (http://ix.io/20Xv), the triangles are now written vertically: (566, 575, 50), (558, 133, 670), (84, 910, 894), etc.
<narimiran> i have the solution, but it is much uglier than the original one where i had `int list list`
<narimiran> the original "transpose" was just this: http://ix.io/20XQ/ocaml
nullifidian_ is now known as nullifidian
toppler has quit [Ping timeout: 250 seconds]
<octachron> narimiran, it is not clear what you are trying to do, if the input format changed, you should change your parsing format, and not parse with the wrong function, unparse and reparse.
<narimiran> octachron: input file is the same, but now you don't need to parse it line by line, but column by column. but you're right, i need to change my parsing function
<octachron> Also you should consider that matching on strings doesn't exist too. You could use projectors, or variants. But matching on strings that can only takes three distinct values is bad form.
<narimiran> yeah, this was only a quick hack to see if i can even make it to do what i needed. let me completely rewrite parsing....
wyn44 has joined #ocaml
nullifidian_ has joined #ocaml
lizzin has joined #ocaml
toppler has joined #ocaml
nullifidian has quit [Ping timeout: 240 seconds]
<narimiran> here we go, two separate parsing functions: http://ix.io/20XW/ocaml - thanks once again for your time and help guys!
mfp has joined #ocaml
jao has joined #ocaml
jao is now known as Guest68393
toppler has quit [Ping timeout: 268 seconds]
toppler has joined #ocaml
jkq has quit [Quit: jkq]
jbrown has quit [Quit: Leaving]
toppler has quit [Ping timeout: 240 seconds]
gareppa has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ggole has joined #ocaml
silver has joined #ocaml
toppler has joined #ocaml
<toppler> I want to write two mli files, one which includes the other but replacing a type. Is this possible? I'm trying to refer to the included module type with "module type of" but the type coming back appears to be a module type inferred from the ml file and not the one provided by the mli type.
<toppler> I've pulled out the signature I want into its own ml file which I include from the two mli files, but I was wondering if I could get by without having to do this.
averell has quit [Remote host closed the connection]
<flux> what does 'include Module' in place of `module type of` do?
<toppler> It'll complain that there is no module type with that name, right?
<toppler> My understanding is that the mli files don't get bound to a module type.
<toppler> (type name)
<ggole> No, they're the signature for the .ml
<toppler> Is there any way to refer to that signature?
<ggole> If you have foo.mli/foo.ml, it's (mostly) as if you had written module Foo : sig <foo.mli> end = struct <foo.ml> end
<ggole> Hmm, I would have thought module type of would do that
<toppler> I want to be able to refer to it, but my understanding is that the signature isn't bound to a name like the implementation is.
<toppler> It seems that "module type of" only infers the signature. Specifically, the types are not abstracted.
<ggole> I'm not quite sure what you mean. If you want more control over the signature, you'll probably have to name the type yourself (which it sounds like you have tried already)
<toppler> It's like when you do "module type FOO = module type of struct type t = int end". The inferred type is type t = int, not abstract.
<toppler> *The inferred module type is sig type t = int end.
<toppler> However, if you do module Foo : sig type t end = struct type t = int end, then module type Foo will give you the more abstract signature.
<Drup> toppler: if you use a similar interface for two different modules, I suggest writing down the signature.
<ggole> Well, that's just the contents of that module type. It has little or nothing to do with module type of.
<Drup> and not use `module type of` as a shortcut for not having to write the signature.
<toppler> Drup: It's what I'm doing. I was just wondering if there was a way to do it without pulling out the common part.
brettgilio has quit [Ping timeout: 245 seconds]
brettgilio has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<Drup> all the other methods are less clean and less reliable
<ggole> You might be able to pull off some dumb trick with substitution, but honestly, just write out the type.
averell has joined #ocaml
toppler has quit [Ping timeout: 276 seconds]
gikiam has left #ocaml ["WeeChat 2.1"]
Guest68393 has quit [Remote host closed the connection]
jao has joined #ocaml
wyn44 has quit [Ping timeout: 240 seconds]
gareppa has quit [Quit: Leaving]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
toppler has joined #ocaml
jbrown has joined #ocaml
brettgilio has quit [Ping timeout: 245 seconds]
wyn44 has joined #ocaml
ollehar has joined #ocaml
wyn44 has quit [Ping timeout: 240 seconds]
wyn44 has joined #ocaml
brettgilio has joined #ocaml
wyn44 has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
wyn44 has joined #ocaml
gravicappa has joined #ocaml
wyn44 has quit [Ping timeout: 268 seconds]
jbrown has quit [Quit: Leaving]
brettgilio has quit [Ping timeout: 245 seconds]
brettgilio has joined #ocaml
klntsky has quit [Remote host closed the connection]
klntsky has joined #ocaml
gareppa has joined #ocaml
nullifidian_ is now known as nullifidian
gareppa has quit [Ping timeout: 240 seconds]
smazga has joined #ocaml
okuu has joined #ocaml
unyu has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Quit: Leaving]
wyn44 has joined #ocaml
gareppa has joined #ocaml
wyn44 has quit [Ping timeout: 240 seconds]
rgherdt has joined #ocaml
wyn44 has joined #ocaml
narimiran has quit [Ping timeout: 245 seconds]
Haudegen has quit [Quit: Bin weg.]
ollehar has quit [Ping timeout: 265 seconds]
KeyJoo has joined #ocaml
ggole has quit [Quit: Leaving]
rgherdt has quit [Ping timeout: 252 seconds]
wyn44 has quit [Ping timeout: 240 seconds]
retropikzel has joined #ocaml
brettgilio has quit [Ping timeout: 245 seconds]
brettgilio has joined #ocaml
jbrown has joined #ocaml
gareppa has quit [Quit: Leaving]
rgherdt has joined #ocaml
ziyourenxiang has quit [Ping timeout: 265 seconds]
KeyJoo has quit [Quit: KeyJoo]
Serpent7776 has joined #ocaml
rgherdt has quit [Remote host closed the connection]
rgherdt has joined #ocaml
rgherdt has quit [Remote host closed the connection]
rgherdt has joined #ocaml
rgherdt has quit [Remote host closed the connection]
rgherdt has joined #ocaml
barockobamo has quit [Remote host closed the connection]
Haudegen has joined #ocaml
brettgilio has quit [Ping timeout: 245 seconds]
rgherdt has quit [Remote host closed the connection]
nullifidian_ has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
retropikzel has quit [Remote host closed the connection]
gareppa has joined #ocaml
rgherdt has joined #ocaml
brettgilio has joined #ocaml
mbuf has quit [Quit: Leaving]
brettgilio has quit [Ping timeout: 246 seconds]
brettgilio has joined #ocaml
rosterok has joined #ocaml
gareppa has quit [Quit: Leaving]
nullifidian_ is now known as nullifidian
jnavila has joined #ocaml
malina has joined #ocaml
wyn44 has joined #ocaml
narimiran has joined #ocaml
wyn44 has quit [Ping timeout: 276 seconds]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
lbart has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
kakadu has joined #ocaml
ygrek_ has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
Haudegen has joined #ocaml
vicfred has joined #ocaml
wyn44 has joined #ocaml
jnavila has quit [Remote host closed the connection]
gravicappa has quit [Ping timeout: 265 seconds]
wyn44 has quit [Ping timeout: 246 seconds]
narimiran has quit [Ping timeout: 250 seconds]
rosterok has quit [Quit: Connection closed for inactivity]
silver has quit [Quit: rakede]
kakadu has quit [Remote host closed the connection]
brettgilio has quit [Ping timeout: 245 seconds]
brettgilio has joined #ocaml
kalio has quit [Quit: WeeChat 2.5]
wyn44 has joined #ocaml
kalio has joined #ocaml
ziyourenxiang has joined #ocaml
redbagels is now known as greenbagels
wyn44 has quit [Ping timeout: 276 seconds]
rgherdt has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Quit: Lost terminal]
okuu has quit [Quit: ERC (IRC client for Emacs 26.3)]
unyu has joined #ocaml
Haudegen has quit [Ping timeout: 268 seconds]
ygrek_ has quit [Ping timeout: 240 seconds]