j7k618 has quit [Remote host closed the connection]
MadcapJake has quit [Quit: MadcapJake]
sagotch has joined #ocaml
<dh_work>
sigh
<dh_work>
how can he write compcert and still think that?
adrien has quit [Ping timeout: 252 seconds]
Asmadeus has quit [Ping timeout: 246 seconds]
sagotch has quit [Ping timeout: 244 seconds]
sagotch has joined #ocaml
keep_learning_M has quit [Quit: This computer has gone to sleep]
hfjvjffju has quit [Ping timeout: 250 seconds]
bytesighs has quit [Ping timeout: 250 seconds]
metadave has quit [Ping timeout: 250 seconds]
rfv has quit [Ping timeout: 250 seconds]
metadave has joined #ocaml
adi_______ has quit [Ping timeout: 250 seconds]
adi_______ has joined #ocaml
rfv has joined #ocaml
bytesighs has joined #ocaml
hfjvjffju has joined #ocaml
Ou42 has joined #ocaml
<Ou42>
hello
<Ou42>
noobie needing a bit of help...
<Ou42>
huh... i can't seem to copy/paste the error... but it's a type issue. I'd like to use Printf.printf a tupple, but it's a module and then use ";" d
<Ou42>
if i just "return" d it works, but if i add the Printf.printf before it... i get:
sagotch has quit [Read error: Connection timed out]
sagotch has joined #ocaml
<Ou42>
Values do not match:
<Ou42>
val remove : (int, int) t -> 'a -> (int, int) t
<Ou42>
is not included in
<Ou42>
val remove : ('key, 'value) t -> 'key -> ('key, 'value) t
<Ou42>
... so my Q is, how to print out a ('key, 'value) if by including a Printf.printf it seems to be setting their type more specrfically and then fails the type checking
oni-on-ion has joined #ocaml
<Ou42>
hello (again?) on_ion.
Habib has quit [Quit: Habib]
<Ou42>
modules are a blessing and a CURSE. more a curse at the moment. :p
<Ou42>
So, data hiding means exactly that. Add to that parametric polymorphism or whatever it is called, OCaml doesn't know the type of the data other than giving it a tag... meaning it can't print it out as it isn't set. it could be something else.
<Ou42>
so, I moved my min function outside the module. that got me further, but not enough. I had to have access to the ADT's ( constructors? ) outside the module... so I just took out the "sig" part and now I can test things!
sagotch has quit [Quit: Leaving.]
Habib has joined #ocaml
Jeanne-Kamikaze has quit [Remote host closed the connection]
* Ou42
slaps Ou42 with the power of greyskull
vztr has joined #ocaml
vztr_ has joined #ocaml
vztr_ has quit [Client Quit]
vztr has quit [Quit: Page closed]
freyr69 has joined #ocaml
sagotch has joined #ocaml
kalio has quit [Ping timeout: 240 seconds]
kalio has joined #ocaml
<Habib>
Anyone know if it's possible to use ReasonReact with OCaml syntax, but get JSX syntax without the [%bsx …] wrapper that ppx_bsx forces?
orbifx1 has joined #ocaml
freyr69 has quit [Ping timeout: 240 seconds]
ggole has joined #ocaml
Guest99739 has joined #ocaml
Habib has left #ocaml [#ocaml]
nicoo has quit [Ping timeout: 256 seconds]
freyr69 has joined #ocaml
orbifx1 has quit [Ping timeout: 272 seconds]
nicoo has joined #ocaml
Guest99739 has quit [Remote host closed the connection]
Haudegen has joined #ocaml
jaar has joined #ocaml
adrien has joined #ocaml
<Ou42>
hello
<Ou42>
i'm taking the FUN MOOC class.
<Ou42>
late join if you like! & I'm not saying that so I can cheat off your homework! :D
<Ou42>
What's wrong with: let d = Dict.empty in let d = Dict.add d "Carrot" 1 in let d = Dict.add d "Apple" 2 in let d = Dict.add d "Banana" 3 in d;; ?
keep_learning_M has joined #ocaml
<Ou42>
They use something similar ( different order of strings and different ints) in the grader, but in the class toplevel/repl after issuing the command, inputing "d" by itself gives an error
<Ou42>
OK, nevermind, I think. I just neeed to assign all that to another "variable"
<ggole>
Ou42: let x = 0 in <body> binds x only within <body>. It is out of scope elsewhere.
<Ou42>
ggole I think i follow... as that coincides with my discovery by preappending let e = <everything I typed before> I can access the "e" var
<ggole>
Yes, you can leave the 'in' off at top level to make a global binding.
<Ou42>
hadn't caught that before. I knew FP was different, but it's much more different than how I think.
<ggole>
Do you understand how to make the binding you want now?
<Ou42>
yes, now I'm on to the next hurdle. ;o)
<ggole>
Ok.
<Ou42>
ggole: TYVM
<Ou42>
if I may... these will be NOOBIE Q's... I know, but still having trouble wrapping my head around this...
<Ou42>
The assignment is coding a remove function for a module Dict, We were given the signature, and most of the struct except for remove.
<Ou42>
In order to see what was going on -- and this took me a while to figure out as I tried the hard ways 1st -- I removed the sig and just left in my struct.
<ggole>
Right, that can be useful.
<Ou42>
I can fill in more if desired, here's Q#2: toplevel says al e : (string, int) Dict.t =
<Ou42>
OK, sorry for scroll. will work on copy/paste. val e : (string, int) Dict.t <<<==== wasn't paying attention... NOOBIE eyes. Thought we were using a List, but no, this is a TUPLE, right? a Recursive Tuple data structure?
<ggole>
This is a two argument type, rather than a tuple.
<ggole>
Tuples types in OCaml are written like a * b * c.
<Ou42>
hold on... lemme paste the given type
<ggole>
Strangely, arguments to type constructors are on the left.
<ggole>
So the (string, int) is an argument list.
<Ou42>
yes! very oldd and the types are lower case!
<Ou42>
type ('key, 'value) t = | Empty | Node of ('key, 'value) t * 'key * 'value * ('key, 'value) t
<Ou42>
Dict is the name of the module. (mostly) got that. So, just like other languages/namespace things... Dict.t
<Ou42>
but what is t?
<ggole>
It's conventional in OCaml to use the name t to refer to the main type of a module (if there is one).
<ggole>
This is because modules are often used unqualified, and it would be redundant to state the same thing twice, eg, Dict.dict
slamzy has joined #ocaml
<ggole>
Instead you have Dict.t, Hashtbl.t, etc
<Ou42>
but 'key, 'value aren't given until they are sent in values... so this is that polymorphic side of things.
<ggole>
That's right.
<ggole>
The ' indicates a type variable.
<Ou42>
but t isn't really anything, right?
<ggole>
t is the name of the data type.
<ggole>
You could put any (lowercase) name in there.
<Ou42>
I should write down all this and publish a book. There's got to be other noobs like me!
<Ou42>
I just noticed something... maybe it'll help you help me. ;o)
<Ou42>
I'm viewing OCaml like chess. There are a ton of chessbook, but none accept that there are some of us that are downright blind and just need 10 sequential ah-ha moments to finally see it and become the grandmasters we're destined to be... :D
slamzy has quit [Remote host closed the connection]
mfp has joined #ocaml
<Ou42>
( or, if you prefer a more serious explanation of that: many authors have forgotten what it was like to "not get it" and they themselves are skipping steps, cutting corners, being efficient ... and in some cases forgetting that those very steps are huge leaps for noobs )
<ggole>
Yes, that's a tricky problem.
<Ou42>
yes. ok back to the prob, I don't want to belabor this. you're being most helpful. Is Dict.t only a None or an Empty?
<ggole>
That's right. The definition of t you pasted above describes which values can have type t.
<Ou42>
that might qualify as an ah-ha moment! TY
<Ou42>
but here's my issue... I would love to have a ton of print statements to follow what is going on. ;o)
<Ou42>
or at the very least to be able to access the Dict... but I cannot, correct? It is the purpose of the module to "data hide" and not let the "user" have access directly, correct?
<ggole>
If you provide a signature, it will hide any information not given in the signature, yes.
<Ou42>
that explains why I couldn't pattern match outside the module. OK, ah-ha #2.
<Ou42>
but the ah-ha 1.5 is somewhere between the 2... I'm just unwilling to accept it.
<ggole>
If you wish to do that, you will have to write a print function and export it in the signature.
<Ou42>
of all the permutations, I didn't hit that one. go figure. good idea.
<ggole>
(There are actually some other possibilities, but they are perhaps bit on the advanced side for a beginner.)
<Ou42>
yes, basic is better. & in prior hw I tried hard to solve the problems with what was presented.
<Ou42>
little did I know that opening up and accessing things not yet taught would very well be opening pandora's box. noobies be afraid.
<ggole>
That's all part of the fun.
<Ou42>
but I did get lucky and a SO post explained how to imbed print statements. They helped for prior HW, but not this HW. I got type errors.
<Ou42>
OK, so I guess my current issue is not understanding the add function. the order given above I created a Dict.empty then added a Carrot, Apple, and Banana, in that order. But the output doesn't appear to be in that order. So, *ahem* in python I would be writing out a bunch of print statements and try to get an understanding of how the data was stored. What is the equivalent of this in OCaml?
<Ou42>
I assumed Carrot would be the root, but how to access the root and see if it is indeed a Carrot?
<ggole>
OCaml has printf, so you could use that.
<ggole>
There is a significant limitation, which is that printf does not handle datatypes by default - you have to write your own printer.
<ggole>
The alternative is to comment out the signature so that the constructors are exposed and try things in the toplevel.
<Ou42>
yeah, I tried getting printf to work, that's when I finally figured out to remove the sig.
<Ou42>
I also learned that printf inside the module was useless... the types were polymorphic inside the module.
<ggole>
You can make that work by passing printers for them
<Ou42>
I "proved" that Carrot is at the root!!! match e with | Empty -> "nada" | Dict.Node (l, k', v', r) -> k' ;;
<Ou42>
ggole: that's too advance, unless you think I should research that at this time. Besides, it's not the FP way, right?
jao has joined #ocaml
<ggole>
Passing functions around is pretty FP :)
<Ou42>
ha. touche.
<ggole>
Oh, there's also #trace
<ggole>
That might be helpful.
<Ou42>
granted I've only briefly done it in one assignment and I'm no where near proficient in func passing. #trace doesn't work in the class toplevel or on try.ocamlpro.com
<ggole>
Oh, huh.
<Ou42>
the class toplevel does seem to have some nice extra features though... it auto appends ;;
<Ou42>
but lemme fire up the VM.
<Ou42>
running one-tab first was a slight mistake. lost some work. :p
<Ou42>
well, at least I'll get some more repetition.
keep_learning_M has quit [Quit: Leaving]
<Ou42>
is there input history in OCaml toplevel w/o installing anything extra?
<ggole>
I don't think so - I always use it from emacs, where that kind of thing is provided
<ggole>
There's a 'fancy' toplevel called utop that does a lot more, but that would fall under 'installing anything extra'
<Ou42>
I also don't have the ability to edit the line I've pasted. grrr.
<Ou42>
I'm gettin ^[[D for left arrow and ^[[C for right. ddg'ing as we speak.
<ggole>
I suppose that rlwrap would also work
<Ou42>
I think I've heard of both! but only once each. so that's 2x now. ;o)
jaar has quit [Ping timeout: 252 seconds]
<Ou42>
ggole's insights confirmed: "[OCaml's toplevel] ... there is no editing support: you cannot conveniently change what you type nor can you rewind to previously typed phrases." https://opam.ocaml.org/blog/about-utop/
<Ou42>
"[ERROR] The compilation of conf-m4 failed ..." install is proceeding.
<Ou42>
kudos to the MOOC ppl for realizing that sw installation is still a sticky wicket(sp?) ;o)
jaar has joined #ocaml
<Ou42>
ggole TYVM for all the help! I'll def rem this once I have my job at JaneStreet. ;o)
keep_learning_M has joined #ocaml
keep_learning_M has quit [Quit: Leaving]
keep_learning_M has joined #ocaml
* Ou42
facepalm
<Ou42>
OK! should have gone to bed. This is me ... learning. It's ugly. It's painful and sometimes it's downright just sad.
<Ou42>
code for add(ing) to a BST was given. To test things I created one using keys they used... but I assumed the wrong shape of the tree. :p
<Ou42>
my order / attention to detail is (way) off.
<Ou42>
if one adds: Carrot, then Apple, then Banana, Carrot will be at the root... but why did I think that Apple was < Carrot and Banana was > Carrot?!
<Ou42>
but it was reading the output that was confusing... parens etc. perhaps a graphical print func is in order!
officialseb has joined #ocaml
officialseb is now known as Guest28135
carlosdagos has quit [Quit: Connection closed for inactivity]
<Ou42>
there are times when Ctrl+V should NOT be next to Ctrl+C.
ollehar has joined #ocaml
* Ou42
sheds a tear
<Ou42>
FYI, Ctrl+Z isn't working. :p
TC01 has quit [Ping timeout: 246 seconds]
wagle has quit [Remote host closed the connection]
wagle has joined #ocaml
Guest28135 has quit [Remote host closed the connection]
jao has quit [Ping timeout: 250 seconds]
asymptotically has joined #ocaml
<Ou42>
so, my remaining issues were my inability to visualize and/or keep track of the, for lack of a better term, "shape" of the BST. I only had 3 nodes and yet I wasn't seeing it correctly. Go figure!
zv has quit [Ping timeout: 252 seconds]
<Ou42>
Once I got enough of a footing on the shape of the BST, I was able to implement the algorithm I found online. Gotta cite it now & should probably document the code A LOT! :p
<Ou42>
but I haven't found it and it'd take me a while to find the solution I did come up with! ;oP
FreeBirdLjj has joined #ocaml
<Ou42>
OK, found my 8 block solution. Still no clue on a 7 block solution.
<lyxia>
it probably involves the fact that the machine is a stack machine
jao has joined #ocaml
freyr69 has quit [Remote host closed the connection]
<Ou42>
lyxia: meaning that it will add to the stack everything that is in "F1" or "F2" when either of those blocks are called? here's one that initially looks daunting... but well, you have to hit every square: http://www.robozzle.com/beta/index.html?puzzle=483
<lyxia>
yes
<lyxia>
did you solve that last one, looks pretty big indeed
<Ou42>
lyxia: I sorta follow, but haven't yet figured out how to get a "tail" of "go, but turn left on blue instead of right"
<Ou42>
yes, but again, i'd have to play around to see if i could get it again... this was more recent though....
<Ou42>
... but not getting it. :p
GreyFaceNoSpace has quit [Quit: Ex-Chat]
<Ou42>
i cheated. had my solution for that one save.
* Ou42
holds head in shame.
<Ou42>
I'm gonna try to catch some Z's.
<Ou42>
g'nite #ocaml
Ou42 has quit [Quit: Going offline, see ya! (www.adiirc.com)]
sagotch has quit [Quit: Leaving.]
<enikar>
I haven't eve
<enikar>
oops…
<enikar>
I have not undunerstand this game.
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
habnabit has quit [Ping timeout: 250 seconds]
_habnabit has joined #ocaml
slamzy has quit [Remote host closed the connection]
_habnabit has quit [Read error: Connection reset by peer]
_habnabit has joined #ocaml
zv has quit [Ping timeout: 252 seconds]
sagotch has joined #ocaml
zv has joined #ocaml
jbrown has quit [Ping timeout: 252 seconds]
jbrown has joined #ocaml
ziyourenxiang has quit [Remote host closed the connection]
ziyourenxiang has joined #ocaml
sagotch has quit [Quit: Leaving.]
waleee has quit [Quit: WeeChat 2.3]
tane has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
ollehar has quit [Ping timeout: 276 seconds]
govg has joined #ocaml
ygrek__ has joined #ocaml
slamzy has joined #ocaml
slamzy has quit [Ping timeout: 256 seconds]
FreeBirdLjj has joined #ocaml
ggole has quit [Quit: ggole]
slamzy has joined #ocaml
slamzy has quit [Remote host closed the connection]
al-damiri has joined #ocaml
steenuil has joined #ocaml
orbifx1 has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Haudegen has quit [Remote host closed the connection]
orbifx1 has quit [Ping timeout: 250 seconds]
fraxamo has joined #ocaml
jaar has quit [Ping timeout: 244 seconds]
asymptotically has quit [Remote host closed the connection]
dtornabene has joined #ocaml
jnavila has joined #ocaml
asymptotically has joined #ocaml
ygrek__ has quit [Ping timeout: 252 seconds]
kakadu_ has joined #ocaml
ocabot has quit [Remote host closed the connection]
companion_cube has quit [Remote host closed the connection]
ocabot has joined #ocaml
companion_cube has joined #ocaml
pierpal has quit [Ping timeout: 252 seconds]
Jesin has quit [Quit: Leaving]
asymptotically has quit [Quit: Leaving]
jbrown has quit [Ping timeout: 276 seconds]
Jesin has joined #ocaml
metreo has joined #ocaml
metreo has quit [Changing host]
metreo has joined #ocaml
jaar has joined #ocaml
pierpal has joined #ocaml
jbrown has joined #ocaml
jnavila has quit [Ping timeout: 245 seconds]
Jesin has quit [Quit: Leaving]
fraxamo has quit [Quit: Leaving]
Jesin has joined #ocaml
spew has quit [Quit: going home]
clownpriest has joined #ocaml
jnavila has joined #ocaml
quipa has joined #ocaml
nikivi has joined #ocaml
quipa has quit [Remote host closed the connection]
quipa has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
dtornabene has quit [Quit: Leaving]
jnavila has quit [Ping timeout: 246 seconds]
orbifx1 has joined #ocaml
bartholin has quit [Remote host closed the connection]
tane has quit [Quit: Leaving]
orbifx1 has quit [Ping timeout: 268 seconds]
webshinra has quit [Remote host closed the connection]
slamzy has joined #ocaml
jao has quit [Ping timeout: 260 seconds]
jao has joined #ocaml
orbifx1 has joined #ocaml
kakadu_ has quit [Remote host closed the connection]
jnavila has joined #ocaml
keep_learning_M has joined #ocaml
jnavila has quit [Remote host closed the connection]
orbifx1 has quit [Ping timeout: 246 seconds]
keep_learning_M has quit [Quit: This computer has gone to sleep]
slamzy1234 has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]