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
nullifidian_ has joined #ocaml
nullifidian has quit [Ping timeout: 268 seconds]
Haudegen has quit [Quit: Bin weg.]
olle has quit [Ping timeout: 268 seconds]
olle has joined #ocaml
nullifidian_ is now known as nullifidian
mfp has quit [Ping timeout: 268 seconds]
analogue has joined #ocaml
AtumT_ has quit [Quit: AtumT_]
kleisli has quit [Ping timeout: 240 seconds]
traviss has joined #ocaml
Xizor has quit [Ping timeout: 264 seconds]
wilfredh has quit [Quit: Connection closed for inactivity]
tormen has joined #ocaml
spew has quit [Quit: Connection closed for inactivity]
tormen_ has quit [Ping timeout: 268 seconds]
analogue has quit [Quit: Leaving]
jao has quit [Ping timeout: 240 seconds]
jaar has quit [Ping timeout: 250 seconds]
kleisli has joined #ocaml
Traviss__ has joined #ocaml
traviss has quit [Ping timeout: 250 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
nullifidian has quit [Ping timeout: 276 seconds]
nullifidian has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
ravenousmoose has quit [Ping timeout: 276 seconds]
kvda has joined #ocaml
kleisli has quit [Ping timeout: 240 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
kvda has quit [Client Quit]
Traviss__ has quit [Quit: Leaving]
traviss has joined #ocaml
narimiran has joined #ocaml
ggole has joined #ocaml
mbuf has joined #ocaml
kvda has joined #ocaml
vodkaInf1rno has joined #ocaml
jgkamat_ has joined #ocaml
jmiven_ has joined #ocaml
notnotda1 has joined #ocaml
Ekho- has joined #ocaml
unyu has quit [Quit: ERC (IRC client for Emacs 26.3)]
zozozo_ has joined #ocaml
vodkaInferno has quit [Read error: Connection reset by peer]
Ekho has quit [Remote host closed the connection]
jgkamat has quit [Quit: ZNC - https://znc.in]
zozozo has quit [Ping timeout: 245 seconds]
jmiven has quit [Ping timeout: 245 seconds]
maker has quit [Ping timeout: 245 seconds]
notnotdan has quit [Ping timeout: 245 seconds]
greenbagels has quit [Ping timeout: 245 seconds]
maker1 has joined #ocaml
greenbagels has joined #ocaml
mal`` has quit [Ping timeout: 276 seconds]
mal`` has joined #ocaml
unyu has joined #ocaml
zmt01 has quit [Read error: Connection reset by peer]
zmt01 has joined #ocaml
betux has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartholin has quit [Remote host closed the connection]
betux has quit [Ping timeout: 268 seconds]
amiloradovsky has joined #ocaml
obadz has joined #ocaml
ravenousmoose has joined #ocaml
Xizor has joined #ocaml
amiloradovsky has quit [Ping timeout: 268 seconds]
toppler has quit [Read error: Connection reset by peer]
toppler has joined #ocaml
Serpent7776 has joined #ocaml
ravenousmoose has quit [Ping timeout: 246 seconds]
mbuf has quit [Ping timeout: 240 seconds]
narimiran has quit [Remote host closed the connection]
narimiran has joined #ocaml
kvda has joined #ocaml
barockobamo has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbifx has joined #ocaml
ollehar has joined #ocaml
zozozo_ has quit [Quit: WeeChat 2.5]
zozozo has joined #ocaml
jeroud has quit [Read error: Connection reset by peer]
jeroud has joined #ocaml
mfp has joined #ocaml
Haudegen has joined #ocaml
jaar has joined #ocaml
toppler has quit [Read error: Connection reset by peer]
toppler has joined #ocaml
toppler has quit [Read error: Connection reset by peer]
toppler has joined #ocaml
betux has joined #ocaml
AtumT has joined #ocaml
GeoffK has joined #ocaml
<GeoffK> can anyone tell me how to do a forward declaration of a function?
<vsiles> You can't. But you can have mutually defined functions. What are you trying to do ?
<GeoffK> i have a function that calls uses a match/with to call a lot of functions
<GeoffK> one of those function can call that function to start the process again.
<GeoffK> maybe just those two can be mutually recursive...
<vsiles> you'll have to make a mutual recursive block: let rec f x = .... g y ... and g x = .... f z .... and h x = .....
<GeoffK> i will try 2 and then escalate to all of them if that fails. Thanks.
gravicappa has joined #ocaml
orbifx has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
stan[m] has left #ocaml [#ocaml]
ptival[m] has left #ocaml [#ocaml]
sagax has quit [Ping timeout: 265 seconds]
trakjohnson[m] has quit [Quit: 30 day idle timeout.]
sagax has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
jaar has quit [Ping timeout: 276 seconds]
kleisli has joined #ocaml
narimiran has quit [Ping timeout: 265 seconds]
kleisli has quit [Ping timeout: 246 seconds]
kleisli has joined #ocaml
jaar has joined #ocaml
jao has joined #ocaml
pino|work has quit [Quit: brb]
pino|work has joined #ocaml
malc_ has joined #ocaml
<ollehar> is there a setting or a way to disable the unit() type in OCaml?
<ollehar> enforce purity of a function
<def`> No
<def`> GeoffK: if it is annoying, you can encode forward decl with a reference to a function
Haudegen has joined #ocaml
<ollehar> def`: why?
<ollehar> def`: has it been discussed?
<vsiles> def`: oh right, I always forget about ref's to do that...
<vsiles> ollehar: probably not enough interesting fallout w.r.t. to the work implied to do that
<ollehar> vsiles: hm
<vsiles> I mean, if you want to do this right, you'll have to do something like Haskell (and then, why don't just use Haskell ?) If you do a dirty switch, it will clutter the whole code base
<ollehar> vsiles: not the same, if you can pick and choose when to allow unit
<vsiles> I don't understand the problem with unit.
<ollehar> vsiles: side-effects have lower testability
spew has joined #ocaml
<ollehar> but yeah, effect types a la koka is the right way to go
<ollehar> so, deep change
<vsiles> I can't see how to do that correctly without rewriting most of everything ocaml related
<vsiles> so little point in that
<vsiles> effects are difficult to handle
<def`> ollehar: algebraic effects have these feature, but there is no stable implementation yet
<def`> this*
emias has quit [Quit: Reboot.]
<ollehar> mm
<ollehar> def`: algebraic effects are not compile time, IIRC?
<def`> ollehar: effects will certainly happen at execution, but their use will be checked statically.
<ollehar> yeah?
<ollehar> then i read it wrong
GeoffK has quit [Quit: Leaving]
<def`> with the proposed design (but many problems have not been solved yet), you can ask for a function to be pure
kleisli has quit [Ping timeout: 245 seconds]
<def`> It is not equivalent to ruling out "unit", but a unit pure function should have no observable effect.
<ollehar> what does that mean?
<malc_> def`: what can it possibly do?
<ollehar> "observable effect"?
<def`> malc_: not terminate ? compute a lot of intermediate values that are ultimately discarded
<def`> so if you look at side-channels, time, memory consumption, cache lines :P, you can distinguish
<malc_> def`: so basically spectre_v3, okay
<ollehar> def`: how is that not the same thing as ruling out unit?
<def`> you are still allowed to use unit
<def`> (unit list, ... type myunit = Unit ...)
<theblatte> how is "disabling" (what does that mean?) unit enforcing purity?
<def`> (tip: unit list is convenient implementation of unbounded natural integers)
<theblatte> (convenient for who? :D)
<vsiles> theblatte: if you can't use/write function using/returning unit, you can't write print_string -> no side effect (short version)
<theblatte> I can so write print_string, mine returns an int instead of unit ;)
<vsiles> :D at some point you'll have to call an I/O function from the std that uses unit
<vsiles> (ok you can fuck the std, but that's not the point here :D)
<Armael> external print : out_channel -> string -> int -> int -> int = "caml_ml_output"
<Armael> print stdout "abc" 0 3
<Armael> look mom no unit
<theblatte> wala
<theblatte> this* (EFRENCH)
pino|work has quit [Quit: brb]
<Fardale> Then the compiler complain that you do not use the output of the function
<vsiles> that what I meant by fuck :p
emias has joined #ocaml
pino|work has joined #ocaml
<vsiles> I guess you would have to provide some guarantees with external stuff
traviss has quit [Ping timeout: 245 seconds]
<ollehar> external would fly in haskell too, i guess
<ollehar> haxxor
* ollehar hacking the planet
ggole- has joined #ocaml
ggole has quit [Ping timeout: 250 seconds]
ggole_ has joined #ocaml
ggole- has quit [Ping timeout: 250 seconds]
FreeBirdLjj has joined #ocaml
betux has quit [Ping timeout: 276 seconds]
orbifx1 has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
tane has joined #ocaml
jgkamat_ is now known as jgkamat
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
kleisli has joined #ocaml
narimiran has joined #ocaml
barockobamo has quit [Remote host closed the connection]
gareppa has joined #ocaml
FreeBirdLjj has joined #ocaml
gareppa has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
smazga has joined #ocaml
orbifx1 has quit [Ping timeout: 245 seconds]
ollehar has quit [Ping timeout: 240 seconds]
kleisli has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
jaar has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Ping timeout: 265 seconds]
jmiven_ is now known as jmiven
ziyourenxiang_ has quit [Ping timeout: 265 seconds]
Haudegen has joined #ocaml
bartholin has joined #ocaml
FreeBirdLjj has joined #ocaml
Hrundi_V_Bakshi has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 250 seconds]
orbifx1 has joined #ocaml
smazga has quit [Ping timeout: 240 seconds]
Boarders has joined #ocaml
<Boarders> I am a haskeller trying to teach myself ocaml, I was wondering if I define a custom list type how I would write a function that can do polymorphic printing of the list?
<Boarders> i.e. the equivalent of to_string :: (Show a) => List a -> String
<malc_> Boarders: you can't
<malc_> Boarders: no typeclasses
<Armael> well we don't have type classes, so the simplest solution is for your function to take an argument of type 'a -> string
<Armael> an extra argument*
<Boarders> ah ok, I thought ml people did it with modules?
<Boarders> can't I make a module with signature involving to_string and have that as an argument to my module?
<Boarders> or is that unidiomatic?
<Armael> you can, but for a single print function it would be cumbersome to wrap it in a functor
<Boarders> I see, thanks!
<tane> Boarders, you can have a look at Set.Make, keyword "functor" on how to parameterize a module with another module
<tane> but as was said, for a single function it's not worth it
<smondet[m]> Boarders: this also works indeed. you can also pass modules as arguments of functions (search for "first class modules"). The question as Armael says, is which is best from a readability / maintainability point of view.
<Boarders> That makes sense, at present I am not even building anything. Just messing around!
<Armael> yeah, usually, if you have a big data structure with many functions, and that is parameterized by a type + some operations (eg the type of the elements + a comparison function), using the module system (with a functor) is a good approach, see Set.Make from the stdlib for an example
<companion_cube> malc_: it won't happen, come on :p
<Armael> malc_: no point in hyping up vaporware :)
<Armael> Boarders: but for printing, the preferred approach is instead to have combinators, e.g. you have a combinator that knows how to pretty-print As, an other combinator that knows how to pretty-print lists given a combinator for the elements
<malc_> companion_cube, Armael: people wrote a paper, maintained a branch... the point is being good and support them
<Armael> and you combine them (just using function application) to obtain a combinator that knows how to pretty-print lists of As
<Armael> for an example, see https://github.com/dbuenzli/fmt
<Armael> (although Format combinators are a bit hairy at first so don't panic if it's not clear at first :))
smazga has joined #ocaml
kakadu has joined #ocaml
<Boarders> another question, what is the way you would combine lots of elements e.g. the equivalent of haskell's: fold ["well", "will", "you", "look", "at", "that"] that is not just inserting loads of ^
jnavila has joined #ocaml
<Armael> you can do List.fold_left (^) "" ["abc"; "def"]
<Armael> is that what you mean?
<companion_cube> you mean String.concat "", right?
<Armael> ah sure :)
<Boarders> both good to know :)
<Armael> not sure about String.concat, but the fold is definitely quadratic
<companion_cube> String.concat is better, it pre-computes the size and allocates only once, iirc
<Armael> ah, concat is linear
<Armael> yep
<companion_cube> I mean it's designed for taht :p
<companion_cube> if you get into serious printing, I'd recomend Format or at least Buffer.t + Printf.bprintf
<companion_cube> (cause yeah, imperative can be faster ;))
smazga has quit [Quit: leaving]
traviss has joined #ocaml
orbifx1 has quit [Ping timeout: 245 seconds]
porchetta has quit [Ping timeout: 276 seconds]
<madroach> companion_cube: Is there a easy way to get back polymorphic comparison with Containers in OCaml 4.09 ?
<companion_cube> ugh
<companion_cube> I need to look at your PR, sorry
<companion_cube> open Pervasives? :p
porchetta has joined #ocaml
ggole_ has quit [Quit: Leaving]
porchetta has quit [Ping timeout: 240 seconds]
kleisli has joined #ocaml
porchetta has joined #ocaml
<madroach> companion_cube: is deprecat.d
orbifx1 has joined #ocaml
AtumT_ has joined #ocaml
AtumT has quit [Read error: Connection reset by peer]
<Boarders> in ocaml if I want to bind a tuple and then pattern match on a component how do I do that?
<Boarders> I was trying
<Boarders> function (f, s) -> match s with ...
<Boarders> but that doesn't seem to work
<companion_cube> madroach: -warn -3
<companion_cube> ;)
<companion_cube> until we fix that in containers
orbifx1 has quit [Read error: Connection reset by peer]
<Armael> Boarders: you should give a bigger code snippet
orbifx1 has joined #ocaml
<Boarders> let rec stack_to_string : ('a -> string) * 'a stack -> string = function (f,s) -> match s with | E -> "[]";;
<Boarders> etc
<Boarders> ignore the ;; sorry
<Armael> that should work
<Armael> although I would curry the stack_to_string function
<Armael> let rec stack_to_string (f: 'a -> string) (s: 'a stack): string = match s with ...
gravicappa has quit [Ping timeout: 240 seconds]
<Boarders> I tried that but got a bit confused but have managed to get it working now
<Boarders> thanks!
jao has quit [Remote host closed the connection]
<companion_cube> madroach: you can probably do `open Pervasives [@@warning "-3"]` actually
kleisli has quit [Ping timeout: 245 seconds]
orbifx1 has quit [Ping timeout: 268 seconds]
Serpent7776 has quit [Quit: leaving]
kleisli has joined #ocaml
narimiran has quit [Ping timeout: 268 seconds]
jao has joined #ocaml
toppler has quit [Read error: Connection reset by peer]
toppler has joined #ocaml
<madroach> cartwright: thanks!
<madroach> companion_cube: thanks!
kvda has joined #ocaml
<madroach> companion_cube: You asked for tests for my bigstring I/O stubs. What's you preferred test framework? I would use alcotest.
<companion_cube> alcotest is fine, as long as it's indicates as a test dep in opam :)
jnavila has quit [Ping timeout: 246 seconds]
kleisli has quit [Ping timeout: 240 seconds]
Jesin has quit [Read error: Connection reset by peer]
Jesin has joined #ocaml
vicfred has joined #ocaml
malc_ has quit [Quit: ERC (IRC client for Emacs 27.0.50)]
_whitelogger has joined #ocaml
toppler has quit [Read error: Connection reset by peer]
toppler has joined #ocaml
jbrown has quit [Ping timeout: 276 seconds]
vicfred has quit [Quit: Leaving]
fixme has quit [Ping timeout: 245 seconds]
olle has quit [Ping timeout: 240 seconds]
olle has joined #ocaml
fixme has joined #ocaml
orbifx1 has joined #ocaml
kakadu has quit [Remote host closed the connection]
tane has quit [Quit: Leaving]
orbifx1 has quit [Ping timeout: 265 seconds]
kleisli has joined #ocaml
kleisli has quit [Remote host closed the connection]
kleisli has joined #ocaml
kleisli has quit [Ping timeout: 268 seconds]
unyu has quit [Ping timeout: 250 seconds]
ziyourenxiang_ has joined #ocaml
spew has quit [Quit: Connection closed for inactivity]
jbrown has joined #ocaml