<Bluddy[m]>
bonhoeffer: much of the complexity that builds up as you scale up applications comes from mutable state: changing the values of variables and data structures, and having that affect interlocking systems. By removing that as much as possible, you remove some of the worst bugs that can occur, making systems far more reliable.
mfp has quit [Ping timeout: 244 seconds]
tristero has quit [Quit: tristero]
sh0t has quit [Ping timeout: 248 seconds]
ygrek has joined #ocaml
ygrek has quit [Remote host closed the connection]
michaeltbaker has joined #ocaml
bruce_r_ has quit [Remote host closed the connection]
bruce_r has joined #ocaml
wu_ng has joined #ocaml
osa1__ has joined #ocaml
<osa1__>
does anyone know how to print shell escape sequences in OCaml? strings like \033[10A work in every other language except OCaml
osa1 has joined #ocaml
osa1__ has quit [Ping timeout: 244 seconds]
rbocquet has quit [Ping timeout: 272 seconds]
ee_ks has left #ocaml [#ocaml]
rbocquet has joined #ocaml
FreeBirdLjj has joined #ocaml
tristero has joined #ocaml
randomA has joined #ocaml
<randomA>
hi
<randomA>
i ned some quick help
<randomA>
I have module AMap = Map.Make(A)
<randomA>
then I want to do let mymap = B AMap.t
<randomA>
but B is not detected
<Bluddy[m]>
B isn't a type. Maybe B.t?
<Bluddy[m]>
but you can't do that anyway, since let declares a value and you're making it equal a type
<Bluddy[m]>
let mymap = AMap.empty should do the trick
<randomA>
isn't B the values of the keys?
<Bluddy[m]>
AMap.t is a type
<randomA>
ok
<randomA>
so how do i say that this map is of type B?
<Bluddy[m]>
you only need to do that for the key type
<randomA>
why?
<Bluddy[m]>
you've created an AMap. It has key type A
<randomA>
yeah
<randomA>
but i want to say that the values will be B
<Bluddy[m]>
The full type of the map is 'a AMap.t, and OCaml will infer that type
<randomA>
oh ok
<Bluddy[m]>
so you don't need to worry about it
<Bluddy[m]>
the only reason you needed to tell Map that it's built for A (using the functor application) is because the key is constantly compared, and we don't want to use polymorphic comparison
<randomA>
ok, if I want to print records, will Map automaticaly do that or no
<Bluddy[m]>
nope. to print them, you need a print function
<randomA>
that's too bad
<randomA>
i tried to match the record but then i had the mismatch type with 't not equal to t
<randomA>
idk
tmtwd has quit [Ping timeout: 265 seconds]
<Bluddy[m]>
If you're printing the entire map of records, you'll iterate over the map, calling Printf.printf on each record
AltGr has joined #ocaml
<randomA>
yes, ill do that
<randomA>
actually, I just mapped modules that are records
<randomA>
and have a to_string method in the module
<Bluddy[m]>
That's fine. It's better
<Bluddy[m]>
In that case you can use Printf.sprintf.
<randomA>
Printf.printf and it works like C?
<randomA>
why spritnf?
<Bluddy[m]>
sprintf just returns a string
<Bluddy[m]>
instead of printing to the screen
<Bluddy[m]>
It's almost exactly like C, except it actually typechecks the types
wxfdglm has joined #ocaml
<randomA>
cool thanks
<Bluddy[m]>
So you can build up the whole string, and then call print_string on the whole thing
<randomA>
and it's also ok for me to have let compare t1 t2 = Pervasives.compare t1 t2 right if all my types are records
<randomA>
Bluddy[m]: and yeah, i'm gonna do that
<randomA>
This is due at 11:59 and it's 10:43 so im probably fucked, but at worst, i
<Bluddy[m]>
yes that'll work fine if there's no map inside the record
<randomA>
ll be a day late
<randomA>
ok, no maps inside records
<randomA>
ive essentially wrapped all my types inside modules
<Bluddy[m]>
then Pervasives.compare is great
<randomA>
and then used the modules to add functions
AltGr has left #ocaml [#ocaml]
<Bluddy[m]>
okey doke. Once again, if it gets too confusing and you have trouble getting it to work, you can get rid of the modules and just place everything in the same module.
<randomA>
thanks for like answering my questions btw. I really appreciate it even though i don't think I'll have this done on time
<Bluddy[m]>
no prob
magnumkarter has quit [Ping timeout: 240 seconds]
magnumkarter_ has quit [Ping timeout: 240 seconds]
<randomA>
if I want to create an alias called exits which is a map of rooms to exits, then that would be Exit Room.Map.t
<randomA>
how come I can go type treasuremap = room Item.Map.t but not type treasuremap = Room Item.Map.t
<Bluddy[m]>
Room is a module, not a type
<Bluddy[m]>
Room.room is a type
<Bluddy[m]>
as is room (if you defined that alias type)
<randomA>
wow
<randomA>
so if i was like room = { .... } then did module Room = struct type t = room, then is room = Room.room
shinnya has quit [Ping timeout: 260 seconds]
tmtwd has joined #ocaml
<Bluddy[m]>
well, where did you define the type? type room = { ... }
<Bluddy[m]>
you don't really need room on the outside. You could just use Room.t
<Bluddy[m]>
But no it's not Room.room, it's Room.t
<Bluddy[m]>
since inside the Room module you define type t
<randomA>
yeah
<randomA>
i saw it i n an example most likelyu dotn
<Bluddy[m]>
So inside Room, you can make type t = {...}
<Bluddy[m]>
with the details of room
<randomA>
and then just spam Map.t
<randomA>
so tired
<Bluddy[m]>
long day, huh?
<randomA>
i ve been up 48 hours and no joke am starting to hallucinate shadows
<Bluddy[m]>
like Don't Starve!
<Bluddy[m]>
know that game?
<randomA>
but like, i was trying to do this project yesterday then got distracted by picking out sublime theme colors
<randomA>
and nope, dont know
<Bluddy[m]>
yeah it's a survival game where you start hallucinating shadows as you go mad
<randomA>
that's unfortuante
<randomA>
its not like people shadows, it's like i see this dark glimps fly accross the peripheral of my vision
<randomA>
kind of like what happens hwne you see a bug
<randomA>
it;s apparentlt an allnighter thing
<Bluddy[m]>
yeah makes sense
<Bluddy[m]>
if you're far from getting it done (and it sounds like it, since you're missing quite a bit) I recommend going to sleep now
<randomA>
hmm, do you think i can write the game loop, create the functions for implementing game state, parse json to the correct types, and get user input in 1 hour?
<Bluddy[m]>
no way
<randomA>
lol are you actually a TA
<Bluddy[m]>
sorry :(
<Bluddy[m]>
this stuff takes time
<randomA>
i'll put your username in the acknowledgement comments
<Bluddy[m]>
sweet
<randomA>
you're not actually a TA for this class, right?
<Bluddy[m]>
nope
<randomA>
i'm pretty sure that other guy was
<randomA>
because he was referencing the exact json names
<randomA>
either he was a TA or was a the proffessor lol
<Bluddy[m]>
yeah could be
<randomA>
thats funny if actual professor was him and then connected me to this username bc he doesnt know me but i shit post a ton on this class forum thing
<Bluddy[m]>
piazza?
<Bluddy[m]>
everybody uses piazza
<randomA>
yah lol
<Bluddy[m]>
it's great
<randomA>
nah, the layout is shitty
<randomA>
Are you a student here then? also taking this class
<randomA>
thatd be funny
<Bluddy[m]>
no i'm in a different school
<Bluddy[m]>
Hopkins
<Bluddy[m]>
but I think I know which school you're at
<randomA>
oh ok
<randomA>
is it in my host id?
<randomA>
apparently that happens
<randomA>
~hostname
<randomA>
eh
<Bluddy[m]>
no i just searched for an OCaml course, and then I looked at the schedule
<Bluddy[m]>
you mentioned you just did functors
<randomA>
oh lol
<randomA>
and you see the writeup for the project
<randomA>
it's so cool, but I always waste a lot of time on trying to print and trying to get types to match
<randomA>
Btw, do you know how testing should be done?
<randomA>
like I know o unit tests
<randomA>
but it's an entire game, so I don't know how I would test some of this stuff
<Bluddy[m]>
well, the general rule is, the more functional you make your functions (ie. no mutable state), the easier it is to test
<Bluddy[m]>
you just feed them input and compare to the output
<randomA>
ok, there is no mutable for sure
<randomA>
alright, i guess ill do a ton of assertequal
<randomA>
so i need to aprse json into these types, which was the reason why I decied to put the type outside because i didn't think ic oudl parse into a module
<Bluddy[m]>
holy crap dude, you expected to do this thing in 2 days?
<randomA>
I think it will work if I do something variants and pattern matching, like all of these are not variatns of each other
<randomA>
Bluddy[m]: i mean yeah, i was up for 48 hours
<randomA>
on a lot of stims
<Bluddy[m]>
it's a large assignment
<randomA>
yeah, it is. It's really cool though.
<Bluddy[m]>
yeah pretty awesome
<randomA>
so for parsing json into modules, is that a thing or no? I was going to pattern match but didn't know how to do that nicely
<Bluddy[m]>
into types, not modules
<Bluddy[m]>
remember -- modules are just wrappers. like plastic bags
<randomA>
right, so that's why i have the types on the outside and not inside
<Bluddy[m]>
that part doesn't matter so much. you can have your types inside the modules or outside them. Either way you'll access them the same way
<Bluddy[m]>
It's purely organizational to have them inside modules
<Bluddy[m]>
Like a sandwich. You can put it in a plastic bag or outside it, it's the sandwich that matters
<randomA>
oh that's interesting
<Bluddy[m]>
anyway, yojson will read the json text and create a tree of variants: float, int, all the variants it has to describe data
<randomA>
right
<randomA>
i understand all that
<Bluddy[m]>
the tree will resemble what's in the json file
<Bluddy[m]>
you then go over the tree and build your records
<Bluddy[m]>
ok
<Bluddy[m]>
so what was your question again?
<randomA>
what do you mean by go over tree?
<randomA>
and so i should def put my types inside my modules?
<randomA>
and this hallucination thing is getting weird as in some depth is getting squigly
<Bluddy[m]>
you've already got your types inside modules, so keep them that way. it doesn't matter so much, like i said.
<randomA>
ok
<Bluddy[m]>
go over the tree means you'll create a function that examines the tree (pattern matches)
<Bluddy[m]>
so you'll get yojson's output, and then you'll match on it
<randomA>
so then if I'm aliasing, I have to do type exits = Room.t Exit.Map.t
<randomA>
yeah, ok so this is the part that confused me
<randomA>
what does it mean by iterate over tree?
<randomA>
in rwo they don't really do that, he just kind of goes through all his values
<Bluddy[m]>
ok so how does yojson represent something like a record? json format is pretty limited
<randomA>
curly braces and list
<Bluddy[m]>
if you're using Json.Basic, you'll have Assoc of (string * json) list
<randomA>
array of curly brases
<Bluddy[m]>
so you'll try to find that inside your function, and then you'll go through the elements and match them up with what your record has
<Bluddy[m]>
array of curly braces is the JSON text, but you want to think in terms of the Yojson data type
<randomA>
so what happens if they ahve a record inside the record, then the parsing must be recursive?
<randomA>
do you think i'll finish this by tomorrow?
<randomA>
i get another 24 hours
<Bluddy[m]>
in that case it could be recursive, but you know what depth to expect. You're using your data format as a guideline. Your records have no inner record, so if you see a list inside the list, you know something's wrong and can report an error. But let's say your room record has only an int -- you'll look for that int inside the list and create the corresponding room record.
<randomA>
this is similar to pattern amtching on records then
<randomA>
ah ok
<Bluddy[m]>
Yeah, but variants are a little different since you can have multiple options, one for each variant.
<randomA>
i patternmatch on JSON's variants
<randomA>
can I extend JSON to give it variants that will match my types?
<Bluddy[m]>
no
<Bluddy[m]>
There's a way to automatically generate json for your type with ppx (a preprocessor), but you don't want to mess with that and you're probably not supposed to
<randomA>
ok
<Bluddy[m]>
JSON only has a few data types anyway, and that's what the variants represent
<randomA>
Alright. That seems good
<Bluddy[m]>
I recommend doing the best that you can to get a working prototype as soon as you can. Tomorrow -- get some sleep.
<Bluddy[m]>
Take shortcuts to get to the point where something is working.
<Bluddy[m]>
Then build out from there.
<randomA>
And the last issue is that apaprently "directions" are suppose to come from the JSON, so there's no default directions like "UP, DOWN, LEFT"...is it possible to parse the json values into a variant?
<Bluddy[m]>
You'll get a String variant from yojson with the text inside
<Bluddy[m]>
And you can convert that to your own direction type
<randomA>
so type direction = blah of String
<Bluddy[m]>
no you want to create a type with your own variants
<Bluddy[m]>
e.g. type direction = North | South | East | West | Up | Down
<randomA>
but what if they have northeast
<Bluddy[m]>
But I'm thinking maybe you just want to have an instruction type:
<Bluddy[m]>
ah ok directions are custom-made
<Bluddy[m]>
if you have an instruction type, type instruction = Direction of string | Take of item | Drop of item ...
<Bluddy[m]>
something like that
<randomA>
actually, dont i not need to use variants
<randomA>
i can just say they are keys
<randomA>
of type string
<Bluddy[m]>
you could. It's traditional to use variants, but you don't have to
<Bluddy[m]>
at least in this case you don't have to
<Bluddy[m]>
variants give you some nice properties, like knowing you covered the entire space of possibilities when you pattern match
<randomA>
ill try first, but i dont want be like two days late
<Bluddy[m]>
yeah do whatever it takes
<Bluddy[m]>
i gotta go to sleep. so should you.
<Bluddy[m]>
good luck
<randomA>
thanks!
<randomA>
and thanks for answering questions
lgstate has joined #ocaml
<lgstate>
is there by any chance any screen cast that walks thorugh step by step implementing each of the type checkers in TAPL? (the source is already online; but I'm looking for a screen cast)
osa1_ has joined #ocaml
osa1 has quit [Ping timeout: 265 seconds]
AlexDenisov has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
wxfdglm has quit [Ping timeout: 248 seconds]
MercurialAlchemi has joined #ocaml
jao has quit [Ping timeout: 272 seconds]
FreeBirdLjj has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
MercurialAlchemi has quit [Ping timeout: 265 seconds]
tmtwd has quit [Ping timeout: 272 seconds]
ccvv has joined #ocaml
lgstate has left #ocaml [#ocaml]
bruce_r has quit [Ping timeout: 272 seconds]
bruce_r has joined #ocaml
pierpa has quit [Ping timeout: 244 seconds]
MercurialAlchemi has joined #ocaml
bruce_r has quit [Ping timeout: 265 seconds]
michaeltbaker has quit []
bruce_r has joined #ocaml
Guest94222 is now known as kandu
osa1__ has joined #ocaml
osa1_ has quit [Ping timeout: 276 seconds]
igt0 has quit [Quit: Connection closed for inactivity]
copy` has quit [Quit: Connection closed for inactivity]
kolko has quit [Read error: Connection reset by peer]
kolko has joined #ocaml
osa1 has joined #ocaml
osa1__ has quit [Ping timeout: 264 seconds]
FreeBirdLjj has joined #ocaml
Simn has joined #ocaml
nojb has joined #ocaml
jnavila has joined #ocaml
apache2 has quit [Remote host closed the connection]
apache2 has joined #ocaml
bruce_r has quit [Ping timeout: 248 seconds]
larhat has quit [Quit: Leaving.]
AlexDenisov has joined #ocaml
osa1_ has joined #ocaml
osa1 has quit [Ping timeout: 244 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
jstolarek has joined #ocaml
AlexDenisov has quit [Ping timeout: 265 seconds]
Algebr` has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
Algebr` has joined #ocaml
osa1_ has quit [Remote host closed the connection]
osa1_ has joined #ocaml
AlexDenisov has quit [Client Quit]
nopf has joined #ocaml
Reshi has joined #ocaml
osa1_ has quit [Remote host closed the connection]
osa1_ has joined #ocaml
isbromberg has joined #ocaml
AlexDenisov has joined #ocaml
osa1_ has quit [Ping timeout: 265 seconds]
FreeBirdLjj has joined #ocaml
jwatzman|work has joined #ocaml
ocaml975 has quit [Ping timeout: 240 seconds]
mpenet has joined #ocaml
mfp has joined #ocaml
larhat has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mpenet` has joined #ocaml
johnf has quit [Read error: Connection reset by peer]
johnf has joined #ocaml
larhat has quit [Read error: Connection reset by peer]
larhat has joined #ocaml
mpenet has quit [Ping timeout: 244 seconds]
mpenet` has left #ocaml [#ocaml]
<dxtr>
I achieve some code yesterday!
<chelfi>
\o/
<dxtr>
I am not disappointed so far
bacam has quit [Quit: back in a moment]
bacam has joined #ocaml
<rightfold>
lgstate: thanks for that question, I always wondered about how to implement equirecursive types, and now I found an example by googling TAPL! :D
AlexDenisov has joined #ocaml
<companion_cube>
there is a github repo with some simple typecheckers
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AlexDenisov has joined #ocaml
jwatzman|work has joined #ocaml
<Algebr`>
anyone well versed in sql around
FreeBirdLjj has quit [Remote host closed the connection]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<rightfold>
Algebr`: yes
AlexDenisov has joined #ocaml
<Algebr`>
in sqlite: I created these tables, http://pastebin.com/pbDK51JS, and expected the last insert to fail but it still succeeded. How can I make it such that an insertion of an nonexistent primary key fails?
<MasseR>
don't you need to have a foreign key constraint?
CuriousErnestBro has joined #ocaml
<MasseR>
Err is my terminology wrong. The thing that is separate from foreign keys that declares *what* to do in case of a delete, insert etc
<Algebr`>
right, so I was thinking I needed to add constraint, but isn't that already created by foreign key implicitly?
<mrvn>
a foreign key is when you say one column contains the key to another table.
<MasseR>
Which dbms?
<Algebr`>
sqlite
<Algebr`>
right, but I want to say I can't do an insert into this event with a account id that doesn't exist in the account tbale
<Algebr`>
which is what I thought the foreign key would do
<mrvn>
let mul m s = List.map (List.map (( * ) s))
<mrvn>
let mul s = List.map (List.map (( * ) s)) I mean.
igt0 has joined #ocaml
<rightfold>
Don't use lists of lists for matrices, they don't have the guarantee that each row is same size
<rightfold>
Use a flattened sequence, then compute offset using x + width * y
<mrvn>
rightfold: why not array of arrays?
<rightfold>
Same issue
<mrvn>
you make the type private and only create the right ones.
<rightfold>
[|[|1|];[|2;3|]|] is malformed
<mrvn>
rightfold: [|1; 2; 3|] too
<rightfold>
Right XD
<rightfold>
HMM
<zozozo>
flattened array is a lot better for memory usage and prefetching
<rightfold>
If you're doing a mutable array, a flat array still has benefit
<orbifx-m>
So other than oml?
<mrvn>
A flattened array needs to also knwo the dimensions. Array of array has it in the block headers.
<orbifx-m>
And why not tuples?
<mrvn>
orbifx-m: needs code duplication to deal with 2, 3 and 4 dimensions.
<jnavila>
orbifx-m: have a look at lacaml
<mrvn>
I bet lots of peple have written their on vector and matrix module by now.
* mrvn
doesn't want to implement a 100x100 matrix with tuples.
<rightfold>
mrvn actually [|1;2;3|] is well formed
<rightfold>
1x3
<mrvn>
rightfold: assume the same 2x2 dimension
<orbifx-m>
Thanks jnavila
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<mrvn>
Might be beneficial to put the size of a vector / matrix into a phantom type. So you can multiply an NxM matix by a N vector to get a M vector. Or NxM * MxO = NxO.
<orbifx-m>
mrvn: it's not good that many write their own. Duplicated effort
<mrvn>
orbifx-m: no kidding
<orbifx-m>
jnavila: anything native?
<flux>
I can recommend 'gg'
<orbifx-m>
Hasn't bunzil written anything? :-P
<jnavila>
orbifx-m: what would be the sizes of the matrices and vectors?
isbromberg has quit [Quit: Konversation terminated!]
pootler has quit [Ping timeout: 240 seconds]
<Algebr`>
it can't even handle a file upload last I heard in this chan. The fact is ocaml community doesn't care about web dev at all
<Algebr`>
not in any serious way
<Algebr`>
oh well
freusque has joined #ocaml
<jnavila>
Algebr`: lately, Janestreet has been interested in web, so maybe they'll set up some saner system...
pootler has joined #ocaml
<MercurialAlchemi>
(I'll admit that I'm in the node + typescript boat myself)
<flux>
algebr`, I managed to make file upload working with eliom!
<Algebr`>
jnavila: and it will be all core based and then people will complain about that too...
<Algebr`>
MercurialAlchemi: its nuts how much and how fast you can build a product with node
<flux>
I don't think there's no compelling reason why ocaml couldn't be just as fast.. except we like to keep our types in order, and it's difficult :)
<flux>
another compelling reason: someone would need to write it :)
<Algebr`>
well people do have an interest, just in the reason & bucklescript land
<MercurialAlchemi>
Algebr`: well, I'm making an SPA with react and server-side rendering, it's not all roses either...
<Algebr`>
MercurialAlchemi: what issues are you hitting?
<rightfold>
Go is the sweet spot between development horror and deployment horror
<Algebr`>
ha
<MercurialAlchemi>
Algebr`: well, first to have server-side rendering you need to have both an ajax implementation and an sql-to-json version of your data retrival methods
<MercurialAlchemi>
also, in general React is great, but the "consensus" store library, Redux, is IMHO not that suited for SPAs
<MercurialAlchemi>
you end up with that giant state where you can't easily expose/synchronize sub-parts of between your pages
DrWhax has quit [Read error: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number]
<Algebr`>
true
profmaad has joined #ocaml
<MercurialAlchemi>
also, promises... make it very easy to forget to catch your errors
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sdothum has joined #ocaml
rgrinberg has quit [Ping timeout: 265 seconds]
AlexDenisov has joined #ocaml
Merv_ has joined #ocaml
pootler has quit [Ping timeout: 276 seconds]
Merv_ has quit [Client Quit]
TheLemonMan has joined #ocaml
fddf has quit [Quit: Page closed]
ggole has joined #ocaml
zaquest has quit [Remote host closed the connection]
zpe has quit [Remote host closed the connection]
Denommus has joined #ocaml
zaquest has joined #ocaml
pootler has joined #ocaml
osa1_ has joined #ocaml
wu_ng has quit [Ping timeout: 265 seconds]
freehck has joined #ocaml
nicholasf has joined #ocaml
osa1__ has joined #ocaml
osa1_ has quit [Ping timeout: 272 seconds]
nicholasf has quit [Ping timeout: 265 seconds]
Denommus has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<benmachine>
re: webdev stuff, I've been using incr_dom lately and it's fun, but it's really more for developing "apps" than, like, normal websites
<Algebr`>
benmachine: and you were able to actually get it installed?
<benmachine>
yes
<benmachine>
although I got it from the bleeding-edge repositories which, who knows, may have broken again by now
<Algebr`>
I felt like the API was way too heavy handed
<benmachine>
it's very, uh, particular
<benmachine>
about how you should do things
<benmachine>
but I found it fit me pretty well
<Algebr`>
benmachine: do you work at JS?
<benmachine>
yeeeees
<benmachine>
but I did this at home :P
<benmachine>
admittedly it does make it easier when you know the guy who wrote the library, but I'm not using any actual JS-specific resources
<benmachine>
(bad habit: talking about "JS" in a conversation about web scripting)
<Algebr`>
yes, I hosted the incr_dom presented in SF, Matt gave the talk
<Algebr`>
I gave it like 10 minutes of effort, then gave up, perhaps gave up too quickly
<benmachine>
heh
Denommus has joined #ocaml
<benmachine>
it definitely took me more than 10 minutes to get it working
jao has joined #ocaml
<benmachine>
but in fairness some of those struggles were getting aspcud on arch linux
<benmachine>
aspcud being in the AUR, and I didn't have a good AUR helper
<freehck>
Hello everyone. I've just read about PPX and want to be sure about one thing. AFAIK Camlp4 is an analog of cpp. Is PPX an analog of lisp macros?
<benmachine>
so I went looking for a package manager to install a package which would help my other package manager solve dependencies
<dxtr>
benmachine: I'm on a distro that didn't have aspcud or any of the dependencies
<Algebr`>
freehck: no, camlp4 is an actual macro system of sorts, cpp is just copy paste
<dxtr>
So I had to create all those packages :p
<Algebr`>
ppx is the successor of camlp4
<benmachine>
dxtr: congrats, you win :P
<dxtr>
:D
<dxtr>
Took like an hour, but still
<freehck>
Algebr`: I'm not sure I understand what "system of sorts" is.
<Algebr`>
freehck: what
<benmachine>
freehck: camlp4 is an actual macro system, of sorts
<benmachine>
is that clearer?
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<freehck>
benmachine: yes, thank you
<freehck>
So ppx has camlp4 in its base?
<benmachine>
no
<Algebr`>
no, I said successor
<benmachine>
ppx doesn't use camlp4, it replaces it
<benmachine>
well, ppx is far more limited in applications, but that's generally a good thing
<Algebr`>
benmachine: how much more limited
<companion_cube>
benmachine: for "normal websites", why would you need JS anyway? :p
<benmachine>
Algebr`: well, you can't do arbitrary syntax things
<freehck>
Okay. Well AST-to-AST translation seems to be quite similar to lisp macros still.
<Algebr`>
almost, there's a good Jane Street blog post about it
<benmachine>
companion_cube: to help manage your withdrawal symptoms
<freehck>
Algebr`: already read. :)
<benmachine>
companion_cube: actually I'm not sure that joke made a lot of sense, sorry :P
<benmachine>
companion_cube: but yeah I dunno, I build websites at either extreme of normality, either they are plain static HTML or some custom RPC server and websockets
<dxtr>
javascript abuse fuck yeah
govg has joined #ocaml
AlexDenisov has joined #ocaml
zpe has joined #ocaml
<rightfold>
javascript is always abuse
<companion_cube>
javabusescript
<dxtr>
Is it really abuse if you (the developer) consent?
osa1__ has quit [Ping timeout: 265 seconds]
<Algebr`>
smh
<Leonidas>
it's like when you're drunk and can't consent anymore
<Algebr`>
could we please leave these kinds of analogies...
<Algebr`>
does cohttp handle sessions?
nicholasf has joined #ocaml
nicholasf has quit [Ping timeout: 240 seconds]
<companion_cube>
hmm, an announce for otags
<companion_cube>
but who still uses otags? :D
copy` has joined #ocaml
wxfdglm has joined #ocaml
zpe has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
osa1__ has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
nicholasf has joined #ocaml
Leonidas has quit [Ping timeout: 265 seconds]
inco6 has joined #ocaml
ee_ks has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
<Bluddy[m]>
companion_cube: yeah I've been waiting for years for my Compuserve client to be updated
sepp2k has quit [Quit: Leaving.]
sepp2k has joined #ocaml
<reynir>
wow it just took me a few minutes to remember it's Lwt.Infix and not Lwt.Syntax or similar
ee_ks has left #ocaml [#ocaml]
freusque has quit [Quit: WeeChat 1.4]
rgrinberg has joined #ocaml
ee_ks has joined #ocaml
FreeBird_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 248 seconds]
kamog has joined #ocaml
inco6 has quit [K-Lined]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
jonasen has joined #ocaml
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
pierpa has joined #ocaml
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
bruce_r has joined #ocaml
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
jwatzman|work has quit [Quit: jwatzman|work]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
inco6 has joined #ocaml
inco6 has quit [Max SendQ exceeded]
osa1__ has left #ocaml ["Konversation terminated!"]
sh0t has joined #ocaml
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
govg has quit [Ping timeout: 265 seconds]
jnavila has quit [Quit: It was time]
jncog has joined #ocaml
jncog has quit [Max SendQ exceeded]
MercurialAlchemi has joined #ocaml
jncog has joined #ocaml
jncog has quit [Max SendQ exceeded]
jncog has joined #ocaml
jncog has quit [Max SendQ exceeded]
nicholasf has quit [Remote host closed the connection]
bruce_r has quit [Ping timeout: 255 seconds]
govg has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
jstolarek has quit [Ping timeout: 244 seconds]
<reynir>
googling 'cohttp xmlm' only gives results for 'http xml'
wxfdglm has quit [Ping timeout: 260 seconds]
govg has quit [Quit: leaving]
jwatzman|work has joined #ocaml
Merv_ has joined #ocaml
pootler has quit [Ping timeout: 265 seconds]
wxfdglm has joined #ocaml
tmtwd has joined #ocaml
slash^ has joined #ocaml
p_nathan has quit [Ping timeout: 244 seconds]
sepp2k has quit [Quit: Leaving.]
AlexRussia has quit [Ping timeout: 265 seconds]
Tinned_Tuna has joined #ocaml
Denommus has quit [Read error: Connection reset by peer]
<Tinned_Tuna>
Hi, I may be mis-using the Unix library. I'm getting a segmentation fault when I pass the empty array "[||]" to execv after calling setuid.
<flux>
tinned_tuna, cool, I think it means you have found a bug in the standard library!
<flux>
not a standard occurrence.
<zozozo>
shouldn't execv always start with the name of the binary ?
<flux>
yes. actually are you tinned_tuna sure it's ocaml that segfaults, and not the binary you run?
<flux>
well, not necessarily the name, but it should usually be something descriptive
<zozozo>
afaik, you have to do something like: Unix.execv bin [| bin; arguments; ... |]
<flux>
regardless of those, calling Unix.execv should not crash the ocaml program in any situation, with any parameters
<flux>
but I think it's still fair play for an ocaml binary to crash if given 0 arguments, although I guess that wouldn't be great either..
<ggole>
I tried that in the toplevel and got "A NULL argv[0] was passed through an exec system call."
<Tinned_Tuna>
It is the binary that I run, but it doesn't matter what binary I run
<Tinned_Tuna>
If it's not an OCaml bug, I think the docs should be updated :-)
<flux>
I doubt that's a case people test too hard. I believe it's invalid, but kernel might not validate it.
<zozozo>
ggole: I don't know how execv* functions are supposed to behave in a toplevel, as they are supposed to replace the current program
<Tinned_Tuna>
The docs aren't hugely clear, but I assume they're supposed to follow the stdlib (unistd) functions they are named for.
<flux>
my shell says: A NULL argv[0] was passed through an exec system call. zsh: abort ./foo
jonasen has joined #ocaml
orbifx-m2 has joined #ocaml
<ggole>
Yeah, the function in (OCaml's) execv.c doesn't check
apache2 has quit [Read error: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number]
<Tinned_Tuna>
ggole: should it? What does C do under those circumstances?
<ggole>
C doesn't give a damn.
<rightfold>
very few programs check for null argv[0]
<flux>
the error comes from whoami
apache2 has joined #ocaml
<flux>
as you can see with sudo strace ./foo
apache2 has quit [Client Quit]
orbifx-m has quit [Ping timeout: 244 seconds]
<flux>
the execve succeeds in running whoami, and the control flow is from there on in that binary
<flux>
so ocaml works correctly
orbifx-m has joined #ocaml
<ggole>
Try it with different executable
<Tinned_Tuna>
ggole: ok, I'll take a lok
<Tinned_Tuna>
*look
jwatzman|work has quit [Quit: jwatzman|work]
FreeBird_ has quit [Remote host closed the connection]
<Tinned_Tuna>
Yup, it works for better binaries. I'd only check /bin/sh and /usr/bin/whoami previously
<Tinned_Tuna>
/usr/bin/host works just fine.
orbifx-m2 has quit [Ping timeout: 250 seconds]
<ggole>
A bunch of "system" binaries give the same response, so it's probably just some more careful checking there
<ggole>
My guess is that there is some GNU library with that logic
<flux>
could be a security measure of some sort in util-linux (not sure if those are part of it)
<flux>
the lesson here is,: don't do it :)
larhat has quit [Quit: Leaving.]
<Tinned_Tuna>
In the future I'll make sure the arrays are non-empty :-p
octachron has quit [Quit: Page closed]
<flux>
well, as said, you're supposed to put the program name as argument 0
DuoSRX has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
wxfdglm has quit [Quit: leaving]
chris2 has quit [Ping timeout: 272 seconds]
kamog has quit [Ping timeout: 265 seconds]
wu_ng has joined #ocaml
ee_ks has left #ocaml [#ocaml]
tane has joined #ocaml
kamog has joined #ocaml
Merv_ has quit [Remote host closed the connection]
kamog has quit [Ping timeout: 248 seconds]
orbifx-m2 has joined #ocaml
orbifx-m has quit [Ping timeout: 272 seconds]
chris2 has joined #ocaml
rgrinberg has quit [Ping timeout: 272 seconds]
CuriousErnestBro has quit [Quit: Leaving]
CuriousErnestBro has joined #ocaml
rgrinberg has joined #ocaml
johnf has quit [Remote host closed the connection]
orbifx-m has joined #ocaml
orbifx-m2 has quit [Ping timeout: 255 seconds]
AlexDenisov has joined #ocaml
wu_ng has quit [Ping timeout: 248 seconds]
Algebr` has quit [Ping timeout: 240 seconds]
AlexRussia has joined #ocaml
orbifx-m2 has joined #ocaml
orbifx-m3 has joined #ocaml
orbifx-m has quit [Ping timeout: 276 seconds]
orbifx-m2 has quit [Ping timeout: 272 seconds]
octachron has joined #ocaml
orbifx has joined #ocaml
orbifx-m3 has quit [Ping timeout: 240 seconds]
rgrinberg has quit [Quit: WeeChat 1.5]
rgrinberg has joined #ocaml
<orbifx>
what do you use for documenting ocaml code? is there something which generates doc files?
slash^ has quit [Read error: Connection reset by peer]
<orbifx>
and is it better to create mli files manually?
<orbifx>
ocamldoc?
<tane>
I guess most modules are actually documented in their mli files
octachron has quit [Ping timeout: 248 seconds]
<orbifx>
and do you generate the mli's manually?
<orbifx>
because if they are autogenerated and I change the ml file I can't then auto-generate again, right?
<ggole>
You can rename the .ml, generate the .mli, and then paste in the new bits
<ggole>
It's clumsy but workable.
<orbifx>
yeah good idea
<flux>
I think usually .ml files live so little that you can copy individual function signatures with ie. emacs (go over function, ^C^T^W, then write val foo : ^Y)
<flux>
so simple it could even be an emacs function ;)
octachron has joined #ocaml
traceroutelol is now known as djsjadkhf
kamog has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 276 seconds]
nicholasf has joined #ocaml
<orbifx>
and is the a build system which handles generating ocamldoc documentation?
<companion_cube>
ocamlbuild can drive ocamldoc
jlouis has quit [Quit: leaving]
jlouis has joined #ocaml
jlouis has quit [Client Quit]
jlouis has joined #ocaml
pootler has joined #ocaml
jlouis has quit [Client Quit]
jlouis has joined #ocaml
jlouis has quit [Client Quit]
jlouis has joined #ocaml
tane has quit [Quit: Leaving]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
octachron has quit [Quit: Leaving]
struk|desk has quit [Remote host closed the connection]
_andre has quit [Quit: leaving]
orbifx has quit [Ping timeout: 255 seconds]
Lethe_ has joined #ocaml
ggole has quit []
rgrinberg has quit [Ping timeout: 244 seconds]
<Lethe_>
hi,
Lethe_ has quit [Quit: Leaving...]
randomA has joined #ocaml
<randomA>
hi
<randomA>
how can i pattern match parse yojson
<randomA>
into recrod tyepes
<randomA>
types that are record
<randomA>
I know I use `Assoc
<randomA>
don't know specifi
<randomA>
is this with yojson safe
<lyxia>
randomA: the three Yojson modules Basic, Raw, Safe provide similar functionality. Which one you choose depends on how hard your values exercise the JSON syntax.
<randomA>
the json format is short
<randomA>
i just need to parse into record types
<lyxia>
Is your JSON a dictionary with the names of the fields as keys?
<randomA>
kind of
<randomA>
yeah
<randomA>
its a normal json format
<randomA>
but it will have things like records
<randomA>
i have structured my records excatly as they hae structured theirs
<randomA>
so i was thinking match json with | {name = n; id = id;} -> createName n id
<randomA>
where creates a record type with fields name id same as json