companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
motherfsck has quit [Ping timeout: 264 seconds]
motherfsck has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
elusive has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
oriba has joined #ocaml
rock64 has quit [Ping timeout: 276 seconds]
rock64 has joined #ocaml
curtosis has joined #ocaml
curtosis is now known as curtosis[away]
mxns has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
mxns has quit [Ping timeout: 272 seconds]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
Haudegen has quit [Ping timeout: 264 seconds]
elusive has quit [Quit: Leaving]
laokz has joined #ocaml
oriba has quit [Ping timeout: 260 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
mfp has quit [Ping timeout: 256 seconds]
curtosis has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
vicfred has quit [Quit: Leaving]
sz0 has quit [Quit: Connection closed for inactivity]
vicfred has joined #ocaml
laokz has quit [Ping timeout: 260 seconds]
curtosis has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
laokz has joined #ocaml
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #ocaml
shawnw has quit [Ping timeout: 264 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
<d_bot_> <EduardoRFS> Are effects in OCaml going to be checked?
shawnw has joined #ocaml
Haudegen has joined #ocaml
laokz has quit [Ping timeout: 260 seconds]
Tuplanolla has joined #ocaml
borne has joined #ocaml
laokz has joined #ocaml
<d_bot_> <froyo> afaik 5.0 will have
<d_bot_> <froyo> - no effects syntax
<d_bot_> <froyo> - no purity in Haskell sense
<d_bot_> <froyo> - just the multicore runtime machinery and the domains lib
<d_bot_> <froyo>
<d_bot_> <froyo> but multicore ocaml had already developed the effects syntax, and are working on typesigs containing effects like so: `string -[io]-> unit`, allowing for checking / purity.
tane has joined #ocaml
bartholin has joined #ocaml
borne has quit [Ping timeout: 264 seconds]
mfp has joined #ocaml
laokz has quit [Ping timeout: 265 seconds]
dhil has joined #ocaml
laokz has joined #ocaml
<d_bot_> <Laurent Cetinsoy> let's say that I have a function and a list of ints
<d_bot_> <Laurent Cetinsoy> hello ! 🙂
<d_bot_> <Laurent Cetinsoy>
<d_bot_> <Laurent Cetinsoy> ```ocaml
<d_bot_> <Laurent Cetinsoy> let f a b = a + b
<d_bot_> <Laurent Cetinsoy> let vals = 1 :: 2 :: []
<d_bot_> <Laurent Cetinsoy> ```
<d_bot_> <Laurent Cetinsoy>
<d_bot_> <Laurent Cetinsoy> Is it possible to call f with vals
<d_bot_> <Laurent Cetinsoy> something like in python func(*values) :
<d_bot_> <Laurent Cetinsoy> f *vals
<d_bot_> <Laurent Cetinsoy>
<d_bot_> <Laurent Cetinsoy> where each value of the list will be mapped to an argument ?
bartholin has quit [Read error: Connection reset by peer]
<d_bot_> <octachron> What will be the type of `*vals` for `f *vals` to be well typed?
<d_bot_> <Laurent Cetinsoy> hmm good question huhu
<d_bot_> <Laurent Cetinsoy> the use case is the following
<d_bot_> <Laurent Cetinsoy> I am developping a small unit test library
<d_bot_> <Laurent Cetinsoy> and I want a function named
<d_bot_> <Laurent Cetinsoy> ```ocam
<d_bot_> <Laurent Cetinsoy> let compare_function f1 f2 values_to_feed_f1_and_f2 = (f1 *values_tof_eed) = (f2 *values_to_feed)
<d_bot_> <Laurent Cetinsoy> ```
<d_bot_> <Laurent Cetinsoy> I trust the user to type correctly the values of the list
<d_bot_> <octachron> Try to write the type of the function.
<d_bot_> <octachron> A strongly typed language doesn't trust the user and let them write ill-typed functions.
<d_bot_> <Laurent Cetinsoy> hmm yeah I am expecting not to be possible but still asking
<d_bot_> <Laurent Cetinsoy> é_è
<d_bot_> <Laurent Cetinsoy> is there some variadiac function parameters available ?
<d_bot_> <Laurent Cetinsoy> I am guess that I could do something with variant types
<d_bot_> <octachron> Why not just require `f1` and `f2` to have a single argument.
<d_bot_> <Laurent Cetinsoy> hm because in the dream scenario, I want it to work for function without knowing in advance the signature of the tested functions as it is defined by the user
<d_bot_> <Laurent Cetinsoy> maybe I could do some pattern matchig hm
<d_bot_> <octachron> It is possible to have variadic functions but the complexity cost is generally not worth it. I would advise to simply design the API with the idea that variadic functions are not a thing.
bartholin has joined #ocaml
<d_bot_> <octachron> Note that it is quite simple for the user to transform "n-ary functions" to 1-ary function and this lets the user define more precisely what are the arguments and what is the resultthat ought to be tested which is not a trivial question in a language with a first-class value functions.
<d_bot_> <Laurent Cetinsoy> yeah
<d_bot_> <Laurent Cetinsoy> I actually do not mind if I cannot implement the compare_function
<d_bot_> <Laurent Cetinsoy> it is more or less a syntactic suggar
<d_bot_> <Laurent Cetinsoy> this answer : https://stackoverflow.com/a/39428421/5203829
<d_bot_> <Laurent Cetinsoy> is more a less a solution
<d_bot_> <ggole> You can write something to apply `f` to the first two elements if they are there and raises if they are not
<d_bot_> <Laurent Cetinsoy> yeah
<d_bot_> <Laurent Cetinsoy> i could pattern match something like maybe ?
<d_bot_> <Laurent Cetinsoy> ```ocmal
<d_bot_> <Laurent Cetinsoy> match l with
<d_bot_> <Laurent Cetinsoy> | a :: _ -> f a
<d_bot_> <Laurent Cetinsoy> | a :: b :: _ - > f a
<d_bot_> <Laurent Cetinsoy> | a :: b :: c :: _ -> f a b c
<d_bot_> <Laurent Cetinsoy> | _ -> failwith "too few arguments for f"
<d_bot_> <Laurent Cetinsoy> ```
<d_bot_> <Drup> what's the type of `f` in this piece of code ?
<d_bot_> <ggole> But dynamic language style apply, which works for arbitrary numbers, doesn't really work
<d_bot_> <ggole> And the type of ocaml lists will restrict those arguments to being the same type, of course
<d_bot_> <Laurent Cetinsoy> f should be a function of either one argugment, either, two, either 3
<d_bot_> <Laurent Cetinsoy> I cannot know in advance
<d_bot_> <Laurent Cetinsoy> as I am developping a unit test
<d_bot_> <Laurent Cetinsoy> library
<d_bot_> <Drup> that's not a valid type 🙂
nullcone has quit [Quit: Connection closed for inactivity]
bartholin has quit [Ping timeout: 246 seconds]
<d_bot_> <Drup> (Generally, I would advise to stop trying to translate python idioms to OCaml, you'll feel more productive about your programming life)
<d_bot_> <Laurent Cetinsoy> haha yeah
<d_bot_> <Laurent Cetinsoy> not expert enough yet to think in ocaml yet 😦
<d_bot_> <Laurent Cetinsoy> but I totally agree
<d_bot_> <Drup> (and there are plenty of unit tests libraries that you can use)
terrorjack has quit [Remote host closed the connection]
laokz has quit [Ping timeout: 264 seconds]
bartholin has joined #ocaml
terrorjack has joined #ocaml
omni_ has joined #ocaml
greeb has quit [Quit: ZNC 1.8.2 - https://znc.in]
freshmaker666 has joined #ocaml
freshmaker666 has quit [Changing host]
freshmaker666 has joined #ocaml
omni has quit [Ping timeout: 265 seconds]
hannes has quit [Ping timeout: 265 seconds]
hannes has joined #ocaml
Leonidas has quit [Ping timeout: 245 seconds]
Leonidas has joined #ocaml
nepascourir has joined #ocaml
_whitelogger has joined #ocaml
shawnw has quit [Ping timeout: 246 seconds]
zebrag has joined #ocaml
rock64 has quit [Ping timeout: 260 seconds]
rock64 has joined #ocaml
bartholin has quit [Ping timeout: 260 seconds]
laokz has joined #ocaml
<d_bot_> <Eric J Morey> Just want to say that this is awesome and thank you!:
nepascourir has quit [Quit: Leaving]
shawnw has joined #ocaml
shawnw has quit [Ping timeout: 256 seconds]
laokz has quit [Quit: Leaving]
omni_ is now known as omni
beajeanm has quit [Quit: The Lounge - https://thelounge.chat]
beajeanm has joined #ocaml
waleee-cl has joined #ocaml
dfeuer has joined #ocaml
curtosis has joined #ocaml
drdee has joined #ocaml
curtosis is now known as curtosis[away]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
drdee has quit [Quit: Leaving]
elusive has joined #ocaml
nullcone has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
curtosis[away] has joined #ocaml
oriba has joined #ocaml
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
zebrag has quit [Read error: Connection reset by peer]
zebrag has joined #ocaml
borne has joined #ocaml
borne has quit [Ping timeout: 272 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
dhil has quit [Ping timeout: 264 seconds]
borne has joined #ocaml
borne has quit [Ping timeout: 264 seconds]
decentpenguin has quit [Read error: Connection reset by peer]
tane has quit [Quit: Leaving]
decentpenguin has joined #ocaml
nepascourir has joined #ocaml
decentpenguin has quit [Read error: Connection reset by peer]
<d_bot_> <froyo> ```ocaml
<d_bot_> <froyo> let test_compare funs vals =
<d_bot_> <froyo> vals >>= fun v -> map ((|>)v) vals (* per-value order *)
<d_bot_> <froyo> let test_compare funs vals =
<d_bot_> <froyo> funs >>= fun f -> map f vals (* per-function order *)
<d_bot_> <froyo> ```
<d_bot_> <froyo> something like this?
<d_bot_> <froyo> the result will be a list of values though. you can restrict this to the more special case of two functions and do your comparison once, or you can fold over the list for more fun
decentpenguin has joined #ocaml
<d_bot_> <froyo> er.. binds aside.. the idea is lists of functions and lists of values, each function applied to the list of values producing a list of outputs.. and that is then concatenated.
<d_bot_> <froyo> i'm guessing test frameworks would do something like that
<d_bot_> <froyo> for a known N args you can do curryN/uncurryN even, to imitate expansion for functions that don't take tuples
<d_bot_> <froyo> for the general case im not sure it'll be as trivial
nepascourir has quit [Quit: Leaving]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #ocaml
Haudegen has quit [Ping timeout: 245 seconds]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml