companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.05.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.05/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
<whoman> yeah, like lisp; the code is already a tree so one could 'execute' parts of it or just refer to it as data or etc.; but i need limitations to stay sane, i am just getting out of that mind set (of no-mindset)
<whoman> i would probably now use sexplib for a similar purpose as yours
<whoman> https://github.com/janestreet/sexplib -- i came across it for the purpose of serialization and ipc =)
sepp2k has quit [Quit: Leaving.]
<orbifx[m]> Yeah, sexplib is cool
kalio has quit [Quit: WeeChat 1.9.1]
kalio has joined #ocaml
<whoman> i learned about [@@deriving] from it, that is also quite cool =)
<whoman> (coming from haskell, as well)
<Drup> orbifx[m]: you will not have efficiency problem unless you hit 100s/1000s elements
<orbifx[m]> whoman: Yeah, handy. Personally I'm avoiding extensions as much as I can.
<Drup> You can probably revisit efficiency when you have blog that are that popular :p
<orbifx[m]> Drup: since this is in the guts of the system almost, I'd rather i didn't break those interfaces in the future. It's nice to put a _bit_ of thought in advance
<whoman> orbifx[m], me as well. only two so far, i may be end up with four max.
<orbifx[m]> Drup: I think I can provide both interfaces anyway. Got the function interface just now and can add a tree for others
<Drup> orbifx[m]: HTML template was never an efficiency problem, really ....
<orbifx[m]> ?
<Drup> I mean, the problem was always to design a sensible system, efficiency was never the main problem ;)
<Drup> (I would argue that most templating system fail at that task, but, oh well)
<orbifx[m]> I see
<orbifx[m]> I'm not designing a templating system, I integrate Mustache for now.
<orbifx[m]> But I need to leave that part of the interface flexible. Both a module or a tree will give enough flexibility, the latter greater most likely.
<Drup> yeah, I gathered that, hence my comment: just do the trivial thing, it will be good enough for a long while
<orbifx[m]> My question was quasi-academic, for how does one decide in such cases.
<orbifx[m]> Yeah, I agree, going with what takes the least effort for now.
<orbifx[m]> It's a big break, hopefully won't have to do such pervasive changes again later
<orbifx[m]> But anyway, that's an interesting overlap there no? Trees vs modules.
<whoman> hm,; can't do this? -> type 'a x = (z 'a) list
<whoman> (haskell "data A a' = [Z a']" )
cbot has joined #ocaml
<orbifx[m]> whoman: what's z?
<whoman> random type
<whoman> like "type 'a Zed = Left string | Right of 'a"
<whoman> +of
* whoman converting haskell code at the moment
superherointj has joined #ocaml
<orbifx[m]> `type 'a zed = Left of string | Right of 'a` ?
<orbifx[m]> whoman: ?
<orbifx[m]> capitalised words are reserved for modules whoman
<orbifx[m]> ow and constructors
<whoman> i will clarify
<whoman> type 'a perfstep = Trans of string | Render of 'a
<whoman> now, i want a list of these
<whoman> type 'a process = (perfstep 'a) list <--- is my intention
<whoman> i know about the case sensitivity things about programming tho thx
<orbifx[m]> `[ Trans "a"; Trans "b"; Render x; ...]`
nomicflux has joined #ocaml
<orbifx[m]> where `x` can be any type.
<whoman> i suppose i could type that in to merlin and see what she says.
<orbifx[m]> Haven't used merlin to help there :P
<whoman> oh, i figured it out. no i meant the toplevel actually =)
<whoman> i am just trying to figure out the syntax lol, im not learning how to code ocaml
<whoman> its just "type 'a process = 'a perfstep list" -- it was very simple wasn't it?
<rks`> very.
<orbifx[m]> :P
<orbifx[m]> whoman: was going to say, cause I noticed you wrote `type 'a process = (perfstep 'a) list`, the type is on the right in OCaml.
<orbifx[m]> But I thought you wanted to make a value, rather than a type signature.
<whoman> i clued in when ocaml said 'type string does not accept arg' =) as to the order of which. now i know =)
<whoman> a good kind of knowing, burned in there nice and deep, from experience =P
superherointj has quit [Quit: Leaving]
silver has quit [Read error: Connection reset by peer]
pierpa has quit [Quit: Page closed]
sh0t has joined #ocaml
<orbifx[m]> hehe
enterprisey has quit [Remote host closed the connection]
<orbifx[m]> I'm away
sh0t has quit [Remote host closed the connection]
nomicflux has quit [Quit: nomicflux]
mfp has quit [Ping timeout: 255 seconds]
JazzyEagle has quit [Ping timeout: 255 seconds]
sh0t has joined #ocaml
sh0t has quit [Remote host closed the connection]
teknozulu has quit [Ping timeout: 248 seconds]
JazzyEagle has joined #ocaml
_whitelogger has joined #ocaml
JazzyEagle has quit [Ping timeout: 240 seconds]
teknozulu has joined #ocaml
<whoman> i am having some difficulties with module and type scope here
teknozulu has quit [Ping timeout: 248 seconds]
p1n34ppl3 has quit [Quit: Lost terminal]
mk9 has joined #ocaml
teknozulu has joined #ocaml
govg has joined #ocaml
teknozulu has quit [Ping timeout: 248 seconds]
<whoman> phew okay i got a handle on things sort of. first class modules n all this is a bit new for me. and merlin is happy again and i hope everyone doing ocaml+emacs is using that
JazzyEagle has joined #ocaml
mk9 has quit [Remote host closed the connection]
mk9 has joined #ocaml
pkd has quit [Quit: Leaving]
infinity0_ has joined #ocaml
infinity0 has quit [Ping timeout: 248 seconds]
infinity0_ is now known as infinity0
infinity0 has quit [Changing host]
infinity0 has joined #ocaml
teknozulu has joined #ocaml
mbuf has joined #ocaml
teknozulu has quit [Ping timeout: 248 seconds]
enterprisey has joined #ocaml
mk9 has quit [Quit: mk9]
hooman has joined #ocaml
whoman has quit [Ping timeout: 248 seconds]
sapristi has joined #ocaml
jbrown has quit [Ping timeout: 240 seconds]
argent_smith has joined #ocaml
mk9 has joined #ocaml
sapristi has quit [Ping timeout: 240 seconds]
p1n34ppl3 has joined #ocaml
teknozulu has joined #ocaml
mk9 has quit [Quit: mk9]
raphaelss has quit [Remote host closed the connection]
teknozulu has quit [Ping timeout: 240 seconds]
TarVanimelde has joined #ocaml
teknozulu has joined #ocaml
malina has joined #ocaml
AltGr has joined #ocaml
teknozulu has quit [Ping timeout: 248 seconds]
sapristi has joined #ocaml
freusque has joined #ocaml
cbot has quit [Quit: Leaving]
andreas___ has joined #ocaml
malina has quit [Remote host closed the connection]
teknozulu has joined #ocaml
enterprisey has quit [Remote host closed the connection]
teknozulu has quit [Ping timeout: 240 seconds]
malina has joined #ocaml
zolk3ri has joined #ocaml
<M-martinklepsch> I'm needing something like group_by for a type like this: `type ledgerx = {date: date; title: string; entries: entry list; source: account}` — I want to return the same type but all items with the same date should be merged (i.e. the entry lists should be concatenated).
<johnelse> M-martinklepsch: I would do a List.sort by date, and then List.fold_left along the resulting list
<M-martinklepsch> found some stuff online but passing (Hashtable.create 100) as init somehow doesn't work
<johnelse> Keep track of the last item's date, and if the next item has the same date, concatenate its entries with those of the item at the head of the list
ziyourenxiang has joined #ocaml
<octachron> another option would be to construct a map using dates as key
p1n34ppl3 has quit [Quit: Lost terminal]
<M-martinklepsch> yeah, that's what I was thinking of initially. but sort + reduce also sounds reasonable. now I'll have to implement a comparator for my custom date type though :P
<octachron> Except if you have functional values inside your date type, you can just use polymorphic compare
<M-martinklepsch> octachron: I represent dates as their own type `(date ((day 12) (month 01) (year 2016)))` so I'm not sure polymorphic compare will be able to compare those semantically correct?
_andre has joined #ocaml
<octachron> It depends on your specific implementation of the date type. Polymorphic compare is implemented as lexicographical order over record fields for instance
<octachron> But in general, for semantic comparison, implementing your own comparison is indeed more robust
TarVanimelde has quit [Quit: TarVanimelde]
teknozulu has joined #ocaml
teknozulu has quit [Ping timeout: 248 seconds]
TarVanimelde has joined #ocaml
<M-martinklepsch> is there a way to extend the default `compare` to my type or should I just have a completely separate function? I couldn't find an immediately obvious way to extend the default compare
<orbifx[m]> You could compose multiple `compare` functions into one large one.
TarVanimelde has quit [Quit: TarVanimelde]
<M-martinklepsch> So since it's a date I was thinking I'd just ISO8601-format it and compare those strings — now weirdly in utop `compare "a" "b"` works just fine but in by (Base using) code compare expects an `int`
<octachron> Base (and Core) disables the polymorphic compare function. Also, I am not sure, why you would want to compare date by converting them to string first
<M-martinklepsch> I see. Gotta say this whole Base/Core/Batteries/Containers/Stdlib thing is pretty confusing to me :D Like in a way there are different versions of OCaml, and it's not always explicitly marked which version a given snippet is about.
<M-martinklepsch> octachron: you're absolutely right in that converting it to a string first doesn't make much sense but comparing year, then month, then day seemed more verbose/brittle
<M-martinklepsch> also my date's component are strings currently :D
<octachron> It nice of you to allow date like 2017/٠٥/Rossignol. I am not sure if it is very pratical however.
teknozulu has joined #ocaml
<M-martinklepsch> octachron: you're totally right of course, I'll need to fix that. I'm getting the data out of CSVs though and just haven't had a strong reason to do that yet
teknozulu has quit [Ping timeout: 248 seconds]
kakadu has joined #ocaml
mfp has joined #ocaml
silver has joined #ocaml
teknozulu has joined #ocaml
teknozulu has quit [Ping timeout: 248 seconds]
<orbifx[m]> martinklepsch: there are libraries for proper date types and comparisons, such as ptime.
malina has quit [Ping timeout: 255 seconds]
malina has joined #ocaml
<M-martinklepsch> Orbifx: yeah, I'm sure there are but wanting to keep things minimal for now
nomicflux has joined #ocaml
teknozulu has joined #ocaml
nomicflux has quit [Quit: nomicflux]
teknozulu has quit [Ping timeout: 248 seconds]
<M-martinklepsch> So I implemented compare for my date type: http://sprunge.us/gVDh — there are probably much nicer ways to do this? Would be thankful for some feedback on how to do this "the OCaml way"
<haesbaert> dddd
<haesbaert> ooops
<zozozo> M-martinklepsch: some libraries make chaining comparisons easier (see https://discuss.ocaml.org/t/canonical-way-to-write-a-compare-function/897)
nomicflux has joined #ocaml
nomicflux has quit [Client Quit]
FreeBirdLjj has joined #ocaml
nomicflux has joined #ocaml
mbuf has quit [Quit: Leaving]
nomicflux has quit [Client Quit]
jbrown has joined #ocaml
raphaelss has joined #ocaml
raphaelss has quit [Ping timeout: 252 seconds]
teknozulu has joined #ocaml
zv has quit [Quit: WeeChat 1.9]
teknozulu has quit [Ping timeout: 240 seconds]
spew has joined #ocaml
<orbifx[m]> Any packages providing unordered sets?
spew has quit [Client Quit]
<zozozo> orbifx[m]: there are some functions in CCList
<orbifx[m]> thanks zozozo
spew has joined #ocaml
<orbifx[m]> Is there a reason why a computation involving a NaN float doesn't rasise an exception?
<zozozo> orbifx[m]: "Floating-point operations never raise an exception on overflow, underflow, division by zero, etc" from the doc of Pervasives
<zozozo> also, "any arithmetic operation with nan as argument returns nan as result."
<orbifx[m]> I guess it makes sense. Which makes me realise what I'm actually curious about: why does `int_of_float nan` doesn't raise an exception and yields 0?
<zozozo> good question
<orbifx[m]> > The result is unspecified if the argument is nan or falls outside the range of representable integers.
<orbifx[m]> It should raise an Invalid_argument maybe?
<zozozo> unspecified but doesn't raise
sepp2k has joined #ocaml
shinnya has joined #ocaml
<octachron> Note also that "int_of_float" is a C primitive, and conversion from nan is unspecified in the C standard, so this behavior is largely inherited from the C compiler used
<orbifx[m]> Hmm, but would it not be better behaviour?
mk9 has joined #ocaml
<orbifx[m]> Safer
teknozulu has joined #ocaml
<octachron> Maybe; but conversion from float to integer is brittle by nature (neither surjective nor injective)
teknozulu has quit [Ping timeout: 248 seconds]
<octachron> and they are not fix for things like "int_of_float (1. +. f) ≠ 1 + (int_of_float f)"
sz0 has joined #ocaml
<orbifx[m]> Sure, although
<orbifx[m]> The issue there is accuracy rather than safety
zolk3ri has quit [Ping timeout: 240 seconds]
zolk3ri has joined #ocaml
sepp2k has quit [Ping timeout: 248 seconds]
sepp2k has joined #ocaml
sepp2k has quit [Client Quit]
sepp2k has joined #ocaml
freusque has quit [Quit: WeeChat 1.9.1]
shinnya has quit [Ping timeout: 240 seconds]
* hooman learning use cases between modules, objects, classes, records
argent_smith1 has joined #ocaml
raphaelss has joined #ocaml
argent_smith has quit [Ping timeout: 255 seconds]
barcabuona has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
teknozulu has joined #ocaml
FreeBirdLjj has joined #ocaml
enterprisey has joined #ocaml
FreeBird_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 248 seconds]
Serpent7776 has joined #ocaml
teknozulu has quit [Ping timeout: 240 seconds]
AlexRussia has joined #ocaml
<orbifx[m]> How is one supposed to check for nans anyway? Compare? `x = nan` doesn't seem to work.
<thizanne> orbifx[m]: x <> x
<orbifx[m]> thanks thizanne
<orbifx[m]> I'm starting to feel like I'm working with Javascript :P
<thizanne> yeah I guess that's what float are about
tane has joined #ocaml
barcabuona has quit [Quit: WeeChat 1.9.1]
<orbifx[m]> `x <> x` makes sense actually
raphaelss has quit [Remote host closed the connection]
<M-martinklepsch> Does anyone know of a REPL thing that integrates with Atom?
<orbifx[m]> Cool thanks thizanne
<M-martinklepsch> Founds this: https://atom.io/packages/repl but wondering if there's anything better
<M-martinklepsch> I guess most people just use Emacs or so?
<M-martinklepsch> When I run `=> jbuilder utop` I'm getting "Don't know how to build .utop/utop.exe"
<orbifx[m]> Hmm, dunno. I use emacs + tuareg only.
<M-martinklepsch> Orbifx: do you use the repl a lot?
<orbifx[m]> I use utop from terminal occasionally..
<orbifx[m]> Not from within Emacs
<M-martinklepsch> How do you verify the behavior of smaller pieces of code? Do you change the entry point of your code to run the function you want to test?
<orbifx[m]> I tend to just build and test
<orbifx[m]> Occasionally I paste into utop
<rgrinberg> M-martinklepsch: you need to provide a dir argument to where your lib is defined
<M-martinklepsch> rgrinberg: yeah, I was doing that, provided `.` as argument since that is where my jbuild file is
kakadu has quit [Quit: Konversation terminated!]
malina has quit [Ping timeout: 248 seconds]
<M-martinklepsch> Another thing I'm confused about: in Base I get a warning when using != since it comes from OCaml's stdlib, suggestion is to use [not (phys_equal ...)]. Why is it wrong to use != when using Base?
jnavila has joined #ocaml
<Armael> M-martinklepsch: are you using != instead of <> by mistake?
Serpent7776 has quit [Quit: Leaving]
hooman has quit [Read error: Connection reset by peer]
sapristi has quit [Remote host closed the connection]
<Armael> I don't know anything about Base, but I assume they warn about != because it's a common mistake to use it instead of <>
sapristi has joined #ocaml
whoman has joined #ocaml
<Armael> (and if you really want !=, use not (phys_equal ..) instead which is more explicit)
<M-martinklepsch> ahh, that makes sense I guess, thanks Armael
<M-martinklepsch> although with <> I get an error that expects something of type int
<M-martinklepsch> I'm using a custom type, expecting I can just compare it with "value semantics", ie. "are all the fields equal?"
<Armael> that's what <> from OCaml's stdlib is doing, but I suspect in Base they want you to explicitly write or derive a equality/comparison function
<Armael> ah yes, see Base's readme
<Armael> subsection "Comparison operators"
<rgrinberg> M-martinklepsch: maybe you don't have a library defined in your jbuild file?
<M-martinklepsch> Armael: thanks for the pointer, makes sense :)
<M-martinklepsch> rgrinberg: you mean like I'm missing a library that I'm using? this is by jbuild file http://sprunge.us/ChAQ
AlexRussia has quit [Ping timeout: 240 seconds]
eagleflo has quit [Read error: Connection reset by peer]
eagleflo has joined #ocaml
<Armael> adrien: btw topic could be updated wrt ocaml 4.06
slash^ has joined #ocaml
<adrien> Armael: sure
ziyourenxiang has quit [Ping timeout: 258 seconds]
Jesin has joined #ocaml
Anarchos has joined #ocaml
FreeBird_ has quit [Remote host closed the connection]
andreas___ has quit [Quit: Connection closed for inactivity]
sh0t has joined #ocaml
malina has joined #ocaml
kakadu has joined #ocaml
<adrien> fail
<adrien> let's find the right channel mode
<adrien> meh, apparently I need even more access flags to configure chanserv
<adrien> great, it seems noone has the rights anymore
<adrien> Armael: prepare the topic and I'll set it
<adrien> now if only freenode staff could stop being as annoying as they are with channel registration
<thizanne> /topic Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.06.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.06/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
<Armael> wtf tho
sh0t has quit [Remote host closed the connection]
sh0t has joined #ocaml
sh0t has quit [Ping timeout: 252 seconds]
adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.06.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.06/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
<adrien> thanks
sh0t has joined #ocaml
raphaelss has joined #ocaml
enterprisey has quit [Ping timeout: 240 seconds]
enterprisey has joined #ocaml
malina has quit [Remote host closed the connection]
malina has joined #ocaml
<M-martinklepsch> If I define a record type A, is it possible to later define a record type B that has all the fields of A and some additional ones?
snhmib has joined #ocaml
<thizanne> M-martinklepsch: no
<thizanne> you can either do that with objects, or define a record type B that has a field of type A and some additional ones
<thizanne> (which one is better will depend on your exact use case)
<M-martinklepsch> ok, cool. probably the latter in my situation (it's just data)
argent_smith1 has quit [Ping timeout: 248 seconds]
malina has quit [Remote host closed the connection]
malina has joined #ocaml
malina has quit [Remote host closed the connection]
malina has joined #ocaml
enterprisey has quit [Ping timeout: 240 seconds]
argent_smith has joined #ocaml
<reynir> (also the type names have to start with a lower case letter :))
Siegfried has joined #ocaml
ayxih has quit [Quit: Leaving]
ayxih has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
kakadu has quit [Ping timeout: 248 seconds]
kakadu_ has joined #ocaml
cbot has joined #ocaml
malina has quit [Remote host closed the connection]
Siegfried has quit [Quit: Textual IRC Client: www.textualapp.com]
tane has quit [Quit: Leaving]
AltGr has left #ocaml [#ocaml]
fraggle_ has quit [Remote host closed the connection]
fraggle_ has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
sh0t has quit [Ping timeout: 268 seconds]
spew has quit [Quit: Connection closed for inactivity]
fraggle_ has joined #ocaml
sepp2k has quit [Quit: Leaving.]
lgd has joined #ocaml
lgd has quit [Client Quit]
jnavila has quit [Remote host closed the connection]
mk9 has quit [Quit: mk9]
sapristi_ has joined #ocaml
sapristi has quit [Ping timeout: 240 seconds]
pierpa has joined #ocaml
silver has quit [Read error: Connection reset by peer]
silver has joined #ocaml
malc_ has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.2]: i've been blurred!]
argent_smith has quit [Quit: Leaving.]
ziyourenxiang has joined #ocaml
kolko has quit [Quit: ZNC - http://znc.in]
raphaelss has quit [Ping timeout: 268 seconds]
hooman has joined #ocaml
spew has joined #ocaml