rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vicfred has quit [Quit: Leaving]
drakonis has joined #ocaml
<zebrag>
`opam search -a lwt.unix` => "No matches found"
<zebrag>
right, it is a library, not a package
chrisz has quit [Ping timeout: 240 seconds]
<zebrag>
dune file `(librairies ... lwt.unix)`, then `utop`, then `#use_output "dune ocaml top";;`, the latter command does not return.
chrisz has joined #ocaml
<zebrag>
pasting the output of `dune ocaml utop` in `utop` is working though
kaph has quit [Read error: Connection reset by peer]
kaph_ has joined #ocaml
bobo has joined #ocaml
spip has quit [Ping timeout: 246 seconds]
rgrinberg has joined #ocaml
kaph_ has quit [Ping timeout: 240 seconds]
tizoc has quit [Quit: Coyote finally caught me]
tizoc has joined #ocaml
motherfsck has quit [Ping timeout: 250 seconds]
zebrag has quit [Quit: Konversation terminated!]
gravicappa has joined #ocaml
shawnw has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vsiles_ is now known as vsiles
dextaa has joined #ocaml
bartholin has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
Haudegen has joined #ocaml
waleee has joined #ocaml
olle has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
perrierjouet has quit [Ping timeout: 250 seconds]
perrierjouet has joined #ocaml
rks` has quit [Ping timeout: 240 seconds]
bartholin has quit [Ping timeout: 246 seconds]
bartholin has joined #ocaml
kaph has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
kaph_ has joined #ocaml
kaph has quit [Read error: Connection reset by peer]
wyrd has quit [Remote host closed the connection]
dextaa has quit [Ping timeout: 256 seconds]
wyrd has joined #ocaml
bobo has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
waleee has joined #ocaml
kaph_ has quit [Ping timeout: 246 seconds]
olle has quit [Ping timeout: 240 seconds]
shawnw has quit [Ping timeout: 256 seconds]
quartz has joined #ocaml
<quartz>
Hello. When I try to compile this code using "ocamlyacc" I get the error: File "parser.mly", line 67: $7 refers to terminal `COLON', which has no argument I'm not sure why.
<d_bot>
<NULL> I thought indexed arguments were a bad idea in yacc-like tools
<companion_cube>
yeah, don't use ocamlyacc anyway
<companion_cube>
use menhir
<d_bot>
<NULL> In any case, not sure how the message is unclear : `$7 refers to terminal 'COLON', which has no argument` yet you refer to this terminal as argument to `rtype` (you probably mean $6 if you use indexed arguments)
<quartz>
I'm sorry I'm not sure what you mean by 'indexed arguements'
<d_bot>
<NULL> $n
<quartz>
It's not a good idea to use those?
<d_bot>
<NULL> No, it's safer to name what you want to get in the patterns directly
<quartz>
And sorry, but why is it $6 and not $7?
<d_bot>
<NULL> $7 is the 7th thing on your pattern, `COLON`; $6 is the 6th, `typ`
<quartz>
Sorry for all the dumb questions, I'm trying to understand the code. DEF, IDENTIFIER, LPAREN are all terminals?
<d_bot>
<NULL> All caps names are traditionally terminals yes
<d_bot>
<NULL> Not sure with yacc, but I think they only need to be capitalised in menhir
<d_bot>
<NULL> Nonterminals are lowercase
<quartz>
But what is 'rtype', 'fname', 'formals'
<d_bot>
<NULL> The names [supposedly] you gave to fields to represent your construction
<d_bot>
<NULL> This is an OCaml record value definition
<quartz>
What do you mean by construction? Like the grammar?
<d_bot>
<NULL> In this case it looks like you're parsing a function definition, so the RHS is how you are going to represent this definition in OCaml to work on it after parsing
<quartz>
I thought this was suppose to implement the indentation feature in python
<quartz>
Because I don't want to use curly braces.
<d_bot>
<NULL> It's not
<quartz>
Oh
<quartz>
I thought the DEDENT and INDENT tokens were there for that
<d_bot>
<NULL> Or rather, you describe where you want indents and dedents everywhere they should happen, so this part is spread over many constructions
<quartz>
I just wanted to isolate the part where they implement the indentation feature, like in python.
<quartz>
But I suppose that's impossible with this code.
<d_bot>
<NULL> Even if they aren't characters, you still need an opening and closing element for your function definitions (and everything else that needs them)
<d_bot>
<NULL> In Python's case, they are INDENT and DEDENT, so you mention them where you want to require thel
<d_bot>
<NULL> them*
<quartz>
Right, the scanner uses a stack to keep track of the number of tabs
<quartz>
The tokens are generated in the parser, based on the status of the stack, or so I think
<d_bot>
<NULL> The lexer generates the tokens and feeds them to the parser
<quartz>
Oh right :)
<d_bot>
<NULL> The lexer is responsible for detecting and correctly understanding indents and dedents
<d_bot>
<NULL> The parser merely states where they are needed in every language construction (like in function definitions)
<d_bot>
<NULL> That's why I said that this doesn't implement indents/dedents: the lexer does. The parser parses them as any other token
<quartz>
Hmm
<d_bot>
<NULL> If the lexer returned INDENT when it read a { and DEDENT when it read a }, the parser would work just as well
<quartz>
Well In that case... my scanner (lexer), should work. It just uses a stack to count the number of tabs. you can see it here: https://bpa.st/I57A
<quartz>
The lexer is more clear than the parser in terms of implementing the indentation feature
<d_bot>
<NULL> Again, at no point does the parser "implement indentation"
<d_bot>
<NULL> nor is it supposed to
<d_bot>
<NULL> It reads tokens that just so happen to be named INDENT and DEDENT
<quartz>
So the entire implementation of the indentation feature happens in the lexer
<d_bot>
<NULL> Yes
<d_bot>
<NULL> Your tab counter, if well implemented, is the whole indentation mechanism
<d_bot>
<NULL> (BTW, do you really want tabs and not spaces or a mix for indentation ?)
<quartz>
Yes, I looked it up, the implementation is very standard. Use a stack, count spaces
<quartz>
Uhhh good question
<quartz>
I believe it counts tabs
mro has joined #ocaml
motherfsck has joined #ocaml
<d_bot>
<RegularSpatula> Interesting discussions…just curious, what is this for, quartz?
<quartz>
I'm trying to make my own programming language using OCaml
<quartz>
At the moment, I'm trying to implement the indentation feature.
<quartz>
I feel my lexer/scanner is well implemented, but I'm trying to get things working on the parser end.
Haudegen has quit [Ping timeout: 250 seconds]
Haudegen has joined #ocaml
quartz has quit [Quit: WeeChat 3.5]
rks` has joined #ocaml
kaph_ has joined #ocaml
<olle>
Without Menhir?
<d_bot>
<darrenldl> i tend to shy away from space sensitive lang designs
<d_bot>
<darrenldl> but i am curious how it works out in practice
rgrinberg has joined #ocaml
bartholin has quit [Quit: Leaving]
gravicappa has joined #ocaml
mro has quit [Remote host closed the connection]
vicfred has joined #ocaml
<d_bot>
<Ambika E.> Does the compiler optimize away consecutive `List.map` and similar things?
<companion_cube>
nope
<companion_cube>
and it's wrong to turn `List.map f @@ List.map g l` into `List.map (f << g) l`
<companion_cube>
(side effects)
<d_bot>
<Ambika E.> fair enough
<d_bot>
<Ambika E.> thanks
<Corbin>
Well, that neatly explains why compiling to OCaml didn't do what I'd hoped. Does the OCaml compiler implement the optimizations for r-closed expressions, at least?
<companion_cube>
what's a r-closed expression?
mro has joined #ocaml
<Corbin>
p17 of "The Categorical Abstract Machine: Basics and Enhancements": "An expression is called r-closed if the environment is not necessary for its computation." This begins a series of CAM optimizations, culminating in TCO for letrecs.
<companion_cube>
but it can still depend on globals, right?
mro has quit [Remote host closed the connection]
<d_bot>
<Ambika E.> Environment includes globals no? So I'd think not?
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Corbin>
According to the footnote on "necessary": "The word 'necessary' should not be taken too literally. The body of the abstraction `fun n -> if true then 0 else n` is not r-closed although the else-branch is never entered."
<drakonis>
Corbin: i thought you liked haskell?
<Corbin>
drakonis: Sure. Haskell can only do this map-fusion optimization on pure lists; doing it on Monads is trickier and can invoke the dreaded `sequence` combinator, which can run in quadratic time depending on the monad.
<drakonis>
i'm actually surprised you're here using ocaml
<Corbin>
Oh. Nah, I don't really care about belonging to only one tribe. TBH I think tribalism is kind of silly?
<drakonis>
i see
<drakonis>
companion_cube: do you know what's up with 4.14.0+options?
<drakonis>
rather
<drakonis>
what the options patchset does?
<drakonis>
the tribalism is indeed quite silly
<drakonis>
plus i think the haskell community can be a bit weird
<companion_cube>
I have absolutely no idea
<companion_cube>
the right person to ask, as always, is octachron
<octachron>
The ocaml-option-* packages correspond mostly to configuration flags.
<drakonis>
oic
gravicappa has quit [Ping timeout: 256 seconds]
sparogy has quit [Remote host closed the connection]
sparogy has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 248 seconds]
mro_ has quit [Remote host closed the connection]
mro has joined #ocaml
spip has joined #ocaml
kaph_ has quit [Ping timeout: 256 seconds]
olle has quit [Ping timeout: 240 seconds]
rgrinberg has joined #ocaml
quartz has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Quit: Leaving...]
Haudegen has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<quartz>
Can someone tell me what lines 67 - 72 are doing? https://bpa.st/22SA