ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
arj has quit [Ping timeout: 264 seconds]
lordkryss has quit [Quit: Connection closed for inactivity]
arj has joined #ocaml
mcc has joined #ocaml
arj has quit [Ping timeout: 264 seconds]
badkins has joined #ocaml
Guuf has quit [Quit: Guuf]
madroach has quit [Ping timeout: 250 seconds]
madroach has joined #ocaml
zwer has joined #ocaml
zwer has quit [Client Quit]
zwer has joined #ocaml
NoNNaN has quit [Remote host closed the connection]
NoNNaN has joined #ocaml
BitPuffin has quit [Remote host closed the connection]
oscar_toro has quit [Ping timeout: 255 seconds]
arj has joined #ocaml
marcux has quit [Quit: marcux]
arj has quit [Ping timeout: 240 seconds]
<mcc> whitequark: i think i feel like the biggest limitation i'm hitting against modularizing / organizing my code is the requirement mutually recursive functions be colocated and "and"ed
<mrvn> or lifted
<whitequark> well, yes, open mutual recursion is the cornerstake of OO.
<mrvn> If they are mutualy recursive then maybe the do belong together.
<mcc> well, what i *want* is open mutual recursion without stack growth.
<mcc> which is something i can't think of an OO language that provides it.
<mcc> lua might. idk.
<vanila> isnt that tail recursion?
<mcc> Yes.
<vanila> I read that ocaml has that
<mcc> OO languages do a poor job of offering tail recursion.
<mrvn> Only place where that often realy doesn't apply is objects and they don't need the colocation.
<vanila> maybe thatS not true?
<vanila> I know that scheme does have this, though
<whitequark> I actually think open mutual recursion is the only thing objects in OCaml can do that nothing else can
<whitequark> structural typing is offered by polymorphic variants
<mcc> maybe i don't know what "open" means
<whitequark> er, row typing
<mcc> vanila: ocaml has tail recursion. however, typically if two functions call each other, they have to be declared together with "and"
<whitequark> mcc: the opposite of the requirement for being located lexically close
<vanila> oh yeah
<whitequark> extensible, in other words
<mcc> i see.
<mrvn> mcc: ocaml has zero stack grows for tail-recursion.
<mrvn> iirc
<vanila> I wonder if you could make a preprocessor that puts the 'ands' in for you?
<mrvn> vanila: no.
<mcc> mrvn: yes. i am saying this is a thing ocaml gives me, but standard OO languages do not.
<whitequark> mcc: what part of your design begets the need for open recursion?
<mcc> well, i'm not sure i need it.
<mrvn> vanila: let rec foo x y z = foo x y z let foo x = foo x 1 2. If you add "and" it breaks
<vanila> because they are both called foo?
marcux has joined #ocaml
<mcc> it's mostly a matter of, i have a set of modules / ml files which package together utility functions for different kinds of types.
<mrvn> vanila: yes. And because the "and" changes a non-recursive let to a recursive let
<mcc> however, i've written myself into a corner where if something has to execute emily code, it can only realistically do this inside of this one big and increasingly scary "execute_step" function in execute.ml.
<vanila> maybe you could generate fresh names for every function first
<whitequark> mcc: i find it that the desire to use OO to organize code is usually counterproductive. it allows you to stash stuff nicely, but in exchange it makes the code much more complex
<vanila> based on scoping rules
<whitequark> well, why would you not want the interpreter to be one function?
<mrvn> mcc: lift the recursion. Pass some lambdas, a record of callbacks or a first class module.
<mcc> so i'm not really, in this case, looking for something OO-y, i just am finding certain kinds of things would be more handy off in a contained module
<mcc> whitequark: there's something nice about it, but it's getting longer and longer.
<Drup> mcc: use high order functions and tie the knot at the end ?
<mrvn> mcc: also note: modules are not OO. Only objects are.
<whitequark> I would factor out the parts which are not essential to this function itself
<mcc> mrvn: i think whitequark was the one who originally mentioned OO, not me.
<mrvn> ok
rand000 has quit [Quit: leaving]
<mrvn> The nice thing about ocaml is that it gives modules, higher level functions and modules all in a nice package.
<mcc> i need to understand the first class module thing better
<whitequark> first class modules are almost certainly overkill for this case
<mcc> it does seem plausible if this gets much more complicated it's going to turn into something continuation-pass-y
<Drup> open recursion, functional style :)
<mrvn> mcc: basically it is just a fany way of passing a record of all the functions and variables in a module.
<whitequark> (so are records, though less so)
<whitequark> mrvn: and types.
<whitequark> without types, first class modules are just records (with subtyping)
<mcc> nevertheless, i need to understand them eventually.
<mcc> ok so here is a question
<Drup> I must say, I never used first class modules
<mrvn> mcc: You define an interface (module type) and then you can pass implementations of that interface into a function by passing the module.
arj has joined #ocaml
<mcc> MLI files let you define a module's interface without, at this time, providing an implementation. right?
<Drup> there is so few real use cases
<Drup> it's good because you can do it
<Drup> but really, most of the time, you shouldn't.
<mcc> how do you prevent MLIs from thus allowing mutual recursion across files?
<mrvn> mcc: yes, mli files only have the types for the interface, the ml file has the meat.
<whitequark> mcc: the dependency graph between ml/mli files must be a tree.
<mrvn> mcc: mli files can't be mutualy recursive, the compiler doesn't allow it
<whitequark> otherwise, the compiler will complain of not being able to resolve one of the edges of the cycle
<mcc> whitequark: i see.
<mrvn> whitequark: s/tree/directed graph without cycles/
<mcc> dag, yo
<whitequark> yeah
<mrvn> I've been fighting with resource allocation in C++ all day. God do I miss ocaml.
arj has quit [Ping timeout: 240 seconds]
darkf has joined #ocaml
arj has joined #ocaml
pyon has quit [Ping timeout: 272 seconds]
arj has quit [Ping timeout: 264 seconds]
marcux has quit [Quit: marcux]
shinnya has quit [Ping timeout: 240 seconds]
marcux has joined #ocaml
arj has joined #ocaml
nojb has joined #ocaml
nojb has quit [Client Quit]
arj has quit [Ping timeout: 272 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
seanmcl has joined #ocaml
marcux has quit [Quit: marcux]
arj has joined #ocaml
arj has quit [Ping timeout: 256 seconds]
tobleronegordon has quit [Ping timeout: 264 seconds]
jao has quit [Ping timeout: 256 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
arj has joined #ocaml
seanmcl has joined #ocaml
arj has quit [Ping timeout: 264 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
seanmcl has joined #ocaml
shinnya has joined #ocaml
arj has joined #ocaml
samrat has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
<struk> companion_cube: hey what do you think of adding a function to CCMultiset that is like this? https://gist.github.com/struktured/f2a77cddf92ed6eb9141 (or just changing add itself to have an optional arg) ?
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
seanmcl has joined #ocaml
arj has joined #ocaml
arj has quit [Ping timeout: 244 seconds]
ebzzry_ has joined #ocaml
ebzzry has quit [Read error: Connection reset by peer]
pierpa has quit [Ping timeout: 265 seconds]
pierpa` has quit [Ping timeout: 265 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
keen___________7 has quit [Read error: Connection reset by peer]
keen___________7 has joined #ocaml
badkins has quit []
q66 has quit [Quit: Leaving]
q66[lap] has quit [Read error: Connection reset by peer]
arj has joined #ocaml
q66[lap] has joined #ocaml
arj has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 264 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
samrat has joined #ocaml
waneck has quit [Read error: No route to host]
arj has joined #ocaml
pyon has joined #ocaml
arj has quit [Ping timeout: 250 seconds]
akuhlens has joined #ocaml
arj has joined #ocaml
ggole has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
arj has joined #ocaml
arj has quit [Ping timeout: 265 seconds]
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
Plazma has quit [Remote host closed the connection]
Plazma has joined #ocaml
arj has joined #ocaml
arj has quit [Ping timeout: 240 seconds]
q66[lap] has quit [Read error: Connection reset by peer]
ygrek has joined #ocaml
q66[lap] has joined #ocaml
arj has joined #ocaml
arj has quit [Ping timeout: 256 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
slash^ has joined #ocaml
samrat has joined #ocaml
AltGr has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
q66[lap] has quit [Read error: Connection reset by peer]
slash^ has joined #ocaml
q66[lap] has joined #ocaml
arj has joined #ocaml
arj has quit [Ping timeout: 244 seconds]
slash^ has quit [Read error: Connection reset by peer]
nojb has joined #ocaml
nojb has quit [Client Quit]
arj has joined #ocaml
arj has quit [Ping timeout: 272 seconds]
NoNNaN has quit [Ping timeout: 250 seconds]
MercurialAlchemi has joined #ocaml
NoNNaN has joined #ocaml
arj has joined #ocaml
nojb has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
arj has quit [Ping timeout: 272 seconds]
samuel02 has joined #ocaml
samuel02 has quit [Remote host closed the connection]
mcc has quit [Quit: This computer has gone to sleep]
nojb has quit [Quit: nojb]
akuhlens has quit [Quit: This computer has gone to sleep]
akuhlens has joined #ocaml
arj has joined #ocaml
akuhlens has quit [Quit: This computer has gone to sleep]
arj has quit [Ping timeout: 264 seconds]
Simn has joined #ocaml
arj has joined #ocaml
akuhlens has joined #ocaml
arj has quit [Ping timeout: 264 seconds]
<adrien> Drup: thanks :)
<adrien> Drup: as I said, I was already awarethat there is little change between the various .z announcement in OCaml and I'm happy with anything provided it works, continues working and is consistent enough
<adrien> btw, now that I've better understood that 913-char sentence from github's ToS, I can probably create that account :P
arj has joined #ocaml
<ggole> Oh goddammit. Fucked by my bad assumptions yet again. When will I learn?
shinnya has joined #ocaml
Guuf has joined #ocaml
<flux> mrvn, you'll miss ocaml once you want to release those resources ;)
arj has quit [Ping timeout: 272 seconds]
nojb has joined #ocaml
tane has joined #ocaml
akuhlens has quit [Quit: This computer has gone to sleep]
avsm has joined #ocaml
<flux> adrien, I'm not sure I would like to have such a function. it leads one to believe it's an O(1) function :-o
<adrien> haha :P
<flux> if it indeed is, then yes :)
avsm has quit [Quit: Leaving.]
Arsenik has joined #ocaml
arj has joined #ocaml
<companion_cube> gasche: oh, -custom seems interesting; does it mean one can link another libc?
<companion_cube> struk: oh, you are right, CCMultiSet should have add_mult and remove_mult
arj has quit [Ping timeout: 258 seconds]
<whitequark> companion_cube: what? no
<whitequark> -custom links a prebuilt libcamlrun
<whitequark> as to why, consider that like half of libc configuration is in the headers, and the ysmbols libcamlrun imports depend on those heavily
<whitequark> there's -use-runtime, but it's broken completely
ygrek has quit [Ping timeout: 258 seconds]
<whitequark> and -runtime-variant, but its usefulness is questionable for your use case
<companion_cube> and it's not possible to statically link the libc (glibc, then) to the binary?
<whitequark> you can't statically link glibc in general :]
<companion_cube> :(
<whitequark> however, if ocaml is built with a libc where it is possible, it's as easy as -cclib -custom
<whitequark> errrr
<whitequark> -cclib -static
<whitequark> you can just switch to 4.01.0+musl or even 4.01.0+musl+static
<whitequark> you will need to apt-get install musl-gcc beforehand
<adrien> or ask yourself more why you want to do that
<companion_cube> heh.
<companion_cube> right, linking with musl is mostly a curiosity to me, but statically linking glibc would truly be useful
<whitequark> you can't statically link glibc
<adrien> you can statically link it but
<whitequark> it uses nsswitch for resolving stuff and such
<whitequark> so gethostbyname and friends will not work
<whitequark> same for dlopen (cmxs)
<whitequark> why do you want to statically link glibc specifically?
<adrien> well, I can't find the exact sentence right now; you can but as whitequark has mentioned, there are serious limitations
<adrien> and again: why? :P
<companion_cube> because it's really annoying to ship binaries otherwise
<companion_cube> well, of course, I was able to ship binary+a bunch of .so + ld.so and play with LD_LIBRARY_PATH and watnot
<whitequark> glibc is forward+backward compatible though
arj has joined #ocaml
<whitequark> at worst case, you may need to build with an old version of glibc.
<adrien> gruik gruik
<adrien> companion_cube: whom are you shipping to?
<adrien> if a C toolchain is available, it's trivial (just do the link on the machine)
<whitequark> that's even worse, ugh
<adrien> it works and it's simple
<companion_cube> well it had an older glibc, otherwise it wouldn't be fnny
<whitequark> it's not simple and it requires a compiler
<companion_cube> it was on a cluster
<adrien> at some point the issue is not how you ship but how old the machines are
<companion_cube> of course the computers did not have an ocaml compiler
<adrien> C
<whitequark> so if you really want glibc and not musl, what you do is build glibc with --prefix=/opt/yourapp
<whitequark> and then ocaml with the same prefix
<whitequark> and bundle it up and ship.
<adrien> if they have a linker you can do it
<adrien> but another (cleaner) solution is indeed musl
<companion_cube> hmmm wait, it's possible to statically link with musl then, and ship the result on any other x86_64 computer?
<whitequark> sure
<companion_cube> then it's useful, I shall try it next time (this summer probably)
<whitequark> I just told you : opam switch 4.01.0+musl+static
<whitequark> upgrade it to 4.02 while you're at it
arj has quit [Ping timeout: 250 seconds]
vanila has quit [Remote host closed the connection]
pii4 has joined #ocaml
lordkryss has joined #ocaml
tane has quit [Quit: Verlassend]
oscar_toro has joined #ocaml
<Unhammer> utop[53]> Re.exec (Re.compile (Re.seq [Re.start; Re.any; Re.eos])) "a";;
<Unhammer> - : Re.substrings = <abstr>
<Unhammer> utop[54]> Re.exec (Re.compile (Re.seq [Re.start; Re.any; Re.eos])) "ø";;
<Unhammer> Exception: Not_found.
samrat has quit [Ping timeout: 240 seconds]
<Unhammer> yeah so no
<adrien> it's latin-1
<adrien> I have no idea if an utf-8 source will change it but in any case, latin1 is probably not what you should test with
arj has joined #ocaml
<Unhammer> anything typed into utop is treated as latin-1?
<Unhammer> emacs shows a U in the lower-left corner of *utop* :/
samrat has joined #ocaml
govg has quit [Quit: leaving]
thomasga has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
<companion_cube> maybe Re.any refers to a single char, and here you have several?
<Unhammer> I do have several
<Unhammer> or, several bytes
<Unhammer> I was just expecting a regex "." inthisdaynage to match codepoints, not bytes
tane has joined #ocaml
<nojb> Unhammer: strings in ocaml are just sequences of bytes
<nojb> if you need unicode you can use sedlex
<Unhammer> I know, but that doesn't mean a regex lib can't abstract over that
<adrien> Unhammer: the compiler treats its input as latin1; as long as your utf8 input is also a valid latin1 sequence, the compiler won't care
<Unhammer> sedlex doesn't let me do "blah(.)" -> match_group 1
<adrien> since strings as just sequences of bytes as nojb said
samrat has quit [Ping timeout: 256 seconds]
<adrien> the main thing is that since the compiler doesn't care, it can be anything and you won't know easily or get a warning
<adrien> (but again that doesn't mean Re necessarily handles what you need, only that you can't test the way you're doing now)
<Unhammer> let snowman = open_in "/tmp/f" |> IO.lines_of|>List.of_enum |> String.join "" ;;
<Unhammer> val snowman : string = u"\226\152\131"
samrat has joined #ocaml
<Unhammer> so choices are either sedlex, with extremely verbose syntax, no backreferences, but unicode; or re/pcre/Str where . matches bytes instead of code-points :(
<whitequark> 3) extend re to use unicode
<whitequark> it's not really as complex as it sounds
<adrien> errrr
<Unhammer> hm
<adrien> remember gnu grep's speed increase when it comes to unicode?
<whitequark> adrien: hm?
<whitequark> oh, whatever
<whitequark> correctness > speed, and code that doesn't use unicode is incorrect
<adrien> but something else actually
<Unhammer> "GNU grep is no longer slow on UTF-8" so that's nice
<Unhammer> maybe we can make re no longer slow on UTF-8 too
<whitequark> (doesn't support, rather)
<adrien> whitequark: oh, definitely but it's quite some work to get something not too slow
<Unhammer> instead of no longer slow and wrong
<whitequark> I'm not so sure about it
<whitequark> represent input as arrays ~ represent input as strings
<whitequark> and cset is already int-based essentially
<Unhammer> (hah great blog headline btw)
zwer has quit [Remote host closed the connection]
<adrien> actually there was something with grep much more recently than 2009/2010 but I can't find it anymore; maybe they took a long time to release a new version
<whitequark> something about NFA, I think
zwer has joined #ocaml
<whitequark> oh, grep already uses thompson nfa
<adrien> gnu grep is one of these tools which is definitely well-done
<Unhammer> http://awk.info/?doc/fastre.html
<adrien> yeah
<adrien> isn't that last link one of the bases for Re?
<adrien> (and awk is really nice when it comes to portability: the most basic versions are still more evolved than recent grep and sed that can be obtained on all ocaml-supported platforms)
arj has joined #ocaml
<Unhammer> heh I'm a heavy user of awk for text-mangling, though preferably the newer versions that have multi-dimensional arrays
arj has quit [Ping timeout: 255 seconds]
_5kg has quit [Ping timeout: 244 seconds]
ygrek has joined #ocaml
choeger_tu has joined #ocaml
Guest652 has joined #ocaml
choeger_tu has quit [Client Quit]
arj has joined #ocaml
thomasga has quit [Quit: Leaving.]
arj has quit [Ping timeout: 250 seconds]
kakadu has joined #ocaml
chambart has joined #ocaml
psy has quit [Remote host closed the connection]
psy has joined #ocaml
arj has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
arj has quit [Ping timeout: 240 seconds]
bgianf_ has quit [Ping timeout: 264 seconds]
lu324 has quit [Ping timeout: 272 seconds]
ygrek has joined #ocaml
choeger_tu has joined #ocaml
_5kg has joined #ocaml
bgianf has joined #ocaml
slash^ has joined #ocaml
samuel02 has joined #ocaml
<companion_cube> struk: next release of containers will contain CCMultiSet.{add_mult,remove_mult}
<companion_cube> you can also use the github issues for feature requests
seanmcl has joined #ocaml
Lasher` has quit [Read error: Connection reset by peer]
arj has joined #ocaml
rand000 has joined #ocaml
samrat has quit [Ping timeout: 256 seconds]
samuel02 has quit [Remote host closed the connection]
arj has quit [Ping timeout: 240 seconds]
ygrek_ has joined #ocaml
f[x] has joined #ocaml
ygrek_ has quit [Remote host closed the connection]
ygrek has quit [Remote host closed the connection]
arj has joined #ocaml
arj has quit [Ping timeout: 240 seconds]
nojb_ has joined #ocaml
nojb has quit [Ping timeout: 256 seconds]
nojb_ is now known as nojb
samrat has joined #ocaml
geekstay has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
slash^ has joined #ocaml
arj has joined #ocaml
f[x] has quit [Ping timeout: 245 seconds]
ygrek has joined #ocaml
chambart has quit [Ping timeout: 255 seconds]
geekstay has quit [Quit: Leaving]
arj has quit [Ping timeout: 245 seconds]
lu324 has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
AltGr has left #ocaml [#ocaml]
<Drup> Unhammer, whitequark : or extend sedlex with groupe captures, which would be really useful.
q66[lap] has joined #ocaml
q66 has joined #ocaml
ygrek has quit [Ping timeout: 255 seconds]
<gdsfh> gdspa
arj has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
seanmcl has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
<Drup> (11:27:59) adrien: Unhammer: the compiler treats its input as latin1; as long as your utf8 input is also a valid latin1 sequence, the compiler won't care <-- I know it used to be true, but are you sure it's still the case ?
q66[lap] has joined #ocaml
<adrien> I haven't checked recently
<nojb> it is deprecated since 4.01
<nojb> (warning 3)
<Drup> it's older than that, isn't it ?
<adrien> yup but does it treat it differently?
<Drup> that doesn't say anything about strings anyway
<Drup> it's for identifiers
q66[lap] has quit [Read error: Connection reset by peer]
<adrien> in any case it's much safer to test with the data read from a file
<nojb> strings are always understood to be sequences of bytes - the ocaml lexer is ocamllex and that is all it understands …
<adrien> argh, die svn, die!
q66[lap] has joined #ocaml
Thooms has joined #ocaml
<adrien> at least I could do "svn log ..." without a clone
arj has joined #ocaml
arj has quit [Ping timeout: 240 seconds]
Anarchos has joined #ocaml
enitiz has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
arj has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
t4nk568 has joined #ocaml
nojb has quit [Quit: nojb]
<t4nk568> Hello
hugomg has joined #ocaml
q66[lap] has quit [Read error: Connection reset by peer]
nojb has joined #ocaml
<adrien> hi
<t4nk568> Anyone here?
<t4nk568> hello
arj has quit [Ping timeout: 240 seconds]
<t4nk568> Wanted to ask a question, doesnt seem like anyone is here atm
<nojb> ask away
q66[lap] has joined #ocaml
<t4nk568> Oh ok :)
<t4nk568> Say you had a function like: let p x y = x y;;
<t4nk568> I get how then the signature is (a -> b) -> a -> b
<t4nk568> Is there any way of getting the signature to be ((a->b)->b) -> a -> b
<t4nk568> or even
<t4nk568> (((a -> b) -> b) -> b) -> a -> b
<t4nk568> does that make sense?
<nojb> no :)
<t4nk568> Its not possible?
<nojb> to get the sig ((a -> b) -> b) -> a -> b you would need to be able to produce a function a -> b from just an ‘a … clearly not possible in general
<t4nk568> I ask because ive been set a challenge to write a function in ocaml with that signature
<t4nk568> closest ive got is
<t4nk568> let p (x:(('a -> 'b) -> 'b) -> 'b) (y:'a) = y
<t4nk568> this has sig p : ((('a -> 'b) -> 'b) -> 'b) -> 'a -> 'a
<t4nk568> The last a needs to be a b. I understand why its a, just have no clue how to get it to return b
<ggole> You could cheat: let f : (('a -> 'b) -> 'b) -> 'a -> 'b = fun _ _ -> assert false;;
<hugomg> to clarify what nojb said, ((a -> b) -> b) is the "continuation-passing-style" of "a". So you are kind of asking to write "a -> a -> b"
<hugomg> another way to cheat would be to make an infinite loop
<t4nk568> Not allowed to use that, or failwith :( My friend managed it using let rec f1 x = f1 x
<t4nk568> But again, this is looping infinitely
<ggole> exit 0!
<ggole> They may have overlooked that one.
<t4nk568> hmmm
<ggole> The real answer is "you can't do that".
<t4nk568> Apparently its not a tick question and its possible.
<hugomg> maybe the problem statement is messed up
<ggole> You can only make a function that doesn't return (by looping, exiting, raising, etc)
<t4nk568> Is there proof as to why you cant? :P
<t4nk568> ah
<t4nk568> intresting
<t4nk568> Unless
<nojb> it follows from curry howard correspondance
<t4nk568> You cant do type 'a = ... can you?
<hugomg> maybe if the (a -> ((b -> c) -> c)) -> a -> b then it would be possible
<t4nk568> actually define a new type called 'a and 'b
<hugomg> what nojb is trying to say is that what you are tying to do is similar to trying to write f : 'a -> 'b
<hugomg> you can't write this kind of "unsafe corce" function - they only way to get it to type is to make it an infinite loop
<t4nk568> Or use Obj.magic
<hugomg> (because infinite loops correspond to "absurd" in logic)
<t4nk568> Which, again, im not allowed xD
<hugomg> I'm assuming you cant cheat :P
<Anarchos> Obj.magic is not legal ??
<hugomg> (and absurd implies anything)
<companion_cube> no it's not legal
<hugomg> its not legal if you are talking about curry-howard correspondence. No such thing as Obj.magic in math-land
<t4nk568> So, if im correct here, there is nothing of type a -> b in math-land
<companion_cube> it's not legal either if you want working, robust code
<nojb> t4nk568: correct
<ggole> Unless logic is inconsistent.
<ggole> Which would be... a bit strange.
* ggole casts cube to the type of person that thinks Obj.magic is OK
<companion_cube> no
<Anarchos> ggole i still wonder why Obj;magic is present in official ocaml...
<companion_cube> probably because ocamllex uses it
<ggole> The Obj stuff is used "internally".
<Anarchos> companion_cube i didn't know.
<nojb> it is used in a couple of parts in the stdlib
<nojb> (Queue is another)
<mrvn> t4nk568: you can do this if you enable rectypes. Otherwise you need to wrape the thing in a constructor. Wether you can then populate the type is another question.
<ggole> But the Queue Obj.magic will die now that we have constructor records.
<hugomg> its useful to have that kind of "escape valve" for when you really need to fight against the language. I kind of like the Haskell approach of giving scary names, like unsafePerformIO, to all these functions though :)
<t4nk568> Question, the List.map function contains in its sig: (a->b)
<flux> ggole, how will it make them die? isn't that just syntax candy?
<ggole> No, it allows constructor arguments to be mutable.
<mrvn> hugomg: ocaml has unsafe* too
<ggole> (Without Obj hacks.)
<hugomg> Obj.magic is a much less scary name than unsafeCoerce :P
<flux> ggole, hm? ref is too much of performance degradation to people?
<adrien> repeat after XL: Obj isn't prt of the language ;-)
<adrien> part*
<ggole> Apparently.
<mrvn> flux: you already have 20 indirections. One more will certainly kill you. :)
<nojb> Hashtbl, Lazy, Parsing, Printexc, Queue, Stream, Weak all use Obj.magic somewhere
<hugomg> flux: IIRC, you can use Obj.magic to make list.map not stack overflow by making the cons cell mutable internally
<ggole> There's a comment in queue.ml complaining about the cost.
<mrvn> hugomg: you can also do that without Obj.magic
<ggole> Not without redefining the list type
<hugomg> yeah but dont you need to create an intermediate reversed list for that?
<ggole> Oh, you mean by not using tail consing. Right.
<mrvn> ggole: sure you can. you use List.rev
arj has joined #ocaml
<ggole> It'd be nice if we had TRMC.
<companion_cube> Hashtbl uses Obj? :s
<mrvn> what for?
<flux> I suppose it uses arrays that have 'blank' entries
<flux> it could use option, I suppose, but..
<ggole> It has (had?) an internal alist type
<ggole> You just fill the array with empty alists
<mrvn> doesn't it have an array of lists?
<t4nk568> Im still learning OCaml :P Can someone explain why List.map allows lists of ('a -> 'b) if that sig isnt allowed in logic? :)
<nojb> it is used to keep campatibility with an old version of Hashtbl
<companion_cube> binary compatibility of Hashtbl is... weird
<mrvn> t4nk568: why wouldn't it be allowed?
<flux> t4nk568, consider this function: let apply f x = f x
<t4nk568> ('a -> 'b) -> 'a -> 'b
<t4nk568> oh
<t4nk568> so what you are saying is
<ggole> t4nk568: ('a -> 'b) can be used at any 'a and 'b, which is fine
<t4nk568> functions with JUST their signature as ('a -> 'b) arnt allowed?
<mrvn> t4nk568: they are allowed
<ggole> You can use int -> float, string -> int option, etc
<flux> t4nk568, it's not that they aren't allowed, but that you cannot implement them
<flux> t4nk568, you need to have 'a around to implement it
<t4nk568> without cheating
<mrvn> # Obj.magic;;
<mrvn> - : 'a -> 'b = <fun>
<hugomg> (or, you can implement them, but only w/ infinit loops)
<t4nk568> ok so
<flux> consider this: you have signature (string -> int)
<t4nk568> yeah
<flux> but you don't have access to anything in the String module
<flux> actually that's a bad example, you can just return 0 ;-)
arj has quit [Ping timeout: 255 seconds]
<flux> but you cannot really 'look into' a 'a of a function, and you cannot create a 'b out of thin air
<t4nk568> so ('a -> 'b) -> 'a -> 'b is possible
bytbox has joined #ocaml
<mrvn> except with the eivl[tm] Obj.magic
<mrvn> so DON't.
<ggole> t4nk568: sure, that's just application
<nojb> t4nk568: yes, is called modus ponens
<t4nk568> Btw thanks to all of you, I appreciate your time
<t4nk568> so if ('a -> 'b) -> 'a -> 'b is possible, what about (('a -> 'b) -> b) -> 'a -> 'b
<mrvn> t4nk568: 'a -> 'b says the function will take any 'a and return any 'b. It will just magically produce the right types (like Obj.magic).
<hugomg> The "(a -> b) -> b" is kind of similar to "a", but written in "continuation-passing-style"
<mrvn> t4nk568: ('a -> 'b) -> 'a -> 'b says: For some 'a and 'b given a function ('a -> 'b) and a 'a it will return a 'b.
<hugomg> Think about it, its something that gives out a "b" if you pass it an "a->b" so it must have a way to produce"a" by itself
<hugomg> so in the end, what you are asking is similar to "a -> a -> b"
akuhlens has joined #ocaml
<t4nk568> hmm yeah I see
<nojb> you are asking wether the knowledge of a is enough to conclude b if you are given that you know that b follows from knowlege of (a implies b) … clearly not enough
<t4nk568> So could we potentially disprove a signature using logic
<nojb> and viceversa
<t4nk568> thats cool :D
<hugomg> Phil Wadler recently wrote a really good introduction to curry howard let me see if I can find it
<t4nk568> So if I could disprove the sig that has been given to me using logic (Truth tables or something) then I have proved that you CANT impliment an ocaml function without 'cheating'?
<nojb> yes
seanmcl has quit [Quit: Textual IRC Client: www.textualapp.com]
bytbox has quit [Ping timeout: 255 seconds]
<t4nk568> Alright, so, whats the easiest way of disproving this? :P
<t4nk568> Truth tables?
<t4nk568> Thanks! Ill give it a read
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<hugomg> not truth tables, this is intuitionistic logic so you aren't allowed to use excluded-middle (p or not p)
<t4nk568> Im an undergrad btw :P, Only really covered truth tables and natural deduction
<mrvn> % ocaml -rectypes
<mrvn> # let f g = g g;;
<mrvn> val f : ('a -> 'b as 'a) -> 'b = <fun>
<mrvn> t4nk568: There is your type implemented
<mrvn> Prooving a positive is so much simpler
<t4nk568> xD
arj has joined #ocaml
<hugomg> mrvn: You don't really need rectypes to write an infinite loop though
<mrvn> hugomg: without it you need a constructor around it.
<hugomg> let f x = f x has type "a -> b"
<hugomg> no need for recursive data types :)
<t4nk568> yeah
<t4nk568> Is that a valid function
<t4nk568> e.g. allowed in logic
<hugomg> Depends on the logic
<hugomg> On ocaml we allow arbritrary recursion, which lets you write programs that loop infinitely
<mrvn> hugomg: your function is different and a loop. mine isn't.
<t4nk568> doesnt let f x = f x have to be let rec f x = f x
<mrvn> without rectypes you can do: type ('a, 'b) cont = Cont of ('a, 'b) cont * 'b
<t4nk568> In which case you have a loop
<hugomg> yes, I always forget the let rec...
slash^ has quit [Ping timeout: 272 seconds]
arj has quit [Ping timeout: 240 seconds]
<t4nk568> No problem
<t4nk568> May I link a picture?
akuhlens has quit [Quit: This computer has gone to sleep]
<hugomg> dont ask to ask, just ask
<t4nk568> So here is an example of the sig I want
<t4nk568> But the first line is the infinate loop
<t4nk568> which isnt allowed in logic
<t4nk568> therefore we can get to impossible results?
<t4nk568> Is this correct?
<hugomg> IIRC you can prove that if you have an "impossible" signature like that than it must be an infinite loop or "assert false" (barring evil magic)
<t4nk568> This reminds me of the 1 = 2 proof
<mrvn> t4nk568: why wouldn't an infinite loop not be allowed?
<hugomg> Fundamentally, the problem is that once you allow arbritrary recursion its possible to write programs that loop forever
<hugomg> which confuse things a bit
<hugomg> you can kind of say that when "f" returns it returns a "b". It just happens that it takes a long time for it to return :)
<hugomg> if you forbid recursion or recursive types then this doesn't happen
<t4nk568> I am allowed to use recursion, just not infinite
<mrvn> t4nk568: then you face the halting problem. It is undecidable.
<hugomg> thing is, the type system can't tell apart infinite recursion from recursion that terminates. The halting problem in undecidable :)
<t4nk568> Knowing this then, its impossible whithout using recursion/obj.magic/failwith...
<mrvn> t4nk568: if you build your logic that every expression halts then you can't express usefull stuff
<t4nk568> Its weird as my prof set this, not as homework but as a challenge... and I love a challenge ;D
<t4nk568> He said its possible without using any "tricks"
<hugomg> I think your prof is either trolling the class or the problem statement has a typo :)
<mrvn> t4nk568: let rec loop x = if x = 1 then () else if x mod 2 == 0 then loop (x / 2) else loop (x * 3 + 1)
<t4nk568> When he releases the answer, im gonna facepalm so hard
<mrvn> t4nk568: does that halt for every x?
<t4nk568> hmmm
<hugomg> I'm afraid you might have nerd-sniped him mrvn
<t4nk568> Wont it keep going up?
<hugomg> nope, it goes down (by ahlf) if its even
<hugomg> for example
<t4nk568> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
slash^ has joined #ocaml
<hugomg> 5 -> 16 -> 8 -> 4 -> 2 -> 1 end
<t4nk568> never mind :D
<t4nk568> So yeah, I do believe it IS possible for all x values
<mrvn> t4nk568: 8 4 2 1, 5 16 8 4 2 1, 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
<mrvn> t4nk568: Now do 27
<t4nk568> lord
<t4nk568> ok
<t4nk568> wait
<mrvn> t4nk568: it might be possible. But can you proof it?
<t4nk568> i wouldnt know how to proove it
<mrvn> "The sequence for n = 27, listed and graphed below, takes 111 steps, climbing to 9232 before descending to 1."
<t4nk568> proofs suck :P
bytbox has joined #ocaml
<t4nk568> Ah so it does come down to 1 eventualy
<mrvn> t4nk568: your logic would need a way to proof this. Note: there is no proof for this known.
dsheets has joined #ocaml
<hugomg> my favourite legend about this problem is that it was created by the soviets to keep the western mathematicians busy looking for a proof of it
q66[lap] has quit [Read error: Connection reset by peer]
<t4nk568> Right :P
<t4nk568> Thats quite fun to think about
<t4nk568> Im gonna speak to another prof in CS who im better friends with then my ocaml prof. See what he thinks. But yeah, thanks for all the help!
<t4nk568> Im pretty sure hes trolling now. I bet the right answer is that there IS NO answer
arj has joined #ocaml
<t4nk568> But if he does somehow have a solution
pakchoi2 has joined #ocaml
<t4nk568> then ill be sure to let you guys know
pakchoi2 has quit [Max SendQ exceeded]
<t4nk568> Cya later! :)
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
<hugomg> I have a question myself now: is it possible to have the -rectypes flag work with functors? http://lpaste.net/114857
<hugomg> I'm getting a compiler error w/ the recursive type inside the Fix functor
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
t4nk568 has quit [Quit: Page closed]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
q66[lap] has joined #ocaml
arj has quit [Ping timeout: 245 seconds]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
<ggole> hugomg: recursive types aren't allowed in general
pakchoi2 has joined #ocaml
<ggole> Try type 'a t type x = x t
pakchoi2 has quit [Max SendQ exceeded]
<ggole> Which is pretty much your functor example with the modules taken out.
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
pakchoi2 has quit [Max SendQ exceeded]
<ggole> You need a concrete type definition that meets some rules (recursion goes through a record/object field or constructor arg, I think)
pakchoi2 has joined #ocaml
<hugomg> ggole: is that what the "type nn" is already doing?
pakchoi2 has quit [Max SendQ exceeded]
pakchoi2 has joined #ocaml
<ggole> type nn is OK because it goes though a constructor arg
pakchoi2 has quit [Max SendQ exceeded]
<ggole> That's my understanding, anyway
<hugomg> the idea is that the Fix functor would implement some fucntions in addition to defining the type but I took that out to keep it simple
pakchoi2 has joined #ocaml
pakchoi2 has quit [Remote host closed the connection]
darkf has quit [Quit: Leaving]
yomimono has joined #ocaml
girrig has quit [Ping timeout: 240 seconds]
girrig has joined #ocaml
akuhlens has joined #ocaml
arj has joined #ocaml
<Drup> hugomg: the issue is that 'a t could be implemented as "type 'a t = 'a"
<Drup> in this case, you have the non-sensical "type t = t"
<hugomg> yes, I think the abstract type in M's signature is whats getting in the way.
<Drup> yep
<hugomg> anyway, if I have a "type 'a ff = ..." and a recursive type "type t = t ff"
akuhlens has quit [Quit: This computer has gone to sleep]
fraggle_ has quit [Ping timeout: 272 seconds]
<hugomg> is there a way to create a functor to implement some functions on the "t" type?
arj has quit [Ping timeout: 264 seconds]
<hugomg> I was (out of curiosity) trying to implement some recursion schemes
<hugomg> let rec fold f x = f (map (fold f) x)
<hugomg> but I'm suspecting that the only way is without rectypes:
<Drup> I think it would be ok if the type t is part of the input signature instead
<hugomg> let rec fold f (Fix x) = Fix (f (map (fold f) x)
<Drup> this way, you don't have to define the type t, you let the user in charge of it, and since from his point of view, the type ff is not abstract, the compiler can check the recursive type is allowed
<hugomg> I don't know how to write the type signature for fold without using t though
<hugomg> val fold : ('r M.ff -> 'r) -> M.t -> 'r
<Drup> you can use t just fine, it's just that you don't define it inside the functor, you take it as input.
<hugomg> but if I take both t and ff as input, then how do I implement fold? It depends on the fact that "t = t ff"
<hugomg> and if t is abstract on the Mappable signature then it doesnt know that
<Drup> it doesn't have to be abstract in the signature
<Drup> let me check if it actually work.
<Drup> hum
<Drup> no it doesn't :/
kakadu has quit [Read error: Connection reset by peer]
arj has joined #ocaml
kakadu has joined #ocaml
olasd has left #ocaml ["WeeChat 1.0.1"]
<hugomg> yes, I suspect that there is no way to do this using -rectypes
<hugomg> I also tried putting the type t = t ff in the signature :)
<Drup> using rectypes is not the greatest idea anyway
<Drup> it creates types that are bogus and it's "infectious"
<hugomg> yeah, I know rectypes are dark magic
BitPuffin has joined #ocaml
arj has quit [Ping timeout: 240 seconds]
<hugomg> but I had to try to see if I could get it to work anyway :D
<Drup> The appeal of the dark side is strong :]
nojb has quit [Quit: nojb]
akuhlens has joined #ocaml
samrat has quit [Ping timeout: 250 seconds]
samrat has joined #ocaml
nojb has joined #ocaml
<struk> companion_cube: thanks for the add|remove_mult updates
badon has quit [Ping timeout: 250 seconds]
arj has joined #ocaml
arj has quit [Ping timeout: 244 seconds]
bytbox has quit [Ping timeout: 245 seconds]
nojb has quit [Quit: nojb]
akuhlens has quit [Quit: This computer has gone to sleep]
badon has joined #ocaml
akuhlens has joined #ocaml
<Unhammer> is there a function in eliom/tyxml that turns Simplexmlparser.xml into a Html5.elt?
<Unhammer> Alternatively, is there a way to embed "raw html" in an otherwise type-checked Eliom_content.Html5 tree?
<Drup> 1) No.
<Drup> 2) No, but you can cheat, using Unsafe.node
struk has quit [Ping timeout: 258 seconds]
<Drup> It's basically impossible to do it dynamically in a type safe manner so there isn't going to be a prettier way.
akuhlens has quit [Quit: This computer has gone to sleep]
nojb has joined #ocaml
michipili has joined #ocaml
arj has joined #ocaml
<Unhammer> so pretend I'm a node of a type that's allowed here?
<Drup> just give the right type
<Drup> (or just don't care and use it directly)
nojb has quit [Ping timeout: 264 seconds]
arj has quit [Ping timeout: 245 seconds]
<Unhammer> btw, sorry for all these questions, but should it be possible to use eliom-stuff in utop? I just get stuff like
<Unhammer> utop[112]> #require "eliom.server";;
<Unhammer> utop[113]> Eliom_content.Html5.F.Unsafe.node "span" [];;
<Unhammer> Error: Reference to undefined global `Ocsipersist'
<Unhammer> Error: Reference to undefined global `Eliom_content'
<Unhammer> (that, or utop crashes)
struk has joined #ocaml
<Drup> no, eliom stuff will not work in utop, it's normal
<Drup> you need ocsigenserver running :)
slash^ has quit [Read error: Connection reset by peer]
yomimono has quit [Ping timeout: 272 seconds]
arj has joined #ocaml
arj has quit [Ping timeout: 245 seconds]
Anarchos has joined #ocaml
thomasga has joined #ocaml
struk has quit [Ping timeout: 272 seconds]
arj has joined #ocaml
yomimono has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
BitPuffin has quit [Ping timeout: 272 seconds]
kakadu has quit [Quit: Konversation terminated!]
thomasga has quit [Quit: Leaving.]
akuhlens has joined #ocaml
arj has joined #ocaml
<Unhammer> guess I can't hook up a repl to ocsigenserver though heh
BitPuffin has joined #ocaml
arj has quit [Ping timeout: 265 seconds]
govg has joined #ocaml
oscar_toro has quit [Ping timeout: 272 seconds]
<Drup> that is probably going to be delicate.
samrat has quit [Ping timeout: 255 seconds]
<Drup> It would be an interesting projet
<Drup> but I doubt it will be that straightforward :p
samrat has joined #ocaml
fraggle_ has joined #ocaml
<Unhammer> mm
ousado has quit [Remote host closed the connection]
ousado has joined #ocaml
ousado has quit [Changing host]
ousado has joined #ocaml
leifw has quit [Ping timeout: 245 seconds]
leifw has joined #ocaml
<hugomg> I think I'm going mad. For some reason, merlin/syntastic stopped giving any warnings about compilation errors in one of my files. For other files everything works fine
<hugomg> I fear I might have found some sort of bug but I have no idea how to narrow it down :/
arj has joined #ocaml
AlexRussia has quit [Ping timeout: 245 seconds]
<hugomg> ooh, looks like it bugs out if there is an unmatched quote in a comment. Weird!
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
<ggole> Comments are parsed :|
arj has quit [Ping timeout: 264 seconds]
<hugomg> I know ocaml allows for nested comments but why would it make a difference if there is a lone '"' there?
<adrien> I never remember the reason :D
<companion_cube> ocaml parses comments to be sure that ocamldoc can do its work, I think
<adrien> at the very least there's ocamldoc support
<companion_cube> or it might be so that if you uncomment, the lexer is still happy
<ggole> Speaking of parsing woes, merlin is giving me a bit of trouble
oscar_toro has joined #ocaml
<ggole> I've managed to mostly beat it into submission, but it insists that the type in let f x : foo_ is not a type *unless* it is a valid bound type name, at which point it will recognise it as a type.
<ggole> Which breaks context-aware completion very neatly.
arj has joined #ocaml
inr has quit [Quit: leaving]
inr has joined #ocaml
arj has quit [Ping timeout: 258 seconds]
choeger_tu has quit [Quit: choeger_tu]
nze has joined #ocaml
AlexRussia has joined #ocaml
arj has joined #ocaml
arj has quit [Ping timeout: 244 seconds]
dsheets has quit [Ping timeout: 255 seconds]
badon has quit [Quit: Leaving]
akuhlens has quit [Quit: This computer has gone to sleep]
pierpa has joined #ocaml
arj has joined #ocaml
akuhlens has joined #ocaml
arj has quit [Ping timeout: 250 seconds]
ggole has quit []
Guest652 has quit [Ping timeout: 265 seconds]
nze has quit [Ping timeout: 255 seconds]
jao has quit [Ping timeout: 255 seconds]
michipili1 has joined #ocaml
arj has joined #ocaml
michipili has quit [Ping timeout: 240 seconds]
arj has quit [Ping timeout: 255 seconds]
nojb has joined #ocaml
manud_ has joined #ocaml
Guest652 has joined #ocaml
hugomg has quit [Ping timeout: 264 seconds]
mort___ has joined #ocaml
arj has joined #ocaml
pierpa` has joined #ocaml
arj has quit [Ping timeout: 272 seconds]
arj has joined #ocaml
akuhlens has quit [Quit: This computer has gone to sleep]
arj has quit [Ping timeout: 258 seconds]
Thooms has quit [Quit: WeeChat 1.0.1]
Thooms has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
arj has joined #ocaml
michipili1 has left #ocaml [#ocaml]
arj has quit [Ping timeout: 264 seconds]
ollehar has joined #ocaml
Guuf has quit [Read error: No route to host]
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
malc_ has joined #ocaml
tane has quit [Quit: Verlassend]
mort___ has quit [Ping timeout: 265 seconds]
arj has joined #ocaml
mort___ has joined #ocaml
arj has quit [Ping timeout: 272 seconds]
arj has joined #ocaml
akuhlens has joined #ocaml
nojb has quit [Quit: nojb]
arj has quit [Ping timeout: 264 seconds]
MercurialAlchemi has quit [Ping timeout: 264 seconds]
yomimono has quit [Ping timeout: 272 seconds]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
nojb has joined #ocaml
chambart has joined #ocaml
zwer_f has joined #ocaml
zwer has quit [Ping timeout: 250 seconds]
arj has joined #ocaml
akuhlens has quit [Quit: This computer has gone to sleep]
troydm has quit [Ping timeout: 250 seconds]
nojb has quit [Quit: nojb]
arj has quit [Ping timeout: 258 seconds]
nojb has joined #ocaml
teiresias has quit [Ping timeout: 240 seconds]
teiresias has joined #ocaml
brendan has quit [Remote host closed the connection]
arj has joined #ocaml
mcclurmc has joined #ocaml
arj has quit [Ping timeout: 255 seconds]
thetabyte has joined #ocaml
<thetabyte> i'm having trouble understanding how a particular snippet of code that uses ocaml refs to make a counter works http://pastebin.com/thYXSDgV shouldn't a new ref pointing to 0 be created every time next_reg is called?
<Drup> hum, the env argument is useless.
chambart has quit [Ping timeout: 255 seconds]
<thetabyte> oh, sorry, i was mid-modification, that isn't implemented yet :/
<thetabyte> should have left that argument out
<Drup> I think removing the argument makes it easier to understand :)
<thetabyte> i just can't understand how this produces a new number every time i call next_reg (), assuming the env argument isn't there
mort___ has quit [Quit: Leaving.]
<thetabyte> (updated pastebin http://pastebin.com/SCia5G4P)
<Drup> let n = 3 in let add_n x = x + n
<Drup> do you understand how this one works ?
<thetabyte> hmm, if it's let n = 3 in fun x -> x + n then yes
<thetabyte> not sure about the '=' or the 'add_n' identifier? i couldn't get that to work in a REPL.
<Drup> yeah, there is "..." at the end :p
<Drup> let n = 3 ;; let add_n x = x + n ;;
<Drup> for the repl
<thetabyte> ah okay! sorry just wanted to make sure i actually understood ;-;
<thetabyte> yup. though if it was let n = ref 0 ;; fun () -> (let temp = !n in n:=!n+1; temp) ;; then it would make sense, because the let n = ref 0 is only run once.
<thetabyte> but in the linked example, isn't let n = ref 0 executed every time you call next_reg, initializing a new ref to 0?
<Drup> in your pastebin, it's also run only once.
<Drup> let's consider "let n = let x =ref 0 in let r = execute_complicated_function x in r+1
<Drup> do you think x and the complicated function are executed everytime I access n ?
<thetabyte> yes, i do :/ is that optimized out if it isn't dependent on an argument to the toplevel function?
<Drup> ok, simpler example
<thetabyte> (i assumed it must be executed every time b/c it would be executed every time in this case: let n arg = let x =ref 0 in let r = execute_complicated_function arg x in r+1)
<Drup> well, in this case, you added an argument !
<Drup> of course, the execution of the body of a function is delayed until you get the argument.
<thetabyte> that's what i'm asking, i suppose. how does the behavior change with respect to arguments? i had no idea the behavior *did* change.
<Drup> however, if you do "let n = 3+2;;"
<Drup> do you really think 3+2 is recomputed everytime I ask for n ? :p
<thetabyte> that's a good point.
<thetabyte> so, what happens for "let n arg = arg; 3+2;;"
<thetabyte> does it recalculate 3+2 every time?
<Drup> yes, since it's inside the body of a function.
struk has joined #ocaml
<thetabyte> hmm. okay, this is starting to make sense. thank you.
arj has joined #ocaml
<thetabyte> (essentially, i wanted to add an argument to next_reg that made sure the value wasn't in a particular list i passed in, and if it was, add again. i'm now realizing i'll need a separate no-argument counter, then a function that takes that list as an argument and manipulates the no-argument counter based on the contents of the list argument)
badkins has joined #ocaml
ski has quit [Ping timeout: 256 seconds]
<Drup> indeed, the counter must be outside the body of the function.
<thetabyte> excellent
arj has quit [Ping timeout: 255 seconds]
Thooms has quit [Quit: WeeChat 1.0.1]
q66[lap] has quit [Read error: Connection reset by peer]
q66[lap] has joined #ocaml
akuhlens has joined #ocaml
ollehar has quit [Remote host closed the connection]
NoNNaN has quit [Remote host closed the connection]
NoNNaN has joined #ocaml
badkins has quit [Remote host closed the connection]
akuhlens has quit [Quit: This computer has gone to sleep]
arj has joined #ocaml
mcclurmc_ has joined #ocaml
mcclurmc has quit [Ping timeout: 244 seconds]
arj has quit [Ping timeout: 264 seconds]
mcclurmc has joined #ocaml
mcclurmc_ has quit [Ping timeout: 244 seconds]
arj has joined #ocaml
ski has joined #ocaml
arj has quit [Ping timeout: 264 seconds]
<thetabyte> ugh, what i wouldn't give for a infix for array concatenation
rand000 has quit [Quit: leaving]