<coventry>
Actually, the question is more, why isn't I.t compatible?
<flux>
on line 5, remove ": S"
<flux>
the key here is that having that makes the type t abstract
<coventry>
flux: Thanks. I vaguely remember something like that from RWO... Any pointers on what to read to clarify that? In RWO or otherwise?
<flux>
sorry, I don't have any. actually I haven't coded in OCaml for a while :-o.
<coventry>
Ah, found it, "Making the Functor Abstract" in the Functors chapter.
<coventry>
Wait, that's not it.
<flux>
so basically what's happening is that module M : sig type t end = struct type t = int end makes the type 't' opaque outside the module M
<flux>
I mean abstract :-)
<coventry>
How is t more abstract without the ": S" constraint? What's abstract mean here, precisely?
<flux>
it means the same as you just write 'type t;;' in top level and then try to interact with the type
malina has joined #ocaml
<flux>
so you know nothing about the type but its name; you cannot create instances of it and you cannot unify it with other types
<flux>
there's also another way to express what you want but in a more precise manner
<flux>
instead of removing : S you can have : S with type t = T.t
<flux>
but I don't think this brings value in this case
<flux>
that's because (as you probably know), ocaml's module system isn't nominal (names being the significant differentiator between modules) but structural
<coventry>
Whereas with ": S", what do I know about the type?
<flux>
you know what the module type S tells you about it
<flux>
and nothing more
<flux>
so if the module type S were to provide some operations on t, it could actually be useful
ShalokShalom_ has joined #ocaml
<flux>
for example: module type Addable = sig type t val zero : t val add : t -> t -> t val equal : t -> t -> bool end
<coventry>
Oh, and then those operations in S could constrain the type? I think I see...
<flux>
and now if someone were to implement a module for that int, they could write: module IntAddable : Addable = struct type t = int .. end but you would never be able to tell that it's using 'int' internally
bruce_r has joined #ocaml
<flux>
and if they do want to expose the 'int', they can use the 'with'-syntax for rewriting parts of the signature: module IntAddable : Addable with type t = int = struct type t = int .. end
johnelse has joined #ocaml
<flux>
..but for simple scenarios it's the same as just dropping the ': S' altogether, though in that case the module type won't be checked, except perhaps later if it's being used as a functor argument
malina has quit [Quit: Throwing apples of Montserrat]
demonimin has quit [Remote host closed the connection]
demonimin has joined #ocaml
coventry has quit [Ping timeout: 240 seconds]
mfp__ has joined #ocaml
<flux>
oops, I just recalled the time lablqml had been part of lablqt, but that indeed must've been eons ago
johnelse has quit [Ping timeout: 240 seconds]
argent_smith has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
johnelse has joined #ocaml
cbot has quit [Quit: Leaving]
johnelse has quit [Ping timeout: 240 seconds]
kakadu has joined #ocaml
kakadu has quit [Client Quit]
kakadu has joined #ocaml
johnelse has joined #ocaml
argent_smith has quit [Quit: Leaving.]
johnelse has quit [Ping timeout: 240 seconds]
DrWhax_ is now known as DrWhax
Guest14530 has quit [Ping timeout: 248 seconds]
sam has joined #ocaml
sam is now known as Guest37165
johnelse has joined #ocaml
<peterpp>
I was going to iterate over a Core.Hashtbl and modify its values at the same time, but Core.Hashtbl.iteri and similar functions in the module all seem to throw an exception
johnelse has quit [Ping timeout: 246 seconds]
johnelse has joined #ocaml
<flux>
peterpp, you can use fold or map to collect the list of changes and then apply them afterwards
<peterpp>
at the moment I'm iterating over the list of keys and call Core.Hashtbl.change for each
<peterpp>
flux, ah, thanks
Guest37165 has quit [Ping timeout: 255 seconds]
sgnb has joined #ocaml
BitPuffin|osx has quit [Remote host closed the connection]
BitPuffin|osx has joined #ocaml
vramana has quit [Quit: vramana]
troydm has joined #ocaml
peterpp has quit [Ping timeout: 248 seconds]
sam has joined #ocaml
sam is now known as Guest85523
jnavila has joined #ocaml
samrat_ has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
magistr has joined #ocaml
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 240 seconds]
jnavila has quit [Remote host closed the connection]
kakadu has joined #ocaml
kakadu_ has quit [Ping timeout: 248 seconds]
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 248 seconds]
peterpp has joined #ocaml
Guest85523 has quit [Ping timeout: 240 seconds]
vramana has joined #ocaml
samrat_ has joined #ocaml
<kakadu_>
I remember a JaneStreet blog post about OCaml speed in general. I was made using light letters on black background. Can you help me to google it?
<flux>
but it seems the opposite is now desires :)
<Kakadu>
So, I did ignore @@ Sys.opaque_identity (-) a b
<Kakadu>
And now monomorphic compare is faster
<Kakadu>
poly/mono/minus related to 100/30/40
<Kakadu>
I got a result that I want. Thanks!
<copy_>
`Sys.opaque_identity (-) a b` might be slower than `a - b`, since it's an indirect call
<Kakadu>
no, it's fine
<Kakadu>
.cfi_startproc
<Kakadu>
L124:
<Kakadu>
subq▸ %rbx, %rax
<Kakadu>
incq▸ %rax
<Kakadu>
ret
<Kakadu>
.cfi_endproc
nomicflux has joined #ocaml
rwmjones has quit [Ping timeout: 246 seconds]
rwmjones has joined #ocaml
<copy_>
Okay
Guest62568 has quit [Ping timeout: 246 seconds]
bruce_r has joined #ocaml
companion_cube has left #ocaml ["WeeChat 1.0.1"]
nomicflux has quit [Quit: nomicflux]
coventry has joined #ocaml
ziyourenxiang has quit [Ping timeout: 255 seconds]
<coventry>
Are OCaml objects still used in contemporary software projects? Real-World OCaml has a chapter on them, but I haven't seen them mentioned anyhere else.
<coventry>
Everyone seems to be getting by just fine with modules and functors.
bruce_r has quit [Ping timeout: 255 seconds]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
bruce_r has joined #ocaml
companion_cube has joined #ocaml
nomicflux has joined #ocaml
jlam__ has joined #ocaml
jlam_ has quit [Ping timeout: 255 seconds]
bruce_r has quit [Ping timeout: 246 seconds]
nomicflux has quit [Quit: nomicflux]
sillyotter has joined #ocaml
<coventry>
RWO answers my question: "In fact, many seasoned OCaml programmers rarely use classes and objects, if at all."
nomicflux has joined #ocaml
sam has joined #ocaml
sam is now known as Guest86083
sillyotter has quit [Quit: WeeChat 1.4]
Guest86083 has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
nomicflux has quit [Quit: nomicflux]
<coventry>
What's an example of OCaml objects' support for row polymorphism? The google results for "row polymorphism" are super abstract.
<Drup>
coventry: object themselves are not used often
<Drup>
objects types, however, do have some users for typing trickeries
<coventry>
Thanks, Drup.
<coventry>
This explanation of row polymorphism gets pretty concrete on p. 9. Seems like it's basically duck typing. https://www.cs.cmu.edu/~neelk/rows.pdf
<Drup>
it's well-behaved duck typing ;)
<coventry>
That must be where the "row" in row polymorphism comes from: All your well-behaved ducks get in a row by themselves.
mengu has joined #ocaml
nomicflux has joined #ocaml
<Drup>
exactly
d0nn1e has joined #ocaml
coventry has quit [Ping timeout: 246 seconds]
peterpp has quit [Ping timeout: 248 seconds]
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 240 seconds]
cbot has joined #ocaml
enterprisey has joined #ocaml
sam has joined #ocaml
sam is now known as Guest11506
coventry has joined #ocaml
copy_ has quit [Quit: Connection closed for inactivity]
Guest11506 has quit [Ping timeout: 255 seconds]
peterpp has joined #ocaml
bruce_r has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
bruce_r has quit [Ping timeout: 246 seconds]
vramana_ has joined #ocaml
vramana has quit [Ping timeout: 240 seconds]
danieli has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 248 seconds]
sam has joined #ocaml
sam is now known as Guest72449
Guest72449 has quit [Ping timeout: 240 seconds]
nomicflux has quit [Quit: nomicflux]
<coventry>
Is there a tool for figuring out which package/filepath a module is defined in? Ideally a merlin command with an emacs binding? "find ~/.opam -name <lowercase-module-name>.mli" works in a pinch, but is slow.
<Drup>
coventry: odig has a command that does something like that
<Drup>
but it's a bit experimental yet
<coventry>
Thanks, will take a look.
samrat_ has quit [Ping timeout: 248 seconds]
enterprisey has quit [Ping timeout: 276 seconds]
<coventry>
Which odig command should I use to get the package providing a given module?
<coventry>
Oh, I see, you can load a module under it in the toplevel. Thanks again.
<Drup>
coventry: apparently, the functionally is present in the library, but not directly accessible in the API
<coventry>
Hmm, 'Odig.load "Json_module";;' gives "no object found to load, even though "type b = Json_schema.schema;;" works in the same toplevel.
<Drup>
it's used by `odig guess-deps`, though
<coventry>
Duh, Json_schema, not Json_module.
<coventry>
Great, that works nicely.
salc has joined #ocaml
enterprisey has joined #ocaml
nomicflux has joined #ocaml
sam has joined #ocaml
sam is now known as Guest21780
jmiven has quit [Quit: co'o]
Guest21780 has quit [Ping timeout: 240 seconds]
jmiven has joined #ocaml
ShalokShalom has quit [Remote host closed the connection]
enterprisey has quit [Ping timeout: 240 seconds]
<dogui>
is there any semantic difference between `let x : t = e` and `let (x : t) = e` ? I have some code that fails to compile in the second case with "The type of this expression .. contains type variables that cannot be generalized"
<dogui>
(trying to minimize it)
<Drup>
there shouldn't
<dogui>
yikes
<dogui>
huh, this doesn't happen on 4.05.0. I was on 4.02.3 before
<dogui>
guess I won't bother minimizing this
<dogui>
thanks Drup!
<Drup>
can you show the not-so-minimal version ?
<coventry>
What is the underscore doing in "type _ field = string;;"? Declaring anything of type "'a field" to be of type string?
<Drup>
but yeah, 4.02.3 is not-so-recent anymore :p
<Drup>
coventry: yes, unnamed type variable
<coventry>
Thanks.
<dogui>
Drup: it's dozens of files, in code I'm not really familiar with. The offending definition is simply `let (rkeys : (Prims.unit,kset,(Prims.unit,Prims.unit) mon_pkey) m_rref) = m_alloc keyRegion []`
<dogui>
(autogenerated code too)
<Drup>
yum
enterprisey has joined #ocaml
enterprisey has quit [Read error: Connection reset by peer]
nomicflux has quit [Quit: nomicflux]
<coventry>
Where in the manual can I find info about the ':>' operator? RWO only mentions it in the context of classes and objects, but here it seems to be used on a function: "| | Bytes kind -> (kind :> Kind.t)" at https://github.com/tezos/tezos/blob/master/src/minutils/data_encoding.ml#L191 (the declaration for Bytes is "type 'a desc = ... | Bytes : Kind.length -> MBytes.t desc | ...", on line 129 of that file.)
sam has joined #ocaml
sam is now known as Guest92889
<Drup>
it's called type coertion
<Drup>
coercions*
<coventry>
On the other hand, if I type "kind" in "| Bytes kind", I get that it's of Kind.length, which is a type not a function.
<Drup>
there isn't much to say about it, except in context with other constructions
<coventry>
What's going on in "| Bytes : Kind.length -> MBytes.t desc"? It looks like the type of the argument to Bytes ought to be a "Kind.length -> MBytes.t" function there, but instead it's just a "Kind.length".
Guest92889 has quit [Ping timeout: 240 seconds]
pierpa has joined #ocaml
<Drup>
that's a GADT
<Drup>
the syntax for constructors is slightly different
<Drup>
I warned you that tezos was not a beginner friendly codebase, and you just hit one of those head on :)