<ggole>
keep_learning: if you used C-C C-b to load avl.ml it won't be bound under the name Avl
<ggole>
You can use #mod_use "avl.ml";; to do that
initiumdoeslinux has joined #ocaml
<keep_learning_M>
ggole, Thank you very much.
<keep_learning_M>
I am wondering what is difference between #require, #use and #mod_use.
<keep_learning_M>
I was trying #use "avl.ml" ;; but it did not worked.
initiumdoeslinux has quit [Ping timeout: 250 seconds]
<ggole>
#use essentially copies a source file into the toplevel
<ggole>
The filename is ignored, eg, it is not used to create a module
<ggole>
#mod_use does the same thing, but places the definitions in a module based on the filename.
<ggole>
#require loads ocamlfind packages.
<ggole>
Usually those will be compiled bytecode.
<ggole>
C-c C-b and #use are pretty close in functionality, by the way.
<keep_learning_M>
Also I am wondering if there is tool which takes care of all these thing. I like to do development in interactive mode. I am already using Merlin + Tuareg + utop.
<ggole>
If you have a larger project it can be useful to use the build system to create toplevels with everything already loaded
<ggole>
For tiny or throwaway multi-file projects you can also write init files and start the toplevel with -init
<keep_learning_M>
Thank you very much. I will take a look at Ocaml projects at github and see how they are organised. Seem like dune is the thing I am looking for https://dune.build/ ?
<ggole>
Several build systems are in use in the OCaml ecosystem. Dune is a reasonable choice, but be aware that if you look up a random OCaml project, it may not use Dune.
<keep_learning_M>
Can you point me to some OCaml project which follows "build system to create toplevels with everything already loaded".
<ggole>
Hmm... I can't think of any off the top of my head.
<keep_learning_M>
ggole, Thanks again. I think it's good starting point.
<ggole>
Yeah, np
_whitelogger has joined #ocaml
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 244 seconds]
iovec has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
Jeanne-Kamikaze has quit [Quit: Leaving]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 268 seconds]
fraxamo has joined #ocaml
gravicappa has quit [Ping timeout: 250 seconds]
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
sonologico has joined #ocaml
gravicappa has joined #ocaml
iovec has quit [Quit: Connection closed for inactivity]
gravicappa has quit [Ping timeout: 272 seconds]
pierpal has quit [Ping timeout: 250 seconds]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
mfp has joined #ocaml
initiumdoeslinux has joined #ocaml
jao has joined #ocaml
jnavila has joined #ocaml
bartholin has joined #ocaml
jao has quit [Ping timeout: 268 seconds]
gravicappa has joined #ocaml
steenuil has quit [Remote host closed the connection]
rain1 has joined #ocaml
rain2 has quit [Ping timeout: 245 seconds]
jnavila has quit [Ping timeout: 250 seconds]
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
iovec has joined #ocaml
initiumdoeslinux has quit [Remote host closed the connection]
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
initiumdoeslinux has joined #ocaml
Haudegen has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 250 seconds]
estrom has joined #ocaml
jun_ has joined #ocaml
initiumdoeslinux has joined #ocaml
jun has quit [Quit: WeeChat 1.6]
jun_ has quit [Client Quit]
jun has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 240 seconds]
slamzy has joined #ocaml
slamzy has quit [Ping timeout: 256 seconds]
gravicappa has quit [Read error: Connection reset by peer]
gravicappa has joined #ocaml
mengu has joined #ocaml
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 244 seconds]
sonologico has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 246 seconds]
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 246 seconds]
estrom has quit [Remote host closed the connection]
mfp has quit [Ping timeout: 268 seconds]
Haudegen has joined #ocaml
gravicappa has quit [Read error: Connection reset by peer]
gravicappa has joined #ocaml
mfp has joined #ocaml
zozozo has quit [Ping timeout: 252 seconds]
zozozo has joined #ocaml
marvin2 has quit [Ping timeout: 246 seconds]
mengu has quit [Quit: Leaving...]
jnavila has joined #ocaml
<quarters>
hello. I'm going through the tutorial on try.ocamlpro.com and see it testing for information not introduced and was wondering where I can get this information, namely lesson 5 step 4 around let
kakadu_ has quit [Remote host closed the connection]
powerbit has quit [Ping timeout: 250 seconds]
<quarters>
I'm also confused about what 'a is a reference to since all the docs that I've looked at use in but don't describe what it is the way other types like int and string are described including here: http://caml.inria.fr/pub/docs/manual-ocaml/coreexamples.html
initiumdoeslinux has joined #ocaml
<ggole>
'a is a type variable
<quarters>
try.ocamlpro.com makes a distinction between lists and arrays but doesn't go into either the fundamental differences between the two or use cases
<tautologico>
quarters: 'a is a type variable, similar to type parameters <T> in languages like C++ or Java, if you're familiar with them (similar but not quite the same)
<quarters>
ggole, tautologico ty!
<tautologico>
so for example 'a list is a generic list where 'a can be "any type"
<tautologico>
we say 'a list is a polymorphic list
initiumdoeslinux has quit [Ping timeout: 246 seconds]
jnavila has quit [Ping timeout: 246 seconds]
<quarters>
I'm only familiar with a definition of polymorphism that describes the way subclasses can override methods or properties of its superclass in oop and am struggling to square that wiht how that word is used with ocaml
<ggole>
Yes, the same word is used to describe fairly different things
<octachron>
This is a different kind of polymorphism: the one that you are talking about is subtype polymorphism, and Ocaml is more oriented towards parametric polymorphism
<ggole>
Just follow your tutorial or textbook or whatever and it will naturally become (more or less) clear what polymorphism means in ML
<quarters>
gotcha
<quarters>
I also reckon that type variables are hardly used due to type inference?
<ggole>
They are heavily used in type definitions
<octachron>
I am not sure if try.ocamlpro.com makes a very good introduction. Did you have a look at real world ocaml too ((or maybe the manual))?
<ggole>
But for code, yeah, you only need them occasionally
<quarters>
octachron, I opted for try.ocamlpro.com due to the expected instant feedback I'd get, but I may need to pivot to the two resources you referenced
<quarters>
ggole, awesome
<_y>
depends, you can give explicit typing annotations
<octachron>
quarters, note that if you want a web repl there is also https://sketch.sh
<quarters>
octachron, ty
estrom has joined #ocaml
<_y>
and actually i strive more and more towards thinking that leaving everything to type inference is a terrible idea
<_y>
and that you should at least annotate functions’ parameters and return type
<_y>
just as you do anyway when exporting values in a module
estrom has quit [Client Quit]
estrom_ has joined #ocaml
estrom_ has quit [Client Quit]
estrom has joined #ocaml
<ggole>
For readability, or to make type errors make more sense?
<_y>
both
<companion_cube>
_y: I've been doing that for a while, too
<companion_cube>
best part is that you can still leave holes with `_` if you don't want to spell out the whole type
<ggole>
I've only found annotations helpful when writing let rec
<_y>
also because of type synonyms
<companion_cube>
ggole: I find the code more readable with annotations
<ggole>
Hmm.
<_y>
for example recently i did «type word = string» and wrote a bunch of functions about words, lists of words and so on
<ggole>
Maybe I'll experiment with that at some point.
<ggole>
Unfortunately the syntax for annotations is pretty gross
<_y>
type inference would have deduced types speaking of «string», while i would like them to speak of «word»
<companion_cube>
the syntax is fine
<companion_cube>
I use `let f (x:a) (y:b) : c = …` generally, it's nice
<ggole>
Type variables aren't rigid that way, though
<ggole>
Although maybe it doesn't matter much if you just want to read them.
<_y>
otherwise i have less meaningfull error messages, and i wouldn’t catch induced errors if at some point i changed the definition of word to something else (bytes ? char list ?), since the functions would still deal with strings
<companion_cube>
right, if you want universal quantification it indeed becomes uglier
<_y>
i like the syntax «let f (type a) (x : a) : a list = [ x ]»
<_y>
that way the quantified type looks like an actual parameter, just like in System F or Coq
<ggole>
I'm not sure about using locally abstract types in that way, since (type t) usually indicates GADT stuff is going on
<ggole>
I think I would prefer to reserve it for when it is needed.
<companion_cube>
speaking of which, it'd be real cool to have `(x y z : a)` as a syntax for multiple variables' type annotation
<_y>
yeah
<Armael>
:)
Armael has quit [Quit: WeeChat 2.1]
<ggole>
companion_cube: that would be nice for wordy types
<_y>
but this would probably be a parsing hell, wouldn’t it ?
Jesin has quit [Quit: Leaving]
<companion_cube>
very likely yes :D
<_y>
I mean, speaking as the guy who tried to lint type expressions in vim
<companion_cube>
anyway, annotating types takes only a bit more time, and imho it helps when reading the code, so it's helpful
<_y>
yeah, to me typing is comparable to invariants, preconditions, postconditions
<_y>
and implicit typing is like all those implicit assumptions disseminated in a codebase
<_y>
if as the writer of the code, you know what the type should be, then you’d better write it so that others know it without question, too
<ggole>
It varies a bit. (xs : foo option list) is somewhat helpful: (block : block) less so.
<companion_cube>
sure
<companion_cube>
you don't have to annotate everything
<companion_cube>
especially not the very short helper functions
<companion_cube>
but typically I like to at least put the return type
<quarters>
I was wondering how to bind the type (the stuff output by repls when using let) of an expression to a variable
gravicappa has quit [Ping timeout: 246 seconds]
<companion_cube>
let x: a = …
jnavila has joined #ocaml
kalio has quit [Quit: WeeChat 2.3]
gravicappa has joined #ocaml
kakadu has joined #ocaml
gravicappa has quit [Remote host closed the connection]
<quarters>
I was wondering if this is illegal and the likely way to fix this would be to change the 1 to Some 1: let a = [("a", None); ("b", 1)]
<ggole>
quarters: that sounds right
<quarters>
ggole, ty
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
initiumdoeslinux has joined #ocaml
ggole has quit [Quit: ggole]
initiumdoeslinux has quit [Ping timeout: 268 seconds]
Jesin has joined #ocaml
gareppa has joined #ocaml
gareppa has quit [Max SendQ exceeded]
gareppa has joined #ocaml
sonologico has joined #ocaml
<estrom>
are structures like the monad used in ocaml?
kalio has joined #ocaml
igitoor has quit [Remote host closed the connection]
marvin2 has joined #ocaml
<quarters>
when swift is described as fruit-flavored ocaml, does that mean that swift is also an ml?
Armael has joined #ocaml
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 250 seconds]
fraxamo has quit [Quit: Leaving]
gareppa has quit [Quit: Leaving]
nullifidian_ has joined #ocaml
nullifidian__ has quit [Ping timeout: 244 seconds]
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 268 seconds]
jao has joined #ocaml
jao has quit [Ping timeout: 250 seconds]
jnavila has quit [Ping timeout: 252 seconds]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
estrom has quit [Remote host closed the connection]
steenuil has joined #ocaml
powerbit has joined #ocaml
initiumdoeslinux has joined #ocaml
initiumdoeslinux has quit [Ping timeout: 246 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
estrom has joined #ocaml
bartholin has quit [Remote host closed the connection]
kakadu has quit [Remote host closed the connection]
recj has quit [Quit: Lost terminal]
estrom has quit [Remote host closed the connection]