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
Jesin has quit [Quit: Leaving]
smazga has joined #ocaml
inkbottle has joined #ocaml
zebrag has quit [Ping timeout: 260 seconds]
Jesin has joined #ocaml
Haudegen has quit [Ping timeout: 260 seconds]
olle has quit [Ping timeout: 246 seconds]
olle has joined #ocaml
wingsorc has quit [Quit: Leaving]
notnotdan has quit [Ping timeout: 260 seconds]
vicfred has quit [Quit: Leaving]
notnotdan has joined #ocaml
jao has quit [Ping timeout: 256 seconds]
notnotdan has quit [Ping timeout: 272 seconds]
notnotdan has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
mfp has quit [Ping timeout: 240 seconds]
smazga has quit [Ping timeout: 260 seconds]
ArthurSt1ong has quit [Quit: leaving]
narimiran has joined #ocaml
ArthurStrong has joined #ocaml
dborisog has joined #ocaml
theblatte has quit [Ping timeout: 256 seconds]
theblatte has joined #ocaml
mbuf has joined #ocaml
dborisog_ has joined #ocaml
dborisog has quit [Read error: Connection reset by peer]
mbuf has quit [Ping timeout: 258 seconds]
mbuf has joined #ocaml
inkbottle has quit [Quit: Konversation terminated!]
inkbottle has joined #ocaml
chripell has joined #ocaml
smazga has joined #ocaml
smazga has quit [Ping timeout: 246 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartholin has quit [Quit: Leaving]
Haudegen has joined #ocaml
ollehar_ has joined #ocaml
olle_ has joined #ocaml
tinga has quit [Remote host closed the connection]
tinga has joined #ocaml
smazga has joined #ocaml
mfp has joined #ocaml
smazga has quit [Ping timeout: 256 seconds]
Anarchos has joined #ocaml
ArthurStrong has quit [Ping timeout: 272 seconds]
Jesin has quit [Quit: Leaving]
Jesin has joined #ocaml
Anukriti has joined #ocaml
<Anukriti> Can anyone tell how to pass an integer pointer to a function in OCaml? I was trying to reduce a mutable state ref variable
<Anarchos> why is relevant the order of declaration in signatures if they are not dependant ?
<Anarchos> Anukriti custom block ?
<def> hmm, there are no such things as pointers in OCaml (if we consider pointer arithmetic a "defining property" of pointers).
<def> you can get reference semantics using references (yay), and more generally mutable fields.
<Anukriti> No, I am new to OCaml. So, was testing if pass by reference exists?
<def> Anarchos: knowing the precise position of a declaration helps generating having an efficient data representation and efficient code
<def> Just use a ref.
<def> That's the proper way to do that.
<Anarchos> def ok
<def> But maybe it is a case of XY problem. Can you show what you are trying to solve?
<octachron> Anarchos, the order is only relevant in term of memory layout if the items are not dependant? Are you indirectly talking about the illegal permutation error?
<Anukriti> But ref is in mutable state. So, can I simply pass it as a parameter in some function?
<Anarchos> not trying to solve a problem, i was just wondering why the compiler complains about order in a signature different of another
<def> Anukriti: yes. But it seems like you are trying to solve a problem in a very procedural/imperative way. If you can be more specific about what you are trying to solve, we might be able to find a cleaner solution.
<Anukriti> So, I am currently working on simplify_exits function in simplif.ml file
<Anukriti> So, there I found an int ref try_depth. It is in mutable state and I want to remove it
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<Anukriti> So, there's a count function in which I was thinking to pass a parameter which will help me to increment try_depth which is needed
<def> Anarchos: signatures are not equal modulo permutation. If you are exporting module types, you need to have equal definitions. Modulo coercions however will automatically generate the right permutation code (so it compiles but translates to runtime operation)
<def> Module coercions*
<octachron> The general idea behind getting rid of mutable states is to make them more explicit by passing them as immutable function parameters rather than refs
<Anukriti> Currently I have used a parameter in count method but how will I replace this incr try_depth using this count method. So, I was thinking if instead passing by value, if I could pass some int pointer, that will help me update try_depth normally
<def> yes. In that case you probably want to express the traversal as a fold that threads the try_depth value rather than an iter that updates a reference.
<Anukriti> octachron yes right, trying that only
<Anukriti> Yes
<def> Forget about pointers, that would lead to the same code (except that you pass the argument manually rather than getting it from the environment).
<Anukriti> So, instead of using parameters, what else I can think of? Can you please suggest
<def> Using parameters, but no ref, no pointer.
<Anukriti> yes, that I have already done
<Anukriti> but there is some type differences that I am encountering currently. Will check, thanks a lot!
<def> let rec count try_depth = function ... | Lstatic_raise (i, ls) -> incr_exit i 1 try_depth; List.iter (count try_depth) ls | _ -> ...
<Anukriti> yes, i have done this only
<Anukriti> Will check, there might be some small error
<def> of course, this works only if the try_depth variable can actually be managed like a pure value, if there are visible side-effects, you will need more refactoring.
<Anukriti> thanks a lot, will do some more refactoring.
zolk3ri has joined #ocaml
ggole has joined #ocaml
Anukriti has quit [Remote host closed the connection]
<Leonidas> https://ocaml.janestreet.com/ocaml-core/v0.14/doc/base/Base/Nothing/index.html haha, that module sounded so intriguing, I had to look up what it does
<Leonidas> in a shocking twist this module actually has documentation
<d_bot> <Anurag> Their docs are much nicer these days 🙂
<Leonidas> yes, they do look quite nice.
<Leonidas> also lots of interesting stuff in the newest release like accessors, higher_kinded, vcaml
jao has joined #ocaml
<Leonidas> can someone give me an explanation what is meant by "witness" in lots of ocaml type code. what is it witnessing?
<d_bot> <Anurag> I'm assuming the witness refers to the entity that knows about what's the concrete type of the item it stores internally? I've seen it in the context of hmap, Univ_map etc
<Leonidas> yes, that's exactly the contexts I've been stumbling over it. also in higher_kinded
<d_bot> <Anurag> I found https://discuss.ocaml.org/t/types-as-first-class-citizens-in-ocaml/2030/3 to be a good explanation of the use-case, and it definitely helped me understand the need for this pattern.
<Leonidas> great, I'll give it a read
<octachron> My explanation is that the value is witnessing a type equality and inspecting the value with pattern matchings reveals which type equalities it was witnessing.
<d_bot> <Anurag> octachron: Thank you! That expresses what i had in mind better than i could 🙂
<Leonidas> ivg is a treasure
<companion_cube> indeed
<companion_cube> the work on z3 is amazing
smazga has joined #ocaml
<def> ?
<companion_cube> he's fixing the opam packages, isn't he?
<companion_cube> or am I confusing with someone else
smazga has quit [Ping timeout: 272 seconds]
smazga has joined #ocaml
smazga has quit [Ping timeout: 256 seconds]
<Leonidas> you mean kit_ty_kate?
simpson has quit [Remote host closed the connection]
simpson has joined #ocaml
smazga has joined #ocaml
keep-learning[m] has left #ocaml ["Kicked by @appservice-irc:matrix.org : Idle for 30+ days"]
undu[m] has quit [Quit: Idle for 30+ days]
smazga has quit [Ping timeout: 272 seconds]
Haudegen has quit [Ping timeout: 264 seconds]
smazga has joined #ocaml
nullcone has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
cantstanya has quit [Write error: Broken pipe]
andreas303 has quit [Read error: Connection reset by peer]
nicoo has quit [Read error: Connection reset by peer]
nicoo has joined #ocaml
waleee-cl has joined #ocaml
zolk3ri has joined #ocaml
ollehar_ has quit [Ping timeout: 272 seconds]
olle_ has quit [Ping timeout: 272 seconds]
andreas303 has joined #ocaml
cantstanya has joined #ocaml
Blencer has joined #ocaml
Blencer has quit [Remote host closed the connection]
Anarchos has joined #ocaml
nullifidian has joined #ocaml
chripell has quit [Ping timeout: 272 seconds]
nullcone has quit [Quit: Connection closed for inactivity]
vicfred has joined #ocaml
nullcone has joined #ocaml
muskan has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
Haudegen has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
bartholin has joined #ocaml
mbuf has quit [Quit: Leaving]
leah2 has quit [Ping timeout: 260 seconds]
ggole has quit [Quit: Leaving]
dborisog_ has quit [Ping timeout: 260 seconds]
leah2 has joined #ocaml
jnavila has joined #ocaml
nullcone has quit [Quit: Connection closed for inactivity]
Haudegen has quit [Quit: Bin weg.]
raver has quit [Read error: Connection reset by peer]
narimiran has quit [Quit: leaving]
muskan has quit [Ping timeout: 245 seconds]
Anarchos has joined #ocaml
Hrundi_V_Bakshi has joined #ocaml
raver has joined #ocaml
<ansiwen> is it possible to write an generic function wrapper intercepting the result of a function, like a filter? that is, let's say I write a wrapper (mywrapper f), that accepts all functions that return a string, and returns a function with identical arguments, but adds an additional "!" to the returned string. Is that possible?
<companion_cube> `let mywrapper f x = f x ^ "!"` ?
<Anarchos> ansiwen no cause you have to give the number of arguments of f
<companion_cube> (works only for unary functions)
<ansiwen> companion_cube: yeah, I mean something that works with all number of arguments, and even labeled arguments...
<ansiwen> Anarchos: that's what I thought, but hoped that there might be a trick
<companion_cube> so, no
<Armael> no, because then what type would it have
<ansiwen> ok, thanks for the confirmation
<Anarchos> ansiwen if you know the arity, it is possible
<ansiwen> Armael: hmm, the wrapper? maybe ('a -> string -> ('a -> string))?
<companion_cube> that's only for one argument
<ansiwen> so 'a can't represent other functional types like ('x -> 'y -> 'z -> ...)?
<companion_cube> no
<companion_cube> well
<companion_cube> it's more that -> is right-associative
<Armael> wait that's not right, for one argument, the type of the wrapper is ('a -> string) -> 'a -> string
<Armael> and yeah -> is right associative
<Armael> (a -> b -> c) is (a -> (b -> c))
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<ansiwen> Armael: ok, right...
<ansiwen> so, if 'a would be another function like (a -> b -> c) that would make c a result and not an argument... is that right?
<ansiwen> this arity stuff always makes my head spin... anyway, main point is: not possible....
<companion_cube> in practice, why not do it for the (few) arities you need?
<olle> should i call adt "enum" in my blog?
<olle> hm
<olle> because then people will understand ^^
<Armael> it would be misleading, enums are only a simple case of ADTs
<Armael> well, I guess it depends on how you interpret "enum"
<olle> yeah, they use it in Rust now
<olle> "enums that carry data"
<olle> that CAN carry data
<Armael> ah well
<companion_cube> they probably did it to not be too mysterious as well
<olle> yes
<olle> but i don't think reasonml went there
<companion_cube> cause OCaml doesn't specify whether a type decl is a struct, an enum, an alias, etc.
<companion_cube> it's always `type foo = …`
<olle> true
<olle> let* was introduced in OCaml 4.08, correct?
<companion_cube> yes
jnavila has quit [Quit: Konversation terminated!]
<olle> thanks
<olle> companion_cube: is there a return too?
<olle> instead of `return ()`
<olle> damn, it's late :(
<olle> sigh
ArthurStrong has joined #ocaml
smazga has quit [Ping timeout: 256 seconds]
pierpa has joined #ocaml
ArthurStrong has quit [Quit: leaving]
<companion_cube> no, there isn't
smazga has joined #ocaml
Hrundi_V_Bakshi has quit [Ping timeout: 256 seconds]
smazga has quit [Ping timeout: 240 seconds]
remexre has quit [Ping timeout: 246 seconds]