<steve_gh>
Hi. I'm trying to understand using functors. I'm getting a compile error "module is not a functor". I have a sig called Distribution_intf which is instantiated by the module Distribution, which is applied to a module with a correct signature.
<steve_gh>
The compiler tells me that when I try to instantiate Distribution, the module is not a functor, and has type sig sig <contents of Distribution_intf> end end
<steve_gh>
Obviously my code is not setting up the module type quite correctly, but I am at a bit of a loss..
<steve_gh>
sorry - should have read sig module type Distribution_intf = sig ... end end
<companion_cube>
but how do you define Distribution?
<companion_cube>
and that's where the issue is? weird
<steve_gh>
That is exactly where the issue is :-(
<companion_cube>
can we see some more code? :) (use a paste)
<steve_gh>
Right - hopefully this will come out ok: Distribution.ml
<steve_gh>
module type Distribution_intf = sig type v type element = Element of float * v type t = element list val norm : t -> t val create : t -> t val lift : t -> f:(v -> v) -> t val compose : t -> t -> f:(v -> v -> v) -> t val expected : t -> v (*val random : t -> v *) end open Core.Std module Distribution( Value : Floatable) : Distribution_intf with type v = Value.t = struct type v = Value.t type eleme
<steve_gh>
nah - that didn't work
<companion_cube>
on a paste site would be better…
<companion_cube>
good thing you didn't copy 30 lines here
<steve_gh>
There is also a Distribution.mli file - that just holds a copy of the Distribution_intf signature
<int-e>
I'm seeing some funny behavior with Format and threads, http://sprunge.us/UdBA?ocaml (using ocaml 4.04.0)... in the end, my question is basically this, is Format supposed to be thread-safe?
<companion_cube>
steve_gh: ahhhhhhhhh
<companion_cube>
the distribution.mli should contain: `module type Distribution_intf = sig … end module Distribution(V : Floatable) : Distribution_intf with type t = V.t`
<companion_cube>
steve_gh: your problem is that the .mli doesn't match the .ml
<companion_cube>
but it also happens that ocaml trusts the .mli in the first place
<companion_cube>
and when you use this .mli it believes that `Distribution` is indeed not a functor
<companion_cube>
so it complains in the other module
<steve_gh>
ahhh - thank you :-)
<Drup>
int-e: huum, I wouldn't be surprised if Format was not thread safe
<companion_cube>
I'd be very surprised if it *was* thread safe
<Drup>
yeah
<Drup>
given how it works ...
<companion_cube>
reminds me I should publish this thead sub-library
<Drup>
companion_cube: I would just use (future) Lwt_fmt
<companion_cube>
that's like, totally different
<companion_cube>
sometimes you might want to use threads and not lwt
<companion_cube>
(and I'm a bit expecting those to be popular again once/if we get effects)
<int-e>
Drup: Well I was hoping not having to find out how it works.
stormogulen has quit [Remote host closed the connection]
<Drup>
int-e: just put lock around the format statement
<companion_cube>
^
<int-e>
Drup: if I make sure that every formatter is only used from one thread, do I have a chance of being threadsafe then?
<Drup>
that should be enough, if you flush at each statement
<companion_cube>
int-e: yes it's safe if you use each f ormatter only from one thread
<Drup>
yeah
<int-e>
okay, that should be good enough, thanks!
<Drup>
actually, yes, but only if you use @.
<Drup>
Otherwise, you will have two concurent indentation engine trying to format on the same channel. The output might turn messy
<int-e>
oh and before I dig myself in further, is thread support in ocaml there to stay or is there still a risk of it being removed again?
<Drup>
"again" ?
mengu has quit [Quit: Leaving...]
<Drup>
thread support was always there, no ?
<companion_cube>
it's here to stay afaik, removing it would be an incredibly breaking change
<int-e>
"again" in the sense of going back to habing no (native) thread support.
<companion_cube>
people would complain
<companion_cube>
(I would)
<Drup>
but why would it be removed ? I'm not sure I follow the logic x)
<companion_cube>
maybe they could remove Event one of these days, though :]
<int-e>
Drup: afaik native threads are fairly new; there has been a cooperative mechanism for a long time.
<Drup>
huh, no
<int-e>
what am I mixing up then, hmm.
<Drup>
git log tells me "Mon Oct 30 10:21:56 1995"
<Drup>
so, really not
<companion_cube>
:D
<int-e>
Oh, what I'm mixing up is that there are plans, perhaps a reality now (need to check), to make the global interpreter lock more finely grained.
<int-e>
it says "if all goes well" and I don't know whether all went well.
<thizanne>
we're in 4.04
<thizanne>
so take a guess :}
<int-e>
thizanne: "hopefully!" ;-)
<companion_cube>
everything takes longer than expected, even taking this law into account
<companion_cube>
"Can we get unicode string literals next ;_;" ← huh?!
<companion_cube>
you can already write utf8 in string literals
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0 has quit [Killed (orwell.freenode.net (Nickname regained by services))]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
sh0t has joined #ocaml
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
Denommus has quit [Remote host closed the connection]
Denommus has joined #ocaml
infinity0 has joined #ocaml
yomimono has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
<int-e>
So, unfortunately, as far as I can see, the multicore support has not made it into ocaml's mainline yet, it's still a separate ocaml-multicore repository. (I'd love to be wrong about this ;-) )
<yomimono>
Unfortunately you are correct, as far as I (a person who doesn't work on multicore) know
<companion_cube>
that's it
<companion_cube>
and it will still take time, imho
Denommus has quit [Ping timeout: 255 seconds]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
hcarty has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
hcarty has quit [Ping timeout: 260 seconds]
<companion_cube>
Drup: hey, I think I have a good way of making CCFormat.list better
<companion_cube>
~sep:",@ " by default
<companion_cube>
you would pass any arg-free format
Muzer has quit [Ping timeout: 256 seconds]
<Drup>
it's strictly less expressive than having (cst ",@ ") by default, but okay
<companion_cube>
it's much more convenient
<Drup>
having sep of type `unit printer` (as above) also sounds simpler
<Drup>
(type and documentation wise)
<companion_cube>
yes, but it's much more heavy to write
<companion_cube>
~sep:";@ " is nice and readable
<Drup>
is it ? 5 chars is that bad ?
<companion_cube>
yes, it is
<int-e>
738
<companion_cube>
+ parenthesis + some combinator
rgrinberg has joined #ocaml
<Drup>
it also means you can't do something like "const pp v" as a sep
<companion_cube>
in hundreds of places in my code
<Drup>
(well, you don't have the equivalent of Fmt.const anyway, but still)
<companion_cube>
I will
<companion_cube>
but still, it's annoying to have ~sep:(Fmt.const "foo")
<companion_cube>
especially because you want the "@ " in addition to that
<companion_cube>
(I known I do, at least)
<companion_cube>
so it would always be ~sep:(Fmt.fprintf ",@ ") or whatever
<Drup>
if you chose the default well enough, will you still have the issue ?
<companion_cube>
yes
<companion_cube>
I overload the default to be future proof in quite a lot of places
<Drup>
that makes the default kindof pointless, but okay
<companion_cube>
please, stop lecturing me on how to use my own libraries -_-
<companion_cube>
I understand your concern of `unit t`, it's nice and all
<Drup>
Make an operator ? :D
<companion_cube>
but how often do you need a dynamic separator?
<Drup>
Alternative solution, expose sp = unit "@ " and various other common separators
<Drup>
then it's ~sep:sp, or the one you choose
<Drup>
(that's actually what is done in Fmt)
<companion_cube>
~sep:Fmt.sp
virtualeyes has quit [Ping timeout: 276 seconds]
<companion_cube>
meh
<companion_cube>
I'll think about it
<Drup>
huh, non
<companion_cube>
huh, yes
<Drup>
Fmt.(list ~sep:sp .... )
<Drup>
local open ftw
<Drup>
:D
<companion_cube>
I'm always a bit weary of this, I avoid it if I can
<companion_cube>
too easy to get a shadowing
<companion_cube>
if not all the printers live in Fmt.(…)
<Drup>
As long as you don't have "pp" in your module, it's going to be fine most of the time
<companion_cube>
I'm tired of this -_-
<companion_cube>
"it's essential" pure curiosity, what do you use the additional flexibility for?
<Drup>
it's not essential, I will just have to load Fmt on top of containers, ultimately, you do whatever you want :)
snowcrshd has quit [Remote host closed the connection]
<companion_cube>
no but what do you need this for?
<companion_cube>
what use cases do you have, really?
<companion_cube>
(I could image ~sep:(return "@{<green>,@}@ ") perhaps)
<Drup>
it's the way I define my printing operators generally. There is no reason to impose base values in ~sep, that's all.
<Drup>
Well color is a good example: I really don't want to use the tag explitely (that's so extremly prone to breakage ...)
virtualeyes has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
<Drup>
companion_cube: anyway, as I said, do what you want, I'll use what I prefer
ethnopes has joined #ocaml
ethnopes has quit [Quit: quit]
ethnopes has joined #ocaml
ethnopes has quit [Quit: /part]
ethnopes has joined #ocaml
MercurialAlchemi has joined #ocaml
hcarty has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
dhil has quit [Ping timeout: 255 seconds]
<kakadu>
I kind of forgot a right trick to allow function of type ('a -> bool) to be appyed to anything......
<kakadu>
let foo : 'a . ('a -> bool) -> int -> string -> bool = fun f a b -> (f a) && (f b);;
<kakadu>
Does it exist>
<kakadu>
?
<thizanne>
kakadu: you need to put it in an object or a record
<companion_cube>
let foo: type a. (a -> bool) -> int -> string -> bool = … ?
* kakadu
is trying...
zpe has joined #ocaml
<companion_cube>
ah right
<companion_cube>
you probably need a record indeed
ocaml709 has joined #ocaml
<thizanne>
(do you actually have a function 'a -> bool that does not return a constant ?)
<kakadu>
Yeah, doing some unsafe stuff :_
<ocaml709>
when using tuareg with emacs is there a way to look up symbols? i.e `>>=` is sort of difficult to google and i would like to see what it means
<Drup>
you can do it with merlin
<thizanne>
companion_cube: we need something like !poly for this question (and I can't find the doc entry again)
copy` has joined #ocaml
<companion_cube>
you can add it once you found it
Denommus has joined #ocaml
<ocaml709>
thanks, i think my merlin setup is broken. i get the auto complete but not the docs
<Algebr>
companion_cube: I meant type f = {foo : (module F...)}
<Algebr>
also merlin-document is great
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<companion_cube>
Algebr: hmm, never thought of that
snowcrshd has joined #ocaml
octachron has joined #ocaml
virtualeyes has quit [Ping timeout: 240 seconds]
virtualeyes has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
jao has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 258 seconds]
AltGr has left #ocaml [#ocaml]
al-damiri has joined #ocaml
william-s has joined #ocaml
dhil has joined #ocaml
slash^ has joined #ocaml
zpe has joined #ocaml
dhil has quit [Ping timeout: 260 seconds]
virtualeyes has quit [Ping timeout: 240 seconds]
virtualeyes has joined #ocaml
AlexDenisov has joined #ocaml
zpe has quit [Ping timeout: 255 seconds]
ygrek_ has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
hcarty has quit [Ping timeout: 255 seconds]
kakadu has quit [Quit: Konversation terminated!]
malc_ has joined #ocaml
srcerer has joined #ocaml
virtualeyes1 has joined #ocaml
moei has quit [Quit: Leaving...]
virtualeyes has quit [Ping timeout: 264 seconds]
sepp2k has quit [Ping timeout: 255 seconds]
virtualeyes1 has quit [Ping timeout: 248 seconds]
snowcrshd has quit [Ping timeout: 240 seconds]
kakadu has joined #ocaml
snowcrshd has joined #ocaml
hcarty has joined #ocaml
virtualeyes has joined #ocaml
ocalm_ has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
yomimono has quit [Ping timeout: 240 seconds]
malc_ has quit [Quit: ERC (IRC client for Emacs 25.0.50.2)]
hcarty1 has joined #ocaml
hcarty has quit [Ping timeout: 256 seconds]
yomimono has joined #ocaml
orbifx has joined #ocaml
fre has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
snowcrshd has quit [Remote host closed the connection]
breitenj has joined #ocaml
_andre has quit [Quit: leaving]
infinity0 has quit [Remote host closed the connection]
steve_gh has quit [Ping timeout: 260 seconds]
infinity0 has joined #ocaml
jnavila has joined #ocaml
lucasem has joined #ocaml
<lucasem>
Is there a way to explicitly set the types/objects included when using a module (so as not to clutter my scope)? Something like haskell's `import Mod (x,y)`?
<copy`>
lucasem: No, but we often write `let (x, y) = Mod.(x, y)`
<lucasem>
copy`: thanks! What about bringing in a type and its constructors?
vicfred has joined #ocaml
<copy`>
I don't think there is a nice way to do it, you can repeat the type definition
<copy`>
Or give the module a shorter name
Denommus has quit [Ping timeout: 255 seconds]
<companion_cube>
there's sth like ppx.import, I think
MercurialAlchemi has quit [Ping timeout: 258 seconds]
<lucasem>
hmmm.. if I repeat the type definition, how would compatibility work with a nearly-identical type in a module (nearly-identical meaning just different names)? Would I have to change the way I made calls using my new type with the module's expected use of its old type?
<companion_cube>
you can write `type t = Foo | Bar = Foo.t`
<lucasem>
companion_cube: I don't understand what's actually happening in that statement — could you explain?
breitenj has quit [Ping timeout: 240 seconds]
<companion_cube>
lucasem: you redefine the type t, but keeping it equal to Foo.t
<companion_cube>
type 'a my_option = None | Some of 'a = 'a option`
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
breitenj has joined #ocaml
yomimono has left #ocaml ["Leaving"]
yomimono has joined #ocaml
<lucasem>
companion_cube: I can't seem to avoid some syntax error... Is there another way to do it? Perhaps more explicitly?
<companion_cube>
might be `type 'a my_option = 'a option = None | Some of 'a`
<lucasem>
companion_cube: that works! This can rename the type, is there any way to rename the constructors?
<companion_cube>
sadly not
ocalm_ has quit [Ping timeout: 248 seconds]
smondet has joined #ocaml
th5 has quit []
infinity0 has quit [Remote host closed the connection]
obadz has quit [Ping timeout: 256 seconds]
infinity0 has joined #ocaml
infinity0 has quit [Changing host]
infinity0 has joined #ocaml
jrslepak has quit [Quit: leaving]
handlex has joined #ocaml
jrslepak has joined #ocaml
jrslepak has quit [Client Quit]
Flerex has joined #ocaml
obadz has joined #ocaml
yomimono has quit [Quit: Leaving]
jrslepak has joined #ocaml
handlex has quit [Quit: handlex]
jnavila has quit [Remote host closed the connection]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
<cheater>
but you could add a function
<cheater>
let blah a = None a
<cheater>
or rather
<cheater>
let blah = None
<cheater>
let blub a = Some a
<cheater>
if you really wanted :)
<cheater>
lucasem: ^
<cheater>
i mean renaming types and constructors is kind of pointless to me but it's fine
Ferwin has joined #ocaml
Ferwin has quit [Client Quit]
zv has joined #ocaml
<lucasem>
cheater: ah yes that makes sense. I'm doing it because I need to use a library that's poorly written, and I don't want to re-write it. I'm making an interface that basically prettifies and selectively exposes modules.
virtualeyes1 has joined #ocaml
Ferwin has joined #ocaml
<Drup>
lucasem: what's the library ?
Flerex has quit [Read error: Connection reset by peer]
Ferwin has quit [Client Quit]
<lucasem>
Drup: it's nothing big or popular. It's from a research project several years ago that I'm expanding upon. Scientists aren't all engineers!
handlex has joined #ocaml
<Drup>
fork and fix, then
<Drup>
(what's the name ? :D)
Flerex has joined #ocaml
virtualeyes has quit [Ping timeout: 240 seconds]
<lucasem>
(I don't want to shame the researcher! :P)
kakadu has quit [Remote host closed the connection]
<Drup>
I have seen enough terrible code by researcher, don't worry
<lucasem>
I'll make sure I get my changes pushed once I finish my work, though :)
<Drup>
and you're getting me curious x)
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Flerex has quit [Client Quit]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Client Quit]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Client Quit]
AlexDenisov has joined #ocaml
<octachron>
If only I had only "seen" terrible code by written by researcher (and not used nor … written some)
AlexDenisov has quit [Client Quit]
<companion_cube>
:D
<Drup>
octachron: same x)
<companion_cube>
let's all admit we wrote terrible code, and hope we don't any more
handlex has quit [Quit: handlex]
<jerith>
I'm not going to stop writing terrible code.
<Drup>
a few month ago, I stumbled upon the svn(!!) repository of my license class projects
<Drup>
it was terrifying
<companion_cube>
:D
<companion_cube>
fun fun
<Drup>
I wrote all of it
<thizanne>
SVN is nice already
<thizanne>
I used a POP3 repository
<jerith>
Or rather, I'm not going to stop writing code that I will later look at and find terrible.
<companion_cube>
I found a caml light file I wrote 10 years ago
<jerith>
Because if I do, it means I've stopped improving.
<companion_cube>
a symbolic derivation function
<companion_cube>
in french :D
int-e has left #ocaml ["too much information"]
<Drup>
companion_cube: my first Caml Light program, also in french, was a mandelbrot/julia plotter with graphics
<Drup>
(to be fair, the field is prone to frenchiness, so that's fair)
<jerith>
I pride myself on never having written any code in French.
<jerith>
(I'd have to learn French before I could do that.)
<companion_cube>
Drup: I'm going to make a pre-release for 1.0 :-)
<octachron>
jerith, I would'nt be so sure, avoiding valid french words in english takes some dedications
<Drup>
:D
<octachron>
(and avoiding words with french origin is a long long war)
wokalski has joined #ocaml
<wokalski>
hey, I would like to supply a file different than .c to C compiler when using ocamlopt. I have seen it discussed here https://caml.inria.fr/mantis/print_bug_page.php?bug_id=5823. It mentions however a specific file and therefore rises issues that the last comment mentions about.
<wokalski>
I imagine there could be a simple flag to allow pass anything to the compiler. Am I missing something?
rgrinberg has joined #ocaml
<Algebr>
wokalski: give the .c file, then for your ccopt tell -x c++ or -x ObjC++
<wokalski>
Algebr: Hm, interesting. What you are saying is that I should rename .cpp to .c, right? afaik it will work with c++, but won't with .m (objective-c).
<Algebr>
it will be taking .cpp cause underlying c compiler will let you but its legacy
<Algebr>
easiest thing for objc is to do -ccopt -ObjC++
larhat has quit [Quit: Leaving.]
Flerex has joined #ocaml
sillyotter has joined #ocaml
<wokalski>
I'm getting: ocamlopt: don't know what to do with file.m.
octachron has quit [Quit: Leaving]
sillyotter has quit [Client Quit]
wtetzner has joined #ocaml
<Algebr>
I said don't name it .m
Flerex has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<Algebr>
give it as .c, hence you're telling the underlying C compiler how to interpret the c source code sa
<wokalski>
ah, clever. Thanks!
orbifx has quit [Ping timeout: 240 seconds]
average has quit [Remote host closed the connection]