hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
hlisp has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
Haudegen has quit [Ping timeout: 260 seconds]
mfp has quit [Ping timeout: 256 seconds]
pigeonv has quit [Ping timeout: 265 seconds]
hlisp has joined #ocaml
nullcone has joined #ocaml
hlisp has quit [Remote host closed the connection]
vicfred has joined #ocaml
hlisp has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
ygrek has joined #ocaml
narimiran has joined #ocaml
narimiran has quit [Client Quit]
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
mbuf has joined #ocaml
jao has quit [Ping timeout: 256 seconds]
hlisp has quit [Ping timeout: 256 seconds]
amiloradovsky has joined #ocaml
ygrek has quit [Ping timeout: 256 seconds]
amiloradovsky has quit [Ping timeout: 244 seconds]
Haudegen has joined #ocaml
sugarwren has joined #ocaml
ferd has quit [Ping timeout: 256 seconds]
ferd has joined #ocaml
Anarchos has joined #ocaml
ferd has quit [Ping timeout: 272 seconds]
dborisog has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
ferd has joined #ocaml
hlisp has joined #ocaml
<olle>
companion_cube: not enough resources_
<olle>
?
<def>
it is not clear how to type "first-class" algebraic effects (when you can abstract over effects, hide their implementation, etc)
mfp has joined #ocaml
amiloradovsky has joined #ocaml
waleee-cl has joined #ocaml
<olle>
def: clear for whom? everybody?
<def>
yes
<olle>
hm hm
<olle>
what about F*?
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
<olle>
Other question: I can't use a module sig in another module sig?
<Anarchos>
olle what you mean ?
<olle>
Anarchos: module type T = sig type t = S.t end
<olle>
where S is a previous module type
<Anarchos>
yes you can
<olle>
with functor keyword?
<olle>
trying to find docs
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 258 seconds]
hlisp has joined #ocaml
pigeonv has joined #ocaml
<olle>
ha!
<olle>
got it
porchetta has quit [Ping timeout: 260 seconds]
oturtle has quit [Ping timeout: 256 seconds]
zolk3ri has quit [Remote host closed the connection]
hlisp has quit [Ping timeout: 260 seconds]
<olle>
can a module have multiple sigs?
<olle>
"Did you mean: can an ocaml module have multiple dogs "
<olle>
hehe
hlisp has joined #ocaml
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
hlisp has quit [Remote host closed the connection]
<tobiasBora>
Hello, I'm not sure to understand why, but I defined in a module module MyModule : ModuleType = struct type 'a t = (int -> (int, 'a)) end
<tobiasBora>
and I have an error "This 'struct' might be unmatched
<tobiasBora>
". When I remove the type the error disapear, so I guess the issue comes from the "type 'a t = (int -> (int, 'a))"
<tobiasBora>
but not sure to see what's wrong there
<olle>
hm
<olle>
tobiasBora: can you try with type t = int?
<olle>
tobiasBora: wait
<olle>
tobiasBora: shouldn't you use * instead of , ?
<olle>
for the tuple
<tobiasBora>
olle: I'm so stupid, thanks! No doing ocaml for 4 years makes me feel quite stupid ^^
hlisp has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
hlisp has quit [Ping timeout: 256 seconds]
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
hlisp has joined #ocaml
<olle>
np :)
<tobiasBora>
Hum... I have the feeling that something strange happens with the types in my tests. I'm trying to recreate Monads using something like that http://paste.debian.net/1145823
<tobiasBora>
However the last line "fun s -> (s+n, ())" fails with "This expression should not be a function, the expected type is unit M.t"
<tobiasBora>
However, the type of M.t is a function: "int -> int * 'a"
<tobiasBora>
defined line 14 in my example: type 'a t = int -> int * 'a
<olle>
how do you compile it?
<tobiasBora>
just with "ocamlopt myfile.ml && ./a.out"
<olle>
which char on that line?
<tobiasBora>
char?
<olle>
character
drbb has joined #ocaml
drbb has quit [Remote host closed the connection]
drbb has joined #ocaml
<tobiasBora>
olle: you ask me where is located the error in the line "fun s -> (s+n, ())"? Everywhere, the whole expression is underlined
<tobiasBora>
characters 4-22
<olle>
ok
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
<olle>
well yeah, looks like `tell` returns a function :) tobiasBora
<tobiasBora>
olle: in general tell just returns a unit M.t, but in that specific module, I expect unit M.t to be int -> int * unit...
<tobiasBora>
(because IntStateMonad defines it like "type 'a t = int -> int * 'a")
drbb has quit [Remote host closed the connection]
<olle>
?
<olle>
how could unit M.t be a function?
drbb has joined #ocaml
drbb has quit [Client Quit]
<olle>
you want tell to return 'a M.t, maybe?
zolk3ri has joined #ocaml
<def>
if type 'a M.t = int -> int *'a, then unit M.t is an function type.
<tobiasBora>
def: yes, so what's wrong with my program?
<def>
tobiasBora: `IntStateMonad : Monad` coerces the module to the module type of Monad, hiding the fact that 'a = int -> int * 'a
<def>
you can do `module IntStateMonad : Monad with type 'a t = int -> int * 'a` to prevent abstracting the type.
<olle>
right, the exact type of 'a is hidden
<olle>
sorry, M.t
<tobiasBora>
oh really? That's strange, why is it like that? So it means that I need to write 2 times the definition of 'a t?
<tobiasBora>
(but indeed it works great)
<olle>
tobiasBora: well, the module sig defines what's public
<olle>
the struct definition does not change that
<tobiasBora>
ok I see
<tobiasBora>
thanks!
<olle>
InitStateMonad is has sig MONAD
<olle>
you should probably use the habit of all upper-case sig
<tobiasBora>
Also, I have some more questions concerning modules. It seems to create a huge overhead (just adding a module multiplies by 30 the running time of my program). How could I avoid this overhead? I say that before there were ocamldefun, but now it's not maintained anymore
<olle>
adding which module?
<def>
A module has almost no overhead. The slowdown must be caused by sometehing else.
raver has quit [Remote host closed the connection]
<tobiasBora>
basically I have 3 "version": one normal, without any module: it runs in 0.025s
<olle>
run it ten times, take the avarage
<olle>
can be random noise
<tobiasBora>
olle: the noise I get is in the 2-3rd decimal...
<tobiasBora>
The one that does exactly the same operation but with a Monad formalism runs in 0.60s (to 30x), and if I just add a simple operation that also call the number of recursive calls... then it goes to 4.5s.
<olle>
interesting
<tobiasBora>
(with GHC and optimisation enabled, the same code runs in ~0.027s (for both versions))
<tobiasBora>
(adding optimisation in ocaml with "ocamlopt -O2 debug.ml" does not help)
<Armael>
tobiasBora: can't compile your paste because it's missing a countNumberCallsNoWriter function
<tobiasBora>
I guess that it's required (at least in Haskell), because the initial state may come from an IO monad
<tobiasBora>
but I'm not sure
<Armael>
i don't know much about optimizing ocaml code and monadic code in particular, but it's not too surprising to me that a program that spends all its time allocating pairs is slower
<Armael>
that one who doesn't
<Armael>
if you run perf on your program you'll see that it spends all its time in the GC
<tobiasBora>
Ok I see, thanks. Not sure why haskell does not suffer from this problem then, but thanks. Also, the bind syntax is quite annoying, and I'm not sure how to use a let-based syntax here. Should I replace the "bind" with a let* as defined here? https://caml.inria.fr/pub/docs/manual-ocaml/bindingops.html
<olle>
tobiasBora: check memory allocation of the haskell program
<olle>
tobiasBora: if you tweak the ocaml gc to eat more memory you can improve speed
<Armael>
I also suspect that haskell has more optimizations targeted at that kind of code, whereas it's not the case in ocaml (yet?) because it's not so idiomatic
<olle>
sure
<olle>
you don't need monads for this use-case in ocaml
<olle>
make an idiomatic ocaml version and check the speed :)
<tobiasBora>
What would be the idiomatic ocaml version for that kind of code (i.e. one "base computation" that has some logging options)? Something like a simple function in argument? Or an object?
<olle>
functor?
<tobiasBora>
olle: well it's already what I kind of use no?
<olle>
yeah
<tobiasBora>
(MakeCountNumberCalls is my functor)
<olle>
true
<olle>
you can use a mutable variable for the count
jao has joined #ocaml
<tobiasBora>
without the state monad?
<olle>
tobiasBora: well, state monad is not idiomatic in ocaml to begin with
<olle>
so the example kind of all apart
<olle>
fall apart*
<companion_cube>
the state monad is kind of useless, unless you combine it with other monads
<tobiasBora>
I see, I'll try to see what it give!
<tobiasBora>
And also, is it possible to create a module that implements several module signatures?
<companion_cube>
module signatures are structural, not nominal
<companion_cube>
so, yes, trivially
<tobiasBora>
so you have a structure to say that a module has "two types"? Like module MyModule : ModuleA, ModuleB = struct ... end?
<companion_cube>
module MyModule = struct … end
<companion_cube>
module MA : A = MyModule
<companion_cube>
module MB : B = MyModule
<companion_cube>
*if* you want explicit casts, otherwise, you can use `MyModule` directly
<tobiasBora>
so you can't have both one module with 2 signatures, you need to instanciate new modules I see. Thanks!
<companion_cube>
but signatures are not really needed
<Armael>
if A is more general than B, then you can just have MyModule : A = struct .. end
<Armael>
and then use MyModule wherever you need something of sig B
<tobiasBora>
Armael: ok, but it does not work if A and B are not comparable
<Armael>
then how would they be valid signatures for the same module?
<companion_cube>
Armael: they can be incomparable yet compatible?
<Armael>
mmm, you're right
<tobiasBora>
yes, like haskells typeclass
<tobiasBora>
(sorry, I've done a bit too much haskell, but I still love my first love ocaml :P)
<tobiasBora>
For example, you may have a module that defines an operation *, and operation +, and you may want to specify that your module have two valid "sub-signatures", defined by Times or Plus
<companion_cube>
you could have a signature that include Times and Plus
<companion_cube>
`module type S = sig type t include Plus with type t := t include Times with type t := t end`
<tobiasBora>
true, but if you want to merge n different types you may need 2^n "merged" types.
<tobiasBora>
I think to remember that objects had a way to get around that but not sure
<tobiasBora>
btw, why object are not more used in *O*caml?
<companion_cube>
they have difficult to read error messages
<companion_cube>
they do have their uses
<thizanne>
every project related to OCaml is named osomething
<thizanne>
that should count as a use
<tobiasBora>
companion_cube: I see, thanks
<tobiasBora>
ahah
<tobiasBora>
Grrr I can't rememeber, what is the good way to turn a random computation into a unit? I can do let _ = f in (), but I think to remember there is something more efficient
<companion_cube>
olle: some things are better, others are not 🤷
<olle>
like the lazy thing?
<olle>
yeah, maybe :)
<companion_cube>
for example, or compilation times
<tobiasBora>
for me a huge point of haskell is the ecosystem
<tobiasBora>
good libraries in ocaml are still missing... Like if I'm not wrong there is not a good database ORM, that makes me forget about my databse
<olle>
afaik, yes
<olle>
I think OCaml deserves better momentum, because it's easy to get into, comparatively
<tobiasBora>
(not related, but it's funny I tried to avoid Monad-based stuff + using references, and it's indeed much more efficient, but the fun part is that the function that does log something is ~30% quicker compared to the function that does *not* log anything ^^
<tobiasBora>
)
<companion_cube>
that's quite strange
<companion_cube>
oh, or do you mean the logging function is the one not using monads?
<olle>
tobiasBora: now try run it without collecting any memory ;)
<olle>
it's the (java) way
<companion_cube>
what do you mean?
<olle>
tuning the gc
<companion_cube>
ah well, you can slightly tune the GC in OCaml too
<tobiasBora>
you don't have strong types in php do you?
<tobiasBora>
fair enough
<hannes>
fwiw i think php greatly improved their security story over the years
<companion_cube>
the post above mentions that, yeah
<companion_cube>
and they do have types it seems?
<tobiasBora>
that you can enforce at "compile time"?
<companion_cube>
idk
<tobiasBora>
people also say that most blocking action are blocking
<tobiasBora>
(remove the first blocking :P)
<olle>
tobiasBora: Vimeo made a great static analyzer, I'll try to promote it more at work
<olle>
I use it for some of our smaller code bases
<tobiasBora>
interesting
<olle>
You basically end up with Java in the end
<olle>
including checks for null
<olle>
add it to your editor and you're good ^^
<tobiasBora>
null should be forbidden if not explicit for me...
<olle>
sure
<olle>
it's on the map for future PHP versions, I think... nullable types.
<olle>
or maybe already added, don't know
<olle>
the current internals team is really good too
<olle>
sorry for ranting about that :| :)
<tobiasBora>
Just a question, nodejs & co are quite "hype", but not sure how serious they are, it seems that Java/PHP/.NET are still much more popular than nodejs. Is it for a good reason, or just history?
<tobiasBora>
(sorry if I'm a bit oftopic)
<olle>
neither of those "old" languages do reactive front-end
<companion_cube>
well I guess .NET works well on windows
<companion_cube>
and java is fast and safer than JS, afaik
<companion_cube>
(also, IDE support)
<olle>
JS is a pile of stinking garbage, but you add Typescript and, again, you end up with Java :)
<olle>
everything just ends with java...
<companion_cube>
google's dart also ends up being java :D
<olle>
haha right
<olle>
and OCaml can be java too! (reasonml)
Anarchos has joined #ocaml
<olle>
or OCaml on the JVM (F#)
<tobiasBora>
people don't care about reactive front-end? It seems quite nice to me to share just one language between frontend and backend
<olle>
yeah, that's the argument
<rom1504>
yeah that's the argument for js
* olle
hm
<tobiasBora>
ok, so there is no real reason against, say typescript + nodejs
<olle>
only the immature ecosystem
<rom1504>
I would have said the opposite
<tobiasBora>
oh, it is?
<rom1504>
language is not amazing, ecosystem is pretty much the only one that kind of work (usable package manager and all)
<tobiasBora>
For me the problem of nodejs & co is that you need to build everything from scratch
<olle>
which one? npm?
<rom1504>
yes
<rom1504>
there are tons of good packages, so you don't need to build everything from scratch
<tobiasBora>
rom1504: well you still need for me to plug correctly all the packages. They don't like framework, so you need to take passeport, plug it with mongodb, then find a way to implement users...
<tobiasBora>
while in django (sorry I don't know much frameworks), you just install one thing, and it works^{tm}
<rom1504>
I fell on this https://github.com/pypa/pip/issues/988 recently (I've been doing a bunch of python recently), and... come on I didn't think other package managers were this far behind
<rom1504>
yeah true you have to know how to assemble all the things
<rom1504>
frameworks may be a more useful guide when you have less experience in web stuff. I bet there are good tutorials though
<tobiasBora>
rom1504: Ok pip is not amazing. Use nix ;)
<simpson>
rom1504: It helps to understand the hidden context: The folks on that issue are working with OpenStack specifically, and OpenStack commits aggressive package-manager abuse.
<rom1504>
is that something people do ? I tried looking into python+pix a while ago and didn't find much (I've been looking for an excuse to try nix :))
<rom1504>
*nix
<tobiasBora>
rom1504: For me framework also help to keep conventions, and reduce risk to have security issues. With a framework, nobody will ever encode a password in the memory. With nodejs... you need to say "oh, I know that I need to hash the password. I will find a library that hash the password for me. Oh it's only 10 lines, why should I take a library." And 10 years later, you realize that you used to broken md5
<tobiasBora>
function and never tried to upgrade it :P
<rom1504>
what is package-manager abuse ? (I did fell on that issue for a real use case with a chain of dependency of size like 2, not even that complicated in my case)
<tobiasBora>
rom1504: I don't think lot's of people use nix no
Anarchos has quit [Remote host closed the connection]
<rom1504>
tobiasBora: that's reasonable but not sure if that's a case that happens that often. It's also possible to reverse the argument (framework has a security issue, everyone uses it and it's not maintained => huge attack potential)
<simpson>
I wish more folks would use Nix. Due to a deficiency in PyPI's metadata, we sadly can't slurp PyPI packages directly into nixpkgs, which is disappointing. Worse, we can't reflect package requirements, because setup.py can contain arbitrary code. Yay~
<tobiasBora>
rom1504: framework has less change to be unmaintained than single library
<tobiasBora>
and security issues can also arrive when you mix several libraries together I guess
<rom1504>
I don't know if that's true. A single library can find a new maintainer easily as it's small and easy to maintain, a framework on the other end...
hlisp has quit [Remote host closed the connection]
sagax has quit [Quit: Konversation terminated!]
sagax has joined #ocaml
<rom1504>
I think it really depends on the case by case, it would be hard to know for sure whether frameworks or small libraries are more secure without actually looking at the data
<rom1504>
we're just talking about possibilities
<rom1504>
I think for security a factor that matters a lot more is who is doing the maintaining, if it's a company with a lot of stakes in it being secure, it's probably going to be secure, if it's just that one guy that works on it in his free time, I'm not sure :)
<tobiasBora>
true, it's just my feeling
<rom1504>
"we can't reflect package requirements, because setup.py can contain arbitrary code." yeah that must be pretty horrible for python package managers
<rom1504>
dynamic dependencies
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 258 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
tane has joined #ocaml
ygrek has joined #ocaml
hlisp has joined #ocaml
mbuf has quit [Quit: Leaving]
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 240 seconds]
sagax has quit [Ping timeout: 260 seconds]
hlisp has joined #ocaml
waleee-cl has joined #ocaml
hlisp has quit [Ping timeout: 272 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
hlisp has quit [Ping timeout: 272 seconds]
Haudegen has quit [Quit: Bin weg.]
zolk3ri has quit [Remote host closed the connection]
sds41 has quit [Remote host closed the connection]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 258 seconds]
nullifidian_ has quit [Read error: Connection reset by peer]
nullifidian_ has joined #ocaml
hlisp has joined #ocaml
<haesbaert>
I use an IntSet= Set.Make (... type t = int ) very often, in different modules
<haesbaert>
I want the visibility to be "global", what's the common way to do this ? cause if I define in one module I have to keep opening it from other modules
<haesbaert>
should I create a intSet.ml ?
hlisp has quit [Ping timeout: 260 seconds]
<haesbaert>
hmm no that wouldnt work
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 264 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
<def>
haesbaert: yes
<def>
intSet.ml: include Map.Make(struct type t = int let compare : int -> int -> int = compare end
<def>
)
<haesbaert>
ahhhh include !
<haesbaert>
many thanks, that should do it
hlisp has joined #ocaml
Anarchos has joined #ocaml
sagax has joined #ocaml
hlisp has quit [Ping timeout: 264 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
hlisp has joined #ocaml
bluesung1ound has joined #ocaml
bluesunground has quit [Ping timeout: 260 seconds]
hlisp has quit [Ping timeout: 258 seconds]
hlisp has joined #ocaml
Jesin has quit [Quit: Leaving]
<olle>
sigh
<olle>
I can't include a module sig into another sig?
<Anarchos>
olle "include T"
<Anarchos>
module type S = sig include T end
<olle>
ah shit
<olle>
wrote wrong sig name
<olle>
thanks!
Jesin has joined #ocaml
hlisp has quit [Ping timeout: 264 seconds]
<olle>
can a function def be abstract in a sig?
<olle>
but how would you know how to use it?
<olle>
imagine i want a sig with type t and val create with a variadic number of args
hlisp has joined #ocaml
zolk3ri has joined #ocaml
<olle>
val creates return t, but it's input args are not known for the sig
<olle>
val create returns*
<olle>
its*
<olle>
christ
<Anarchos>
variadic number of args do not exist in OCaml
<olle>
But you'd could simulate it somehow?
<olle>
hm
<olle>
can't think of something good
<hannes>
I'd take a look into Printf.printf
<olle>
oh god
hlisp has quit [Read error: Connection timed out]
<olle>
or list with input types, but it'd have to be ADT exposed in the sig anyway
<olle>
bah
<olle>
fuck it
<olle>
I coded and coded and now I have to split up my 2300 LoC file into ~20 modules with functors and what have you, due to cyclic dependencies.
<olle>
hm
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
nullifidian__ has joined #ocaml
nullifidian_ has quit [Ping timeout: 258 seconds]
sugarwren has quit [Quit: Leaving]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
tane has quit [Quit: Leaving]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 272 seconds]
hlisp has joined #ocaml
raver has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 272 seconds]
amiloradovsky has quit [Ping timeout: 244 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]