wtetzner has quit [Remote host closed the connection]
octachron has quit [Quit: Leaving]
Sim_n has quit [Quit: Leaving]
beise has quit [Ping timeout: 240 seconds]
wtetzner has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
orbifx1 has quit [Ping timeout: 240 seconds]
agarwal1975 has quit [Quit: agarwal1975]
silver has quit [Read error: Connection reset by peer]
nomicflux has quit [Quit: nomicflux]
<shon>
First order modules are amazing!
<shon>
Well, maybe that's over blown. You could probably accomlish the same thing with functorization. But they are pretty fun :)
<mengu>
wish there were ocaml screencasts
nomicflux has joined #ocaml
<P4Titan>
Hi again
<shon>
mengu: of live coding? Or what do you mean?
<P4Titan>
If I define a module w/ a functor and then implement an instance of that module
<mengu>
shon: can be live coding, can be a tutorial
cir has joined #ocaml
<P4Titan>
should I instantiate the module in the same file, and then export only it
<P4Titan>
because otherwise, I would have to export the functor definition, the module w/ the functor, and the functor instance module
<P4Titan>
What would be good practice?
vicfred has joined #ocaml
ziyourenxiang has joined #ocaml
infinity0 is now known as Guest80040
infinity0 has joined #ocaml
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
Guest80040 has quit [Ping timeout: 240 seconds]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
shinnya has quit [Ping timeout: 255 seconds]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
mfp has quit [Ping timeout: 255 seconds]
lucasem has left #ocaml [#ocaml]
mengu has quit [Quit: Leaving...]
FreeBirdLjj has joined #ocaml
<cheater>
does ocaml have sharing?
<cheater>
like if i have a list with 2000 tuples and each has the same value put in fst and snd will they be duplicates or will they be the same objects over and over?
<cheater>
also another question, if i have a type foo = Foo1 | Foo2, can I somehow do something like type bar = (int * Foo1) or something to that effect?
FreeBirdLjj has quit [Ping timeout: 240 seconds]
<P4Titan>
cheater: Note Foo1 is a constructor and not a type, its type is foo
<P4Titan>
so your tuple isn't good
<P4Titan>
from what I know at least
wtetzner has quit [Remote host closed the connection]
fre has quit [Ping timeout: 256 seconds]
<P4Titan>
On another note: I have a module with a functor once again. I implement the functor in which I create a variant type. Is there a way to access the constructors of that variant type through the larger module I'm implementing
<shon>
P4Titan: Yes. I think you can do that, so long as you expose the constructors in the signatures.
<shon>
(Or just don't have a signature, to leave everything exposed.)
omongo has joined #ocaml
omongo has quit [Client Quit]
copy` has quit [Quit: Connection closed for inactivity]
ygrek has quit [Ping timeout: 252 seconds]
govg has joined #ocaml
<cheater>
yes P4Titan i understand Foo1 is a constructor of type foo. i understand the difference. i would just like to somehow maybe create a new type that only contains Foo1, or something like that.
<cheater>
i've had another question. in my project, in foo_bar.ml i have module Baz = struct ... and so on. In quux.ml I try to refer to Foo_bar.Baz.my_function, but I am told that module Foo_bar.Baz is not bound. why would that be?
<shon>
P4Titan: I don't think you declare `bar` as you suggest there, because it isn't a type. What you can do to exert control over this kind of thing, i.e., when you want it so that some functions will only be given values matching (x:int, Foo1) and never ones matching (x:int, Foo2), you can jsut keep those functions sealed in a module, and not expose them for use.
<shon>
Sorry, that was for cheater.
<shon>
And my first sentence was meant to say: "I don't think you _can_ declare `bar` as you suggest there, precisely because `Foo1` isn't a type (as you know).
<shon>
cheater: for your first question, I'm pretty sure they will be same objects over and over.
<shon>
cheater: And for your last question, do you have a foo_bar.mli file?
<cheater>
shon: ok thanks
<cheater>
shon: yes, i do
<cheater>
shon: what about it?
<P4Titan>
well, you may not be exporting Baz correctly
<P4Titan>
@cheater
<cheater>
do i need to expose it manually? it's not mentioned in the .mli at all
<shon>
Exactly, you need to export modules just like you would export any other aspect of the program.
<shon>
Not mentioned means sealed inside.
<P4Titan>
^^^ that's why
<shon>
(Unless you have no signature at all, and then everything is exposed).
<P4Titan>
so you should do module Baz : sig ... end
<P4Titan>
and include the function and variable signatures of the stuff you would like exposed
<cheater>
ah
<cheater>
shon what does "no signature at all" mean?
<shon>
E.g., if you delete the .mli file (or rename it).
<P4Titan>
you don't have a .mli file
<P4Titan>
then ocaml automatically exposes everything
<cheater>
ah, right, ok
<cheater>
thanks guys
<shon>
(^_^)d
<P4Titan>
aye
vicfred has quit [Quit: Leaving]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
oschwald has quit [Quit: Leaving.]
fre has quit [Ping timeout: 240 seconds]
<cheater>
:)
vicfred has joined #ocaml
fre has joined #ocaml
<shon>
Anyone around who has experience with the acheck package??
nomicflux has quit [Quit: nomicflux]
ygrek has joined #ocaml
nomicflux has joined #ocaml
<cheater>
not me shon sorry :(
<cheater>
hey, if I have module Foo and inside it i define type bar... why would the compiler say the following? "This expression has type bar but an expression was expected of type Foo.bar"
ygrek has quit [Ping timeout: 248 seconds]
nomicflux has quit [Quit: nomicflux]
obadz has quit [Ping timeout: 240 seconds]
P4Titan has quit [Remote host closed the connection]
obadz has joined #ocaml
vicfred has quit [Ping timeout: 240 seconds]
fre has quit [Ping timeout: 240 seconds]
MercurialAlchemi has joined #ocaml
ygrek has joined #ocaml
vicfred has joined #ocaml
philtor has quit [Ping timeout: 276 seconds]
snhmib has quit [Ping timeout: 260 seconds]
fre has joined #ocaml
vicfred has quit [Quit: Leaving]
snhmib has joined #ocaml
infinity0 has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 245 seconds]
<flux>
cheater, do you maybe have two distinct bar types?
ocaml706 has joined #ocaml
Guest82 has joined #ocaml
ocaml706 has quit [Client Quit]
Guest82 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
zirman has quit [Ping timeout: 276 seconds]
MercurialAlchemi has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 248 seconds]
fre has quit [Ping timeout: 260 seconds]
hcarty has quit [Quit: WeeChat 1.5]
frefity has joined #ocaml
<frefity>
I'm struggling to get code completion to work using merlin after moving a submodule into its own file. While everything was in one file it worked without issues but now I can only see the module but no functions or values in the completion list
<frefity>
I'm using vscode
<companion_cube>
frefity: you might want to write a .merlin file! (it's on the merlin wiki)
<companion_cube>
(it's very easy)
<frefity>
I've already done that
<frefity>
I've included the current directory "S ." and "B _build/**"
<companion_cube>
ah! but have you built the project again?
<companion_cube>
for modules living in other files, merlin relies on .cmi (and other similar files)
<frefity>
yep
<companion_cube>
do you use/refer to the submodule anywhere? might not be built otherwise
<frefity>
I do, and I can see the sobmodule .cmi, .mli etc in the _build directory
snhmib has quit [Ping timeout: 240 seconds]
<frefity>
Initially I didn't have a .mli file for the submodule. I thought it might be that so I created one and exposed everything
<companion_cube>
no, it does not depend on the presence of .mli (a .cmi is created in any case)
<companion_cube>
I don't know then, sorry :/
<companion_cube>
(maybe try to restart merlin? but it's a unusual problem)
freusque has quit [Quit: WeeChat 1.6]
<frefity>
i've restarted merlin, restarted vscode and done a clean build. nothing helps ::(
<frefity>
thanks for your help. also, thanks for containers :)
<companion_cube>
:-)
freusque has joined #ocaml
beginner has joined #ocaml
<beginner>
i am trying to get a crip on locally abstract types. What is the difference between depth and depth2 in my minimal example http://pastebin.com/EpEv1Xu0
Simn has joined #ocaml
snhmib has joined #ocaml
alfredo has joined #ocaml
wokalski has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
AltGr has joined #ocaml
freusque has quit [Ping timeout: 264 seconds]
snhmib has quit [Read error: Connection reset by peer]
mpenet has joined #ocaml
larhat has joined #ocaml
TheLemonMan has joined #ocaml
<TheLemonMan>
does anyone have any experience with using Ocaml on a bare-metal ARM system? In my case it's not very 'bare' since I also have MbedOS available
<companion_cube>
no idea, really; maybe ask the mirageOS people?
<flux>
I only know of mrvn, but he was unable to make it work reliably
<companion_cube>
beginner: the first syntax is less powerful, I think; when you *really* need to quantify on a type (e.g. for GADTs) use the second syntax
snhmib has joined #ocaml
johnelse_ has joined #ocaml
mpenet has left #ocaml ["ERC (IRC client for Emacs 26.0.50.2)"]
johnelse has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
freusque has joined #ocaml
johnelse_ is now known as johnelse
<def`>
frefity: try just "B _build" :P
<frefity>
def`, I tried that too, didn't help
orbifx-m has joined #ocaml
<orbifx-m>
hello all
freusque has quit [Read error: No route to host]
<orbifx-m>
when using Pack: with oasis, is it possible to have a toplevel module, instead of all modules being under the toplevel?
<orbifx-m>
e.g. there is a top.ml and a.ml, can I have: open Top and open Top.A?
mengu has joined #ocaml
mengu has quit [Remote host closed the connection]
n4323 has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
<companion_cube>
not automatically
<companion_cube>
(unless there is no top.ml and you specify `Pack: true` in the corresponding library)
toolslive has joined #ocaml
mfp has joined #ocaml
n4323 has left #ocaml [#ocaml]
<wokalski>
hey, I'm seeing some possible regressions when building a cross compiler from trunk. The build is finished successfully but I can't run the products; I get bad cpu type. After investigating the issue on my own there's nothing obvious. I diffed build logs of 4.04.0 (which worked) and trunk version and they seem to be very very similar. Do you know about any changes which might impact my issue?
<orbifx-m>
so do I have to alias the modules in top.ml (seen a project do that) or is there an oasis driven way companion_cube ?
<companion_cube>
orbifx-m: "pack" is an oasis/ocaml/ocamlbuild-driven way
<companion_cube>
if you want a top.ml, you can write manually the `module A = A` … in top.ml
zpe has quit [Ping timeout: 252 seconds]
<orbifx-m>
yes because pack seems to only end up with Top.Top
beise has joined #ocaml
<companion_cube>
well indeed
<orbifx-m>
it can't choose one package as the top one, if I'm correct
<companion_cube>
I don't think so
freusque has joined #ocaml
mengu has joined #ocaml
<orbifx-m>
any recommendations on how to proceed? having aliases seems a hack
zpe has joined #ocaml
<companion_cube>
sorry, no
<companion_cube>
I usually go with pack for namespacing, bu then the pack only contains modules
n4323 has joined #ocaml
<orbifx-m>
think I'll just name my top one as 'core', or maybe 'common'. any conventions there?
<companion_cube>
not particularly
<companion_cube>
except in the JST world where they seem to call it Std
sepp2k has joined #ocaml
fre has joined #ocaml
<orbifx-m>
for standard?
<thizanne>
yeah that's probably not for the other common acronym
<Leonidas>
I think Core.Std is being replaced by just Core.
<Leonidas>
at least I saw yminsky tweet about it
fre has quit [Read error: No route to host]
toolslive has left #ocaml ["ERC (IRC client for Emacs 25.1.1)"]
jnavila has joined #ocaml
fre has joined #ocaml
snowcrshd has joined #ocaml
<orbifx-m>
Leonidas: how will they implement that?
<companion_cube>
Leonidas: heh :D
<companion_cube>
they don't have problems with breaking compat, it seems
<flux>
could keep an alias around?
<flux>
in general ocaml world is not super in keeping source compatibility ;-)
<companion_cube>
hu, my experience is the opposite
<companion_cube>
many libraries care about backward compat
<orbifx-m>
companion_cube: if I make my top a nested module, and therefore have no ml file named after the library, the setup complains that it cannot find a source file matching the library name
<orbifx-m>
flux: I too agree with companion_cube, especially when it comes to the standard library
<companion_cube>
orbifx-m: wait, if you manually write the aliases in top.ml… then you have top.ml?
<orbifx-m>
I didn't write the aliases. decided to make everything nested
<orbifx-m>
so I moved top.ml to core.ml. Say the library is called foo, it warns that it can't find a matching module named 'foo' in library foo.
_andre has joined #ocaml
steve_gh has joined #ocaml
<orbifx-m>
So does it actually make a parent module?
mengu has quit [Remote host closed the connection]
<companion_cube>
have you tried `make clean` first?
<companion_cube>
many of these warnings usually come from stale build files that shouldn't exist anymore
<orbifx-m>
I did
<orbifx-m>
distclean too
<orbifx-m>
ill try again
<orbifx-m>
I'll manually delete everything
dhil has joined #ocaml
<companion_cube>
hmmm
<companion_cube>
so you have Pack: true in the oasis file? did you setup again?
<orbifx-m>
yeah I do
<orbifx-m>
let me do it all again, for certainty
<steve_gh>
Hi. Can I declare a function to take an argument matching an interface signature, rather than a type. The purpose would be to enable a module function to take an argument that matches the interface of a nested module, not just the type of the nested module.
<steve_gh>
So if I have function S(V) = struct type v module T : T_intf with type t=V.t ...
Muzer has quit [Ping timeout: 256 seconds]
<steve_gh>
I would like a function foo which takes an argument that matches the signature T_intf rather than T.t.
<companion_cube>
orbifx-m: also, when oasis/ocamlbuild complains, you can take a look at _build/_log
<companion_cube>
sorry I can't help you more
fre has quit [Ping timeout: 240 seconds]
<steve_gh>
That would enable foo to take an argument of a module that included T(V) rather than of type T(V)
<companion_cube>
wait, you want to pass modules as parameters to functions, is that it?
<orbifx-m>
thanks companion_cube
<steve_gh>
Hi companion_cube. I want a function to take an argument that matches an interface, rather than of a particular type.
<steve_gh>
I have a functor T(V) with sig T_intf. I have second functor S(V) = struct TT = T(V) type tt = TT.t ...
<steve_gh>
So far, so good: TT has interface T_intf with the appropriate external type.
<steve_gh>
I also have another module X = struct include T(V) ... end. So X maps onto T_intf, based on the same module type V, but is of course a different type to TT
<steve_gh>
What I would like is to define a function within functor S that will take an argument that obeys T_intf with module type V, so I could pass an argument either of type TT, or of type X
Muzer has joined #ocaml
beise has quit [Ping timeout: 258 seconds]
wokalski has quit [Quit: Page closed]
silver has joined #ocaml
beise has joined #ocaml
steve_gh has quit [Ping timeout: 260 seconds]
mengu has joined #ocaml
malc_ has joined #ocaml
<companion_cube>
functions don't take interfaces
<companion_cube>
they take types
<companion_cube>
only functors can take (module) interfaces
beise has quit [Quit: WeeChat 1.4]
<companion_cube>
(if we ignore first-class modules, I doubt that's what you're looking for)
<companion_cube>
ah damn
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
jao has quit [Read error: Connection reset by peer]
zpe has quit [Ping timeout: 264 seconds]
jao has joined #ocaml
zpe has joined #ocaml
<cheater>
flux, i don't think so! but this project is very complex, so maybe.
fre has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
<frefity>
Can anyone recommend some idiomatic ocaml code to learn from? Ideally code that doesn't resort to fancy tricks just for the sake of it and puts an emphasis on readability / maintainability
dhil has joined #ocaml
two_wheels has joined #ocaml
fre has quit [Read error: Connection reset by peer]
<companion_cube>
some Bünzli libs, maybe
nomicflux has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
<frefity>
thanks
zpe has quit [Ping timeout: 264 seconds]
fre has joined #ocaml
larhat has quit [Quit: Leaving.]
xavierbot has joined #ocaml
<xavierbot>
OCaml version 4.04.0
<xavierbot>
Camlp4 Parsing version 4.04.0
xavierbot has quit [Remote host closed the connection]
<companion_cube>
:D
<companion_cube>
too verbose?
xavierbot has joined #ocaml
<xavierbot>
OCaml version 4.04.0
<xavierbot>
Camlp4 Parsing version 4.04.0
dhil has quit [Ping timeout: 240 seconds]
<companion_cube>
> 1+1;;
<xavierbot>
Characters 0-1:
<xavierbot>
> 1+1;;
xavierbot has quit [Remote host closed the connection]
<P4Titan>
My question is: I would want to use ImplType to construct the type `t` to keep things unified, but I cannot seem to do so
octachron has joined #ocaml
<Drup>
P4Titan: what's the content of MkType ?
<Drup>
well, it doesn't matter much: if you want to re-expose the constructor, you need to know them exactly. If t is abstract in the imput signature SomeType, you can't
P4Titan has quit [Read error: Connection reset by peer]
P4Titan has joined #ocaml
<P4Titan>
The contents of `MkType` are simply functions that work with type `t`
slash^ has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
Xadnem has joined #ocaml
<tvynr>
I compiled my code with "ocamlfind ocamlc -g ...", but every time I try to issue a break in ocamldebug, I get "Can't find any event there.". Google hasn't been much help; the question has been asked but not answered. Any thoughts?
<tvynr>
Nevermind. For the record, this can happen if the module in question doesn't get linked into the binary. :(
al-damiri has quit [Quit: Connection closed for inactivity]
mengu_ has quit [Remote host closed the connection]
_andre has quit [Quit: leaving]
kakadu has quit [Remote host closed the connection]
octachron has joined #ocaml
jnavila has joined #ocaml
Xadnem has quit [Quit: Lost terminal]
malc_ has quit [Remote host closed the connection]
sh0t has quit [Ping timeout: 240 seconds]
snowcrshd has quit [Ping timeout: 240 seconds]
mengu has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
moei has quit [Quit: Leaving...]
jnavila has joined #ocaml
jerme is now known as jerme_
jnavila has quit [Ping timeout: 252 seconds]
ygrek has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
ygrek_ has joined #ocaml
steve_gh has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
ygrek_ has quit [Remote host closed the connection]
<steve_gh>
Looking for a good tutorial on generic types. When I see a type definition like type 'a t, how should I read it ? t is the type of a generic type a ?
<companion_cube>
`'a t` is a type `t` parametrized by `'a`
<companion_cube>
e.g.: `'a list` is a list of elements of type 'a
<companion_cube>
'a option list (read: ('a option) list), a list of options of 'a
<steve_gh>
Hi companion_cube, so (and this comes back to my question from earlier today) can I restrict 'a to matching an interface, something like ('a : A_intf) t ?
<companion_cube>
steve_gh: so, what you ask for, again, doesn't make sense
ygrek has quit [Ping timeout: 256 seconds]
<companion_cube>
you would like 'a to be a type that satisfies Map.Ord, or something like that, maybe?
th5 has quit []
<steve_gh>
forgive me, I've been mainly coding in ruby for 15 years, so I've been doing a lot of duck typing
zpe has joined #ocaml
<companion_cube>
no pb
ygrek has joined #ocaml
<steve_gh>
I think so, so if Map.Ord builds a Map from an Ordered_type Ord, I presume that Map.Ord has some module type built off Ord. So Yes, I would like an 'a which is constrained to any type that satisfies Map.Ord
<zozozo>
maybe you simply want a functor ?
<companion_cube>
steve_gh: you can't
<steve_gh>
Hi zozozo, I have functors :-)
<companion_cube>
what you want is indeed a functor
<companion_cube>
the functor can take an argument satisfying a signature
<companion_cube>
but a mere function can just be polymorphic, not depend on a signature
yomimono has joined #ocaml
<steve_gh>
Yeah this seems to be the problem. I have a functor S(V), which in turn instantiates a module T (with type t) via functor T(V). I also use the functor T in an include statement within module X, so I have module X = struct include T(V) end.
<zozozo>
why not module X = T(V) ?
<steve_gh>
What I want to be able to do is spectify a function foo within functor S that takes an argument that must match the signature of T(V), so it could be a T, or it could be an X
<companion_cube>
the argument is a value
<companion_cube>
not a module
<companion_cube>
you're totally confusing values and modules
<companion_cube>
I mean that functions' arguments are values
<companion_cube>
functors' arguments are modules
<companion_cube>
you cannot mix
tvynr has quit [Ping timeout: 252 seconds]
<steve_gh>
zozozo: X has aditional functionality to T(V). So in reality, T is a functor that creates a state transition table, across a module type V. X adds additional functionality (for example different means of generating the functionality)
<steve_gh>
So when I apply it, I'm interested simply in the T(V) part of it's functionality, not the additional stuff that defines how to buid it
<zozozo>
ok, still companion_cube is right
<steve_gh>
companion_cube. The signature of foo would currently be val foo : T.t -> ... The problem I have is that I want foo to be able to use anything that can take something that matches the T_intf with appropriate functor argument
<companion_cube>
like T.t?
<octachron>
steve_gh, if I understand correctly, you have a "module type S = struct type t val f: t -> t end", and you would want to be able to write something like "let g (x: s.t) = f x"
<octachron>
i.e. pull functions from the signature/interface ?
orbifx1 has quit [Ping timeout: 248 seconds]
<steve_gh>
Yeah, but I want to be able to call foo with an arg of type T.t, or alternatively with type X.t, since I have defined T = T(V), and module X = struct include T(V) end
ygrek_ has joined #ocaml
<steve_gh>
and I'm struggling to work out how to do it
ygrek has quit [Ping timeout: 276 seconds]
<companion_cube>
why not X = T?
<octachron>
steve_gh, well X.t = T.t so any function working with one will work with the other
<steve_gh>
companion cube: more precisely module X = struct include T(V) let bar t = ... end
<companion_cube>
ah
<companion_cube>
but T(V) defines its type `t` in terms of `V`?
<companion_cube>
(if yes, it means X.t = T.t anyway)
<steve_gh>
so X has additional functionality. That makes the compiler complain !
<steve_gh>
That's exactly what I am trying to achieve :-) When I define foo : T.t -> ..., I want the compiler to recognise that under the hood T.t and X.t are the same type, because they both derive from T(V)
<companion_cube>
why not `X = struct include T … end`?
<companion_cube>
then you're worrying about the wrong place
<companion_cube>
you need to ensure X.t = T.t
<companion_cube>
for this, you either need: (i) that X uses T directly, or (ii) that every application T(V) returns the same type
<companion_cube>
(for instance, Map.Make(String) always returns the same type)
MercurialAlchemi has quit [Ping timeout: 260 seconds]
<steve_gh>
I can apply T(V) in two ways. I can nest it: module T = T(V), or I can extend it: module X = struct include T(V) end.
<companion_cube>
my remark still applies
<steve_gh>
If T(V) defines type t, then I am trying to define a function foo, which accepts an argument of type t, regardless of whether t has come via a nested or an extended route
ygrek_ has quit [Remote host closed the connection]
ygrek has joined #ocaml
ygrek_ has joined #ocaml
fre has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
orbifx1 has joined #ocaml
<octachron>
steve_gh, the point is that a function cannot even make the difference between the two route
<steve_gh>
hi octachron. Not quit sure what you mean, are you saying that the function cannot distinguish between the 2 routes, or that there is no way that the function can cope with both routes?
<octachron>
steve_gh, a function cannot distinguish between the two routes
<octachron>
i.e., if you have a function of type "val f : t -> 'something", all the function knows is that its first argument has for type t. There is no module level information here
yomimono has quit [Ping timeout: 252 seconds]
mengu has quit [Ping timeout: 245 seconds]
zpe has quit [Remote host closed the connection]
mengu has joined #ocaml
<steve_gh>
maybe another tack: so functor S(V) = struct module T = T(V) type t = T.t let foo t-> ... end, and module X = struct include T(V) ... end
ygrek has joined #ocaml
zpe has joined #ocaml
ygrek_ has quit [Remote host closed the connection]
<steve_gh>
Can I do some sort of higher order magic like module S = S(V) with type T.t = X.t
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
<companion_cube>
look at what Map.Make doesn
<companion_cube>
-n
mengu_ has joined #ocaml
mengu has quit [Ping timeout: 255 seconds]
Sim_n has joined #ocaml
<Drup>
I'm smelling an XY problem
zpe_ has joined #ocaml
<Drup>
steve_gh: what are you trying to achieve, concretely ?
<companion_cube>
Drup: :D
zpe has quit [Ping timeout: 252 seconds]
<octachron>
steve_gh, do you have any code example? It would help
<Drup>
companion_cube: tbf, "I have programmed in Ruby for 15 years" was a bit hint
<Drup>
big*
zpe_ has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 248 seconds]
Simn has quit [Ping timeout: 255 seconds]
<steve_gh>
Drup. To be fair, ruby has been my main language for 15 years after I ran away from C++. I still also do a bit of C, and have dabbled in Erlang. I once did a course in lambda calculus whiel doing my undergraduate philosophy degree, but in my defense, I was very, very drunk at the time!
zpe has joined #ocaml
<steve_gh>
But seriously, I'll put together a (simpified) concrete code example that boils the problem down, and hope to be able to share it with you either tomorrow or Thurs.
<Drup>
lambda calculus is like C++, it's much more pleasant to use it drunk
<steve_gh>
ROTFL!
<Drup>
steve_gh: what I would like is what you are really trying to do, not how you think it should be solved
<Drup>
surprisingly, there is no wikipedia article
<steve_gh>
Drup - understand XY problems. Let's se if I can put it simply. V is a value (Floatable say). From V I create functors D(V) (a prob distribution over V's), T(V) (a transition table over V's), and eventually S(V), a slice of V's (date * D(V) ). Within a slice I need a function next (called foo in the thread above) which will map a slice and a transition table (~tbl) into a slice on the next point in time.
<steve_gh>
What I care about is that the ~tbl argument to next matches the signature of T(V), i.e. that it is a transition table on V's.
<steve_gh>
At the moment I generate the type of ~tbl via a nested module T =T(V). But I want to be able to use anything that matches the signature of T(V). So in the thread, module X = struct include T(V) ... end is actually a lattice structure, so we generate a transition table T(V) with a particular and individual build function
agarwal1975 has quit [Quit: agarwal1975]
<steve_gh>
So within S(V), I know that next has an argument ~tbl that must match the signature of T(V), but I can't necessarily list them all within S(V)
<steve_gh>
.. and that is the problem I am trying to solve :-)
<octachron>
steve_gh, this sounds like an extremely complex implementation of discrete Markov chain
<Drup>
this all sound not particularly difficult. Put next inside a functor that takes (at least) two arguments, V and T(V) and next will be of type V.t -> T(V).t -> V.t
P4Titan has joined #ocaml
<P4Titan>
Hi again. I'm sorry for asking frequently
agarwal1975 has joined #ocaml
<P4Titan>
But I have a module type, in which I want to require a module
larhat has quit [Quit: Leaving.]
<Drup>
"require" ?
<P4Titan>
want the module implementing said functor, to define this module
<P4Titan>
that has the signature asked for
<P4Titan>
like a functor for a module type?
<Drup>
ah, right, you want a function over signatures
<P4Titan>
sure?
<Drup>
you can't do that :D
<P4Titan>
do what?
<P4Titan>
what I want to do?
<Drup>
P4Titan: you can't have functions over signatures. Can you show a code example of what you tried ?
<P4Titan>
sure
<steve_gh>
<ochtachron> The discrete markov chain is a starting point, but the end goal is a lot more complex. Think something like an implementation of the Peyton-Jones paper on compositional contracts, but with functionality required that would get you 15-20 if you tried it in the financial sector!
<Drup>
the usual way is to do like in the Map, module. Map.Make returns a module of type Map.S, which you can use in your signatures
ansiwen has quit [Ping timeout: 258 seconds]
govg has quit [Ping timeout: 240 seconds]
ansiwen has joined #ocaml
<P4Titan>
what do you mean exactly?
<steve_gh>
Folks, thank you all for you help. I'm going to go and think about how to improve my implementation, and try and cool my brain off (Chardonnay ?)
<Drup>
you can see that it exposes a module type S and a functor "Make" whose signature is simply `module Make (Ord : OrderedType) = S with type key = Ord.t`
<Drup>
do the same thing, and then you will be able to have `module Serial : Serialize.S with type t = packet`
<P4Titan>
you're saying I can have that in the functor I'm implementing, the first haste
<Drup>
yes
<P4Titan>
so what I should do is make MkSeriazable return a type
<Drup>
no, you don't change MkSerializable
<P4Titan>
ok
<Drup>
You just write down it's return type and expose it
<P4Titan>
and the fact it takes a functor doesn't affect anything?
<Drup>
P4Titan: go look at the map module
<P4Titan>
yes, will do
<Drup>
really look, you're doing the exact same thing
<Drup>
(at least, the same API)
<P4Titan>
are the entries in the documentation you linked me to valid signatures
<P4Titan>
just curious, since module Make:
<P4Titan>
functor (Ord : OrderedType) -> S with type key = Ord.t
<P4Titan>
looks unfamiliar
<Drup>
"module M (X:S) = T" ≡ "module M = functor (X:S) -> T"
<Drup>
s/=/:/
<P4Titan>
ok, I'll look into this now
<P4Titan>
Thanks!
yomimono has joined #ocaml
ygrek_ has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
mengu has joined #ocaml
f[x] has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
ygrek_ has quit [Remote host closed the connection]
mengu_ has quit [Ping timeout: 258 seconds]
orbifx has joined #ocaml
zpe has quit [Ping timeout: 258 seconds]
snowcrshd has joined #ocaml
* Drup
is playing the new game "adding topics to github repositories"
f[x] has quit [Ping timeout: 252 seconds]
yomimono has quit [Ping timeout: 256 seconds]
P4Titan has quit [Ping timeout: 240 seconds]
fre has quit [Quit: WeeChat 1.4]
Sim_n has quit [Quit: Leaving]
steve_gh has quit [Ping timeout: 260 seconds]
octachron has quit [Quit: Leaving]
f[x] has joined #ocaml
agarwal1975 has quit [Quit: agarwal1975]
jlongster has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]