<flux>
farewell, ocaml.io, we didn't even know you :/
nicholasf has quit [Remote host closed the connection]
soupault has quit [Ping timeout: 276 seconds]
regnat[m] has quit [Read error: Connection reset by peer]
srenatus[m] has quit [Read error: Connection reset by peer]
Bluddy[m] has quit [Read error: Connection reset by peer]
lpw25[m] has quit [Read error: Connection reset by peer]
barkmadley[m] has quit [Read error: Connection reset by peer]
M-pesterhazy has quit [Read error: Connection reset by peer]
M-ErkkiSeppl has quit [Remote host closed the connection]
M-jimt has quit [Write error: Connection reset by peer]
M-Illandan has quit [Write error: Connection reset by peer]
M-martinklepsch has quit [Write error: Connection reset by peer]
llmn has joined #ocaml
nicholasf has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
nicholas_ has joined #ocaml
nicholasf has quit [Ping timeout: 250 seconds]
jstolarek has quit [Ping timeout: 272 seconds]
wu_ng has quit [Ping timeout: 248 seconds]
kamog has joined #ocaml
FreeBirdLjj has joined #ocaml
Merv has joined #ocaml
<dxtr>
So I might start reading Real World Ocaml this evening and learn the language
<dxtr>
"might" because it depends on when the kids fall asleep and stuff :p
<Khady>
Have fun :)
<dxtr>
There are some things that have put me off for a few months (Mainly the mutable stuff) but right now I feel like I should just get over it and give it a go
<Trou>
é/wc
Trou has left #ocaml [#ocaml]
<dxtr>
Been toying with haskell for like six months but lately I've been like "Sigh.." when I am confronted with an issue in it
Merv` has joined #ocaml
igt0 has joined #ocaml
<dxtr>
So I decided to put that on the shelf in favor of ocaml now
<dxtr>
I have also been lurking here for a few months or so :p
lpw25[m] has joined #ocaml
<chelfi>
When you say the mutable stuff has put you off, do you mean you would miss Haskell's IO ?
Merv` has quit [Client Quit]
<dxtr>
No, I guess it's more of an unreasonable feeling I've had :)
<chelfi>
For what it's worth, OCaml programmers tend to avoid mutation and most basic data structures provided by one of the mainstream stdlibs have persistent, immutable implementations by default
<dxtr>
Yeah I'm gonna give it a serious shot
<dxtr>
It looks fun
freusque has quit [Quit: WeeChat 1.4]
freusque has joined #ocaml
<reynir>
it's fun () -> !x
freusque has quit [Ping timeout: 265 seconds]
ggole has joined #ocaml
sepp2k has joined #ocaml
Denommus has quit [Remote host closed the connection]
Denommus has joined #ocaml
nojb has joined #ocaml
regnat[m] has joined #ocaml
M-martinklepsch has joined #ocaml
M-jimt has joined #ocaml
Bluddy[m] has joined #ocaml
M-ErkkiSeppl has joined #ocaml
barkmadley[m] has joined #ocaml
M-pesterhazy has joined #ocaml
srenatus[m] has joined #ocaml
M-Illandan has joined #ocaml
llmn has quit [Quit: Page closed]
mg is now known as mg-
nicholas_ has quit [Remote host closed the connection]
nicholasf has joined #ocaml
Algebr` has quit [Ping timeout: 276 seconds]
pootler has joined #ocaml
<freehck>
dxtr: you already have it, lucky one. I ordered it 20 days ago and still waiting for delivery. Russia is so far. :)
<dxtr>
I have had it for a couple of months now at least :p
<dxtr>
But the delivery was like two days
FreeBirdLjj has quit [Remote host closed the connection]
<dxtr>
freehck: Sweden here
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
<mpenet>
so we'll be at least 2 with an ocaml interest over there :>
<mpenet>
I am exiled close to Lund
<rightfold>
OCaml is good
<dxtr>
mpenet: Norrköping here :p
profmaad has joined #ocaml
ee_ks has joined #ocaml
<_y>
i thought RWO had to be rewritten
<_y>
is it worth buying it now?
<dxtr>
really?
<dxtr>
Aw
<chelfi>
AFAIK most of it is still relevant
<profmaad>
i wouldn't say it has to be rewritten, but it certainly needs an update
<profmaad>
i would just use the online text until then
<dxtr>
Yeah I'll probably use both
<_y>
well i started reading it online and saw the code snippets were broken, but that’s not the contents itself
<chelfi>
it needs a reedition because of minor stuff like the switch from camlp4 to ppx, installation instructions, and maybe a port from Core to Base, but otherwise it stays relevant
<_y>
Base ?
<chelfi>
the new Jane Street stdlib replacement announced this week
<_y>
please don't tell me there has been yet another stdlib this summer
larhat has quit [Quit: Leaving.]
<dxtr>
haha
Merv` has quit [Remote host closed the connection]
<dxtr>
What's wrong with core? :p
<_y>
that must be a joke
<chelfi>
dxtr: portability issues, and it is quite heavy
<chelfi>
many people are reluctant to add it as a dependancy to small projects
<companion_cube>
_y: Base is the evolution of core_kernel
sdothum has joined #ocaml
<chelfi>
base should be simpler, portable, have less dependencies (ideally no dependencies)
<freehck>
_y: RWO definitly has really old code snippets. I saw there List.map function having a function as optional argument.
<profmaad>
core_kernel was just to get rid of the unix dependency. base is an actual attempt at slimming it down
<companion_cube>
which is nice, indeed
<chelfi>
freehck: when you say optional, do you really mean optional, or labeled ?
<dxtr>
So, uuh, how do I go about installing base then?
<chelfi>
because if labeled, List.map is redefined in Core and it does take the function as a labeled argument
<profmaad>
opam install base, no?
<companion_cube>
I think base is not released yet
<profmaad>
well, first opam repo add janestreet git://github.com/janestreet/opam-repository.git
<companion_cube>
we witnessed its appearance on github 1w ago
<companion_cube>
but it's not on opam yet
<_y>
freehck, not only that, but the web interface is clearly broken as i always had an error instead of the expected output that is to be generated automatically
<dxtr>
companion_cube: Yeah I was just about to do that, actually
shinnya has joined #ocaml
<chelfi>
I did not try this but I believe that if you opam pin the OCaml version used in RWO, most if not all code snippets should still work as expected
<_y>
and the stuff to file bugs with github issues sounded like abandoned
<_y>
chelfi, i thought the online book was a pure html version, with output generated server-side?
larhat has joined #ocaml
<chelfi>
¯\_(ツ)_/¯ no idea
<_y>
would be weird otherwise
larhat has quit [Client Quit]
Merv` has joined #ocaml
<dxtr>
[ERROR] The compilation of type_conv failed at "make".
<dxtr>
Lame!
<dxtr>
W: Field 'camlp4o' is not set
<freehck>
chelfi: yes, of course I wanted to say "labeled".
<freehck>
chelfi: wait-wait-wait. Core has its own map function?
<freehck>
I need to read more about Core.
tarecd has joined #ocaml
<benmachine>
Core has its own most things
larhat has joined #ocaml
<chelfi>
freehck: that is the whole point of Core :)
<chelfi>
this can be confusing for newcomers to OCaml reading RWO because most of the functions that are described are available only through Core, and they cannot copy/paste a random code snippet without making sure the proper dependencies are installed and in scope
<chelfi>
the upside is that as long as you can make sense of the Core way of doing things, there is a lot of convenient functions readily accessible for most basic usages
<freehck>
chelfi: it's okay. The first thing is recommended in RWO is to load Core in utop.
<freehck>
chelfi: Well, I still don't understand what Core is. And why it was introduced.
<freehck>
Is it an extension of standard libraries?
<chelfi>
it is an alternative standard library
<flux>
core is a library designed to be used by "all" ocaml developers in place of the standard library that comes with ocaml
<freehck>
Well I thought that Batteries are an extension...
<chelfi>
OCaml's stdlib is quite minimal (or at least used to be)
<flux>
batteries is also an alternative, but its interfaces are more similar to the library that comes with ocaml
<flux>
and batteries is a descendant of an older project extlib
<chelfi>
It lacks a lot of functions that are used routinely by users of other mainstream languages
<dxtr>
What's findlib?
<flux>
findlib aka ocamlfind is a tool to manage, find and use ocaml libraries
<chelfi>
batteries aims at being a mostly compatible stdlib extension, adding compatible stuff while trying to stay compatible with the stdlib in case of overlaps
<dxtr>
I can't install async because type_conv wants that but can't find it
<chelfi>
This allows Core to provide a default List.map that uses labels, for instance, while batteries would keep the stdlib's type
<benmachine>
the important part is the "camlp4.extend" bit, not the "findlib" bit
<dxtr>
[NOTE] Package camlp4 is already installed (current version is 4.03+system).
<flux>
dxtr, what does ocamlfind query camlp4.extend say?
<freehck>
flux: what is more alive now? batteries or core?
<flux>
dxtr, and if that fails, ocamlfind query camlp4 ?
<dxtr>
/usr/lib/ocaml/camlp4
<flux>
freehck, well, probably core, as it has more manpower
<flux>
I don't know how much "liveness" do they need, I don't think a standard library should be mutating continously :P
<chelfi>
there are other alternative stdlibs, like companion_cube 's containers
<flux>
dxtr, strange, so it seems it does infact find the package
<companion_cube>
chelfi: what does batteries lack compared to other languages, in your opinion?
zv has quit [Ping timeout: 272 seconds]
<chelfi>
companion_cube: I meant that OCaml's stdlib lacks many useful functions, and that batteries try to provide a lot of them
<companion_cube>
oh, ok!
<freehck>
flux: you know, I now look very well on core extensions. I used to extend stdlib myself and 2 weeks ago found that batteries did the same task with same methods. :)
<chelfi>
I personnaly am quite fond of batteries :)
<freehck>
So I'll get a look onto Core in a while if it has more manpower. :)
<freehck>
Well I still wanna get the book to begin.
<flux>
if it takes this long it probably means nobody has any time to work on it, or the vm screwed itself and there are no backups..
<jnavila>
flux: thanks for the pointer. Too bad we cannot do anything about it.
<smondet>
flux: they're working on it, the github *is* the backup :), the issue is not just the VM itself seems to be more "distributed" (rackspace, DNS, ...) </second-hand, hand-wavy, info>
<dxtr>
flux: What version should I use then? :p 114.08+89 seems to be the latest
<flux>
smondet, github has the complete machine description? I don't think the vm boots from the github repo, however cool that would be.. ;)
<flux>
dxtr, hmm, so it seems so. perhaps one that's not available only via janestreet opam resources?-)
<flux>
you could try opam instal async.113.33.03
<flux>
(remember to have the external resolver aspcud installed, I consider opam's internal resolver broken)
shinnya has quit [Ping timeout: 272 seconds]
<dxtr>
And how do I install that?
<flux>
via your host system, ie. I installed it with apt-get
MercurialAlchemi has quit [Ping timeout: 265 seconds]
nicoo has quit [Ping timeout: 268 seconds]
yegods has joined #ocaml
kamog has quit [Remote host closed the connection]
zpe has joined #ocaml
<smondet>
flux: oh I thought you meant the content
nicoo has joined #ocaml
ee_ks has left #ocaml [#ocaml]
<flux>
smondet, yes, the actual stuff they need to get it up and running :)
<flux>
sure having the content somehwere is nice, but still many steps away to go from no vm to a vm serving that..
balod has quit [Remote host closed the connection]
<dxtr>
flux: And then?
pierpa has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
pierpa` is now known as pierpa
jao has joined #ocaml
<flux>
dxtr, opam instal async.113.33.03 I guess
ee_ks has joined #ocaml
<dxtr>
Oh it automatically discovers aspcud?
<dxtr>
So I don't need OPAMEXTERNALSOLVER? :p
<flux>
correct
<dxtr>
I can't install async.113.33.03 because I am not using ocaml version 4.02.3 :p
<flux>
well, there you have it, it's impossible :). perhaps if you opam switch to 4.02.3 and make-do with that older ocaml version for the time being.
<flux>
IMHO many of the libraries (by jane street?) are wayy too dependant on ocaml version.
<dxtr>
right
nicholasf has quit [Remote host closed the connection]
sepp2k has quit [Quit: Leaving.]
<flux>
hopefully the Base won't follow the suite.
<flux>
I seem to recall it was very difficult to get any useful packages to test with 4.03 because so many packages dependend on ocaml <4.03
yegods has quit [Remote host closed the connection]
randomA has joined #ocaml
<randomA>
hello, pelase help
<randomA>
id don't understand what it means that i say type a = b C.Map.t
<chelfi>
this declares a type alias
<randomA>
is this a typo and should be type a : b C.Map.t
<randomA>
oh shit
<chelfi>
It means that in scope, whenever you would use b C.Map.t, you could use a instead
<randomA>
so type a is a implementation of Map with keys C and values t
<chelfi>
well, it depends on what exactly b C.Map.t means but something along those lines yes
shinnya has quit [Ping timeout: 255 seconds]
<randomA>
C is amodule and t is the representation type
<chelfi>
(for instance b could be a tuple (key, value) in which case b C.Map.t is an implementation of Map with keys key and value value)
<chelfi>
in other implementations, you may have value Int.Map.t for instance which are likely maps from ints to values
<randomA>
so i f i have type exits = room Direction.Map.t
<randomA>
then exits is a alias for mapping from Directions to exits?
<randomA>
uh
<randomA>
Directions to rooms i mean
<chelfi>
it seems likely, yes
<randomA>
where rooms is a type and Direction is a module
<randomA>
very confusing
<randomA>
chelfi: how do i access the exits functiosn then?
<chelfi>
Most likely in Direction.Map
<randomA>
but i have exit, right?
<randomA>
so then I'm doing exits.add
<chelfi>
exists is a type, not a module
<chelfi>
Unless it is a record (or an object), it does not contain functions
<randomA>
yeah, it's a type
<chelfi>
it is more likely that you have a module somewhere that defines a function add : 'a Direction.Map.t -> ...
<chelfi>
and you would do something like add exit ...
<chelfi>
So I guess in your case, Direction.Map.add exit ...
<randomA>
so then exit is a type and exits is a type
<randomA>
oh wait ok i know
<chelfi>
exit would be a value of type exits and exits is a type
<randomA>
chelfi: so I'm confused whether it is better that I do type room - ... module Room = struct type t = room ...
<randomA>
or should i just do module Room = struct type t = { ...
<chelfi>
I guess it depends on whether you want Room.t to be abstract
<randomA>
would i want it to be?
<chelfi>
In particular, if all your functions working on Room.t are in the Room module, there is little value to defining a type room outside the Room module
<randomA>
ok i see
<chelfi>
If you want people to be able to bypass your API, you should not make Room.t abstract
<chelfi>
for instance if you want people to be able to use arbitrary Map functions without you exposing them
<chelfi>
on the other hand, if you want people to always use the functions you expose, you should make it abstract so that client code does not rely on a particular representation
<chelfi>
(which means you could change your representation later on without breaking client code)
<randomA>
i don't know...
<randomA>
im not sure what im confused about
<chelfi>
if you do not know, it is easier to make it concrete, but safer/cleaner to make it abstract
<chelfi>
(in general)
<randomA>
lol
<randomA>
i dont even know what im using this map for
<randomA>
because apparently i need associatlion lsits
<chelfi>
maybe you should keep it concrete then, play with it a bit, and when you know, you can decide
<chelfi>
Association lists are one possible Map implementation
<randomA>
in general, the type is holding data, and the module is data witht he functions?
mpenet has quit [Remote host closed the connection]
<Bluddy[m]>
randomA: You want to keep things simple as much as you can. I think association lists are a good idea because they're simple.
<Bluddy[m]>
Don't worry about abstracting things. Just keep things simple.
yegods has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
sdothum has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Bluddy[m]>
Investing a little in simplification will help you get this done faster. For example, I wouldn't create any modules within OCaml files.
AlexRussia has joined #ocaml
<Algebr`>
agreed, just get it working first
pootler has quit [Remote host closed the connection]
agarwal1975 has quit [Quit: agarwal1975]
<rightfold>
hmm, print_string stopped working for some odd reason
<Algebr`>
probably need to flush
<rightfold>
TIL print_endline
Merv` has quit [Ping timeout: 244 seconds]
<rightfold>
ah yes that works, thanks :)
tane has joined #ocaml
fraggle_ has joined #ocaml
<dxtr>
How would I replace a package with my own version?
<Algebr`>
pin it
<Algebr`>
opam pin
<dxtr>
And this can be a package in a directory?
<dxtr>
"Pins package PACKAGE to TARGET, which may be a version, a path, or a URL."
<dxtr>
Neat
bruce_r has joined #ocaml
<Algebr`>
yes, local dir or git
shinnya has joined #ocaml
nojb has quit [Ping timeout: 265 seconds]
<flux>
does opam 2.0 search do logical 'and' to the search criteria? please say it does?-)
<Drup>
flux: what do you mean ?
<Drup>
opam search has been improved, but not sure what you mean exactly
<flux>
opam search xml json -> I did want to search libraries that do xml OR json
<flux>
+NOT :-)
<flux>
so I would prefer it worked like apt-cache search, where I can apt-cache search xml json log and get actually useful results
ggole has quit []
yegods has quit []
pootler has joined #ocaml
ee_ks has quit [Ping timeout: 240 seconds]
FreeBirdLjj has joined #ocaml
wxfdglm has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
Simn has quit [Quit: Leaving]
CuriousErnestBro has quit [Remote host closed the connection]
Simn has joined #ocaml
agarwal1975 has joined #ocaml
struk|work has joined #ocaml
pootler has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
slash^ has joined #ocaml
osa1_ has joined #ocaml
<osa1_>
Bytes.get is returning a char. how do I read a byte from a byte buffer?
<flux>
char = byte
<osa1_>
so Char.code (Bytes.get bytes idx) never fails with encoding problems etc. and always gives me the byte?
<flux>
yes, there's no encoding
randomA has joined #ocaml
<randomA>
hi hi
<randomA>
i got a question
<randomA>
is it better if I use the id of a record and put that as my values in my map or should I put the entire record
<randomA>
in other words, is it better if I have a (string, string) association list or a (string, mytype) assocaition list
<randomA>
i have a map either way
<randomA>
hey
tristero has quit [Quit: tristero]
<Bluddy[m]>
how do you get back the record if you only store the id of the record? Do you need to be able to pull out the rest?
<randomA>
Bluddy[m]: that's a really good point
<randomA>
i had not of that
<Bluddy[m]>
well that's exactly what will help you decide which representation you need
<randomA>
I have a question. If I have a type room, type item, and type object. And basically room and item are objects, then I create an Object module and have room and item implement that, then how do I create a map where the keys are the strings of the field of room an item
<Bluddy[m]>
so you're saying you want to store either items or rooms as the data in your assoc list?
<randomA>
Bluddy[m]: well i'm going to have one Map from item to room, and one map from room to another type called exits
<Bluddy[m]>
ok. so those are 2 separate types in 2 separate data structures, so no problem there
<Bluddy[m]>
if you want to mix types together in one map, the easiest way is to wrap them in another type like so:
<Bluddy[m]>
type wrapper = Room of room | Item of item
<randomA>
ok, i just figured since both types room and item have some similar functions like getting id, that I'd kind of merge them together
<Bluddy[m]>
so you're using the same type for both?
<randomA>
no, I was going to try to do something like inehritance in java
<rightfold>
row polymorphism!
<randomA>
with classes and subclassses
<randomA>
i dont know if that's a thing though
<Bluddy[m]>
OK you can use classes in OCaml, but it's not the typical way to do things
<Bluddy[m]>
I'm not sure if that's what your professor wants you to do
<randomA>
yeah he doesn't
<randomA>
i feel like you're a TA as well
<randomA>
that's ok. im not cheating or anything
<Bluddy[m]>
I do TA in my own school... I have a lot of experience TAing (and some teaching)
<Bluddy[m]>
Yeah no problem -- I'm just pointing you in the right direction
<randomA>
but do you TA at this school?
<randomA>
eh, i dont think i want to know
wxfdglm has quit [Ping timeout: 244 seconds]
<Bluddy[m]>
We don't have an OCaml class that's currently running, so no
<randomA>
lol ok
osa1_ has left #ocaml ["Konversation terminated!"]
<Bluddy[m]>
Anyway, for OCaml, when you want to have types that are similar (such as room and item), you place them in a single type
<randomA>
so my other question is how do I know whether to create a module or not
<Bluddy[m]>
I would recommend for you to avoid modules as much as you can
<randomA>
and yeah, i was going to place them in tpe object
<randomA>
oh why?
<randomA>
i thiknk he really wants us to
<Bluddy[m]>
Really?
<Bluddy[m]>
So here's the thing
<Bluddy[m]>
Putting things is different files in OCaml is equivalent to different 'modules'
<Bluddy[m]>
But you can also create little modules inside files
<Bluddy[m]>
and that makes things more complicated.
<randomA>
oh, he doesnt want in different files though
<randomA>
he wants in one big file
<Bluddy[m]>
Really?
<Bluddy[m]>
So weird
<randomA>
yeah
<Bluddy[m]>
So if you must use modules... The thing to understand is that they're mostly optional
<Bluddy[m]>
they help you organize your code
<Bluddy[m]>
but they don't provide you with special abilities like classes do
<randomA>
ok
<Bluddy[m]>
Deciding whether things belong in different modules is mostly learned from experience
<randomA>
So I want to use the Map module and implement that
<randomA>
I see the implementation for OrderedType but i feel like that's not necesssary
<Bluddy[m]>
OK Map is a special type of module called a functor
<Bluddy[m]>
functors are where modules get interesting
<randomA>
yes, learned about that this morning
<randomA>
I can use the Make function really easy
<rightfold>
hehe, "avoid modules", "I want to use Map.Make" :3
<randomA>
i feel like Map is really nice
<Bluddy[m]>
Well, functors let you create new modules that have new abilities out of old ones. They're the only place where you absolutely need to use modules
<Bluddy[m]>
So if you want to use Map, you create a custom map type that suits your key type using Map.Make
<Bluddy[m]>
And that results in a new Map module that you give a name to
<randomA>
right
<randomA>
so I have type exits = room Direction.Map.t
yegods has joined #ocaml
<randomA>
this is essentially a Map of Directions to room types
<randomA>
what confuses me is whether I should be mapping to Room modules or Room type
octachron has joined #ocaml
<randomA>
becuase i have a type room = {} and Module Room
<rightfold>
that would be Room.room, then
yegods has quit [Read error: Connection reset by peer]
yegods_ has joined #ocaml
<Bluddy[m]>
If you have a type room, you want it to be the same as the type inside the Room module (presumably).
<randomA>
so I should map to Room.room?
<randomA>
yes, it is
<Bluddy[m]>
If you have such a type inside Room, then yes
<randomA>
Alright, so in order for me to use Map.Make() I have to input a structure that impelments compare and type t
<randomA>
that's ti right?
<randomA>
then it will magically work?
<Bluddy[m]>
Not so magically, but yes, it should work
<Bluddy[m]>
And 'structure' = module
CuriousErnestBro has joined #ocaml
<randomA>
coolbeans
<rightfold>
booleans
<randomA>
hehe
yegods_ has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
<randomA>
So if I've created Object module where I will give an implementation called Item object and one called Room object, and both of these item and room are records with the field id that I want, how would I retrieve that id from the module?
<flux>
you have module Item and Room in the module Object?
pootler has joined #ocaml
<flux>
maybe you mean this: module Object = struct module Room = struct type t = { id : int } let room1 = { id : 1 } end end and then somehwere you have code like let room = Object.Room.room1 and you want to find the id from that 'room'?
<randomA>
yeah eaxcatly
<flux>
well it could be room.Object.Room.id as the direct form
<randomA>
lol
<randomA>
is that ok?
<flux>
if your compiler already knows the type of room, you can use room.id
<randomA>
flux: becuase i was thinking i could make maps easier too by doing module ObjMap = Map.Make(Object)
<randomA>
then i only have to create one map right?
<Bluddy[m]>
randomA: nope
<Bluddy[m]>
you're missing a piece here
<flux>
you create only one Map module for the objects perhaps
<randomA>
yeah, but i create different instances of the MapObj
<Bluddy[m]>
you're thinking of Java, where Room and Item inherit from Object
<Bluddy[m]>
but that's not what's happening here
<randomA>
yeah, that won't work here?
<Bluddy[m]>
Room.t and Item.t are separate types. They have no connection to each other
<randomA>
so do I just create a RoomMap and ItemMap instead?
<Bluddy[m]>
Despite having similar field names
<randomA>
but is it still okay for me to have my Object abstract module?
<Bluddy[m]>
Yeah it's fine, but it's not really doing anything
CuriousErnestBro has quit [Quit: Leaving]
<randomA>
ok so i should just not do that
<Bluddy[m]>
Remember modules for the most part are just wrappers -- they have no purpose outside of code organization with the exception of functors
<Bluddy[m]>
If you ever wanted to store Room.t and Item.t in the same object, you'd wrap them in a type
<randomA>
I think maybe it's easier to just not do that
<Bluddy[m]>
there's no reason to do it unless you had a specific need
<randomA>
i'm going to e parsing JSON file with this data into the types. Will this be very difficult?
<randomA>
i so the json.basic stuff but seems like a lot of converting
CuriousErnestBro has joined #ocaml
<Bluddy[m]>
It's not hard, but do you understand the way pattern matching and variants work?
<randomA>
flux is definitely a TA or the prof, because the room1 is the exact json lol
<randomA>
Bluddy[m]: yeah mostly
<randomA>
kind of
<randomA>
i was going to create a variant for all the types I wanted
<randomA>
then extend json module
<randomA>
yojson
<Bluddy[m]>
OK. I don't think there's a need to extend the json module. yojson, if I remember correctly, just builds up a variant representation of the json data. You parse that with pattern matching and create your types.
<rightfold>
What's the difference between Yojson.json and Yojson.Basic.json?
<randomA>
um, i mean it builds a varaint, but if i've created a type room, then I want to parse json into the room type
<randomA>
even though room is a record
<randomA>
and should my records not be exposed. Like I should wrap the record for my Item inside the Module
<randomA>
and not be like type item, and then be l ike module Item
<Bluddy[m]>
rightfold: It's just variations of conforming to the JSON standard, working with OCaml needs & limitations etc
<randomA>
ok.
<randomA>
it should be ok
<randomA>
i think i should just work with modules and not the types
<Bluddy[m]>
What yojson does is, it gets rid of the need to parse the actual text. It'll convert the JSON text to a tree, and then you match on that tree (of variants) and build up your type. You need to decide how to encode your type into variants such as `Int, `Float etc
<randomA>
like declare the types inside
<Bluddy[m]>
how you want to organize it (modules) is up to you -- there's really no 'right' way
<randomA>
so if room is a type wrapped in module, then my type is is like TYPE of Room
<randomA>
in this case, would I be better off not wrappign types inside moduels?
slash^ has quit [Read error: Connection reset by peer]
<randomA>
actually, i think it hsould be outside then
<octachron>
randomA, resorting to analogies, modules are like chapter of a book(aka program)
<randomA>
ok
<randomA>
and types are like paragraphs
<octachron>
there are not strictly needed, and if you are confused by them avoid them for now
<randomA>
i feel like modules include functions and records don't
<randomA>
ok
<octachron>
when programs growth, modules are nice to organize the code in a more readable way
<octachron>
but in your case, I have the impression that you need first to have some working code; before starting to wonder how to organize your not-yet-existing code.
<Bluddy[m]>
yeah I recommend you ditch modules in your code for now. Just have type room, type item etc
<randomA>
lmao its due like tonight
<randomA>
like 11:59 pm
<randomA>
ima be coding from now until 11:59 pm
<Bluddy[m]>
modules are complicating your understanding. better to have working code than code you can't make progress in
<Bluddy[m]>
if you get it right, you can put them back in afterwards
<rightfold>
Modules are like teeth
MercurialAlchemi has quit [Ping timeout: 265 seconds]
bruce_r_ has joined #ocaml
ee_ks has joined #ocaml
<dxtr>
So, are there any tools I should know about?
<dxtr>
Like stack for haskell, rebar3 for erlang, etc?
bruce_r has quit [Ping timeout: 272 seconds]
<companion_cube>
opam, merlin, ocp-indent
<randomA>
how can i compare two records?
<randomA>
i can use pervasives.compare?
<companion_cube>
yes
<randomA>
so it will just work, like let compare = Pervasives.compare
<randomA>
that's it?
octachron has quit [Ping timeout: 260 seconds]
<companion_cube>
yes
<companion_cube>
unless the record contains uncomparable things like functions
<randomA>
nah, they're mostly just strings
<randomA>
ah one of them contains a tuple
<companion_cube>
fine
<caw>
If anyone here has some spare cycles, would you mind trying to build this project? https://github.com/heidi-ann/ocaml-raft There are several dependencies that I can't resolve and don't yet know how to fix. Someone more experienced with OCaml/opam/etc probably can, though.
<randomA>
what if it contains a room Direction.Map.t
<companion_cube>
caw: apparently it uses "old" libraries based on camlp4
<companion_cube>
randomA: ah, that's not really comparable
<companion_cube>
(two equivalent maps might not be balanced the same way)
<randomA>
companion_cube: ok, i don't need that to be in that structure anyway
<caw>
companion_cube: I figured as much... any thoughts on how to upgrade it? Or would it be easier to downgrade OCaml?
<companion_cube>
there is Map.compare, though
<companion_cube>
caw: hummm, upgrading it is doable, but a bit tedious
<randomA>
yeah but in order to implement Map.compare, you need to first implement Comparable
<companion_cube>
(replace `with sexp` by `[@@deriving sexp]`, for instance)
<randomA>
or i mean, not comparable but like a compare
<randomA>
should i use a try statement here
<companion_cube>
randomA: you need to compare values, yes
<caw>
companion_cube: cool, thanks. I'll give it a shot
magnumkarter has joined #ocaml
<companion_cube>
good luck
<randomA>
like let compare x y = try Pervasives.compare x y with Not_Found -> 0
<companion_cube>
hmmm
<randomA>
companion_cube: yeah so pervasives.compare will go over the records and compare their values
<companion_cube>
yes
<randomA>
i can loose the the the Map
<magnumkarter>
does anyone know how to setup an ocaml project with ppx_inline_test and oasis?
<companion_cube>
but why Not_found
<randomA>
thats just what rwo has
<randomA>
int the example im looking at
<companion_cube>
magnumkarter: probably with some magic in myocamlbuild.ml
<companion_cube>
randomA: ahhh yoiu're using Core
<companion_cube>
then I'm not sure of the interfaces
<randomA>
no, im not
<randomA>
i really shouldnt be
<companion_cube>
RWO uses it
<randomA>
i know
jstolarek has joined #ocaml
<Bluddy[m]>
randomA: a compare function (compare x y) returns 0 if x=y, positive num if x > y, neg if x < y
<randomA>
yeah
<Bluddy[m]>
there's no reason to return Not_found
<randomA>
no i match on Invalid_Argument and return -1
<Bluddy[m]>
why would there be an invalid argument?
<randomA>
because Pervasives.compare returns that when you try to ocmpare funcitonal types
<Bluddy[m]>
ok that's true, but you don't feed it functional types. So just ignore that part.
<randomA>
ok
jstolarek has quit [Ping timeout: 240 seconds]
<Bluddy[m]>
note the difference also between 'returns a certain type' and 'throws an exception'. They're not the same -- an exception will go all the way up your code and doesn't need to be handled where it's thrown.
yegods has quit []
<randomA>
so you're sure thatok makes sense
<randomA>
weird back printing
<randomA>
but yeah, i got you
rgrinberg has joined #ocaml
_andre has quit [Quit: leaving]
randomA has quit [Remote host closed the connection]
natimic has quit [Remote host closed the connection]
CuriousErnestBri has joined #ocaml
igstan has joined #ocaml
igstan has quit [Client Quit]
CuriousErnestBro has quit [Ping timeout: 265 seconds]
tristero has joined #ocaml
magnumkarter_ has joined #ocaml
atsampson has quit [Quit: new irssi time]
atsampson has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
jmiven has quit [Client Quit]
jao has quit [Remote host closed the connection]
jmiven has joined #ocaml
<dxtr>
Hmm
<dxtr>
Unbound value String.is_prefix?
<dxtr>
According to the documentation it should exist
<rightfold>
open Core.Std
jao has joined #ocaml
AltGr has joined #ocaml
<dxtr>
Unbound module Core :p Although I have it installed
<dxtr>
And String.concat exists
<rightfold>
-pkg Core
<rightfold>
-pkg core *
CuriousErnestBri has quit [Remote host closed the connection]
CuriousErnestBro has joined #ocaml
<dxtr>
Hm, okay this was a merlin error
<dxtr>
Now it doesn't think my string is a Core.Std.String.t although Core.Std.String.t should be a string, according to the documentation :p
<dxtr>
Error: This expression has type string but an expression was expected of type string option
<dxtr>
oh
<dxtr>
Ahha!
<dxtr>
I'm a moron
<dxtr>
Why is "rec" necessary for functions that are recursive?
AltGr has left #ocaml [#ocaml]
tane has quit [Quit: Leaving]
<rightfold>
it's useful to omit rec when you want to shadow a variable and use the old value in its definition
<rightfold>
for example: "let x = 1 in let x = x + 1 in let x + x + 1", vs "let rec x = x + 1" which won't work because x + 1 will refer to the new x (not the old one)
p_nathan has quit [Ping timeout: 272 seconds]
<dxtr>
Right
<dxtr>
How can I tell merlin to include to not spit out errors on Core.Std stuff?
p_nathan has joined #ocaml
rgrinberg has quit [Ping timeout: 260 seconds]
<Leonidas>
dxtr: use PKG in your .merlin
<Leonidas>
dxtr: because recursive functions are handled differently in the compiler. i suppose nonrecursive functions are faster, therefore you need to add the rec keyword to make the compiler do more work
<Leonidas>
but thats just a theory
tmtwd has joined #ocaml
agarwal1975 has quit [Quit: agarwal1975]
jao has quit [Ping timeout: 244 seconds]
nicholasf has joined #ocaml
jao has joined #ocaml
CuriousErnestBro has quit [Ping timeout: 255 seconds]
bonhoeffer has joined #ocaml
<bonhoeffer>
what applications is oCaml often used for?
<bonhoeffer>
some of the folks i work with are building concolic s/w analysis tools with it -- but what types of applications do folks love to do with it?
Simn has quit [Quit: Leaving]
freehck has quit [Ping timeout: 240 seconds]
fraggle_ has quit [Ping timeout: 265 seconds]
<bonhoeffer>
why are variables mutable? that seems very limiting
<bonhoeffer>
i meant why can one not change the value associated with a name after its definition?
<rightfold>
bonhoeffer: this makes it easier to read the code, because you know that the variable will have the same value it always had