companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
brettgilio has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
brettgilio has joined #ocaml
kanishka has quit [Quit: Quit]
nullcone has joined #ocaml
mfp has quit [Ping timeout: 246 seconds]
gjaldon_ has quit [Quit: Connection closed for inactivity]
waleee-cl has quit [Quit: Connection closed for inactivity]
kleisli_ has joined #ocaml
kleisli__ has quit [Ping timeout: 260 seconds]
osa1 has joined #ocaml
_whitelogger has joined #ocaml
<d_bot> <dj charlie> @Et7f3 i want to use rtop inside an environment that can't interpret control codes/colour
<d_bot> <dj charlie> that's the q
<d_bot> <dj charlie> (so i can use reason in the toplevel there)
inkbottle has joined #ocaml
zebrag has quit [Ping timeout: 264 seconds]
osa1 has quit [Ping timeout: 256 seconds]
narimiran has joined #ocaml
<inkbottle> You can define `let (and+) = ( * );;` But when you try to use it, the answer seems to suggest the types are more predetermined, and the definition shouldn't have been accepted in the first place
<inkbottle> Is it `and***` that has its type constrained to `'a t -> 'b t -> ('a * 'b) t`, and `let***` that must have its type one of `'a t -> ('a -> 'b) -> 'b t` or `'a t -> ('a -> 'b t) -> 'b t`?
wagle has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
wagle has joined #ocaml
brown121407 has quit [Quit: ZNC 1.8.2 - https://znc.in]
brown121407 has joined #ocaml
dckc has quit [Ping timeout: 264 seconds]
remexre has quit [Remote host closed the connection]
dckc has joined #ocaml
remexre has joined #ocaml
vicfred has quit [Quit: Leaving]
osa1 has joined #ocaml
reynir has quit [Ping timeout: 246 seconds]
reynir has joined #ocaml
vicfred has joined #ocaml
kleisli_ has quit [Quit: Leaving]
reynir has quit [Ping timeout: 260 seconds]
reynir has joined #ocaml
osa1 has quit [Ping timeout: 260 seconds]
kleisli has joined #ocaml
kleisli is now known as dillon
dillon is now known as endorphin
brown121407 has quit [Quit: ZNC 1.8.2 - https://znc.in]
brown121407 has joined #ocaml
Tuplanolla has joined #ocaml
<def> inkbottle: that seems right
bartholin has joined #ocaml
osa1 has joined #ocaml
cantstanya has quit [Remote host closed the connection]
cantstanya has joined #ocaml
reynir has quit [Ping timeout: 256 seconds]
reynir has joined #ocaml
_whitelogger has joined #ocaml
waleee-cl has joined #ocaml
<d_bot> <Et7f3> @dj charlie try to set `TERM=dumb` before executing it
<d_bot> <dj charlie> i have that set ty for the suggestion though ๐Ÿ™‚
narimiran has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
kleisli_ has joined #ocaml
<Armael> @dj charlie `man utop` indicates how you can turn off the fancy colors/completion widget
<Armael> #utop_prompt_dummy;
<Armael> UTop.set_show_box false
<Armael> mm so False* if you're in rtop
<d_bot> <dj charlie> i have that set
<d_bot> <dj charlie> this is the contents of the file that does init for my rtop...
<Armael> (nvm, I can't do reason; it should be UTop.set_show_box(false))
<d_bot> <dj charlie> ```
<d_bot> <dj charlie> #utop_prompt_dummy;
<d_bot> <dj charlie> UTop.set_show_box(false);
<d_bot> <dj charlie> #require "utop";
<d_bot> <dj charlie> UTop.prompt := React.S.map((s => LTerm_text.of_string(LTerm_text.to_string(s))), (^)(UTop.prompt));
<d_bot> <dj charlie> ```
<d_bot> <dj charlie> ๐Ÿ™‚
endorphin has quit [Ping timeout: 260 seconds]
<Armael> so what's the issue then?
<d_bot> <dj charlie> here...
<d_bot> <craigfe> inkbottle: the restrictions on `let+` and `and+` are syntactic (determined by the desugaring transformation), not type-based. There's no reason that your binary operators have to fit applicative or monadic signatures, they just have to type-check after the transformation has occurred.
<d_bot> <dj charlie> kicking it off with `rtop -init $HOME/.rtop.init`
<d_bot> <craigfe> e.g.
<d_bot> <craigfe> ```ocaml
<d_bot> <craigfe> let ( let+ ) x _ = x
<d_bot> <craigfe> let ( and+ ) = ( * )
<d_bot> <craigfe> ;; let+ _ = 2 and+ _ = 3 in ();;
<d_bot> <craigfe> - : int = 6
<d_bot> <craigfe> ```
<Armael> ah right, I guess the init script gets evaluated after the prompt is printed
<d_bot> <dj charlie> (that's after me pressing space a few times)
<d_bot> <dj charlie> *enter
<Armael> in which environment are you running rtop, out of curiosity?
<d_bot> <dj charlie> acme ๐Ÿ™‚
<d_bot> <dj charlie> i just run `ocaml` in a new pane if i want to have a repl for that
<d_bot> <dj charlie> and have binds for my window manager to kick that off
<d_bot> <dj charlie> not sure if there's another way to run a reason repl without using rtop
<Armael> so the `ocaml` basic toplevel works for you?
<d_bot> <dj charlie> yep
<Armael> but rtop/utop is doing fancy stuff and doesn't handle TERM=dumb to disable it
<d_bot> <dj charlie> yeah
<d_bot> <dj charlie> for that reason i stay away from utop in my editor
<Armael> (whereas the ocaml toplevel does)
<Armael> ah that's a shame
<d_bot> <dj charlie> but i'm unfamiliar with reason's tooling and not sure if there's another way to run a repl without rtop
<d_bot> <dj charlie> haven't done a deep dive yet
<Armael> I don't know much about reason either, is rtop the only toplevel that's available?
mfp has joined #ocaml
<d_bot> <dj charlie> that's a burning question ๐Ÿ™‚
<Armael> ah well :)
<d_bot> <dj charlie> here's hoping ๐Ÿ™‚
<d_bot> <dj charlie> may have to just dissect rtop
<Armael> you can always open an issue with utop/rtop
<Armael> to honor TERM=dumb
<d_bot> <dj charlie> could
<d_bot> <dj charlie> well thanks for your attempt to help me deal with this issue ๐Ÿ™‚
<Armael> yeah sorry I couldn't be of much help
<d_bot> <dj charlie> ๐Ÿ™‚ nah
<d_bot> <octachron> @ostera Otherwise, build should be reproducible.
<d_bot> <ostera> gotcha
<d_bot> <ostera> i must be doing something wrong here
<d_bot> <octachron> Probably but it is hard to infer what is the issue from "something goes wrong sometimes"
<d_bot> <ostera> @octachron this is what I'm doing to match on the _last arg_ being a unit:
<d_bot> <ostera>
<d_bot> <ostera>
<d_bot> <ostera> ```ocaml
<d_bot> <ostera> let args = match args with
<d_bot> <ostera> | ({ desc = Tconstr (path, _, _)} :: rest) when Path.last path = "unit" -> rest
<d_bot> <ostera> | _ -> args
<d_bot> <ostera> in
<d_bot> <ostera> ```
<d_bot> <ostera> because of how I collected the args, I know the head of the list is the last one
<d_bot> <octachron> This also the wrong way to test equality with the type unit
<d_bot> <ostera> what'd be a more idiomatic way of doing this?
<d_bot> <ostera> Btype.is_Tconstr ?
<d_bot> <octachron> It is not a question of idiomatic, this is just plain wrong.
<d_bot> <ostera> 'er we go -- from Path.last to Path.same I wasn't _that_ far off
<d_bot> <ostera> thanks ๐Ÿ™‚
<d_bot> <octachron> Note I was reacting to the "sometimes things go wrong after a recompilation", that should not happen.
<d_bot> <ostera> I'll keep an eyen on printtyp and printtyped to see more of what I've been hacking around and how to do it properly
<d_bot> <ostera> okay, so here's what I see
<d_bot> <ostera> I've got a file
<d_bot> <ostera>
<d_bot> <ostera> ```ocaml
<d_bot> <ostera> let int () = 1
<d_bot> <ostera> ```
<d_bot> <ostera> on the first run of `ocamlc -dtypedtree test.ml` the little hack i've got going on prints out `int/1` -- wrong, the last argument here is a unit.
<d_bot> <ostera> if I run it __again__
<d_bot> <ostera> it prints out `int/0`
<d_bot> <ostera> every other run after that seems to have converged on int/0
<d_bot> <ostera> removing test.cmo and test.cmi restarts the behavior
<d_bot> <octachron> While I am at it. Your argument function should be probably adapted from https://github.com/ocaml/ocaml/blob/trunk/typing/typecore.ml#L2289
<d_bot> <ostera> ooh fancy, will have a look!
<d_bot> <octachron> This is expected. Generating the infered mli will use some idents
<d_bot> <octachron> Thus compiling with an existing cmi or not is not the same. Also stamps are a brittle implementation details.
<d_bot> <ostera> interesting
<d_bot> <ostera> it definitely has to do with the compilation of the signatures
<d_bot> <ostera> I just removed the bits that relied on the .cmi and i can reliably get `int/1` (the wrong number)
<d_bot> <ostera> when you say "iferred mli will use som idents" where can I learn more about this?
<d_bot> <octachron> What do you mean also by the wrong number?
<d_bot> <ostera> oh, i'm expecting the function int to have arity 0 after I remove the last argument if its a unit
<d_bot> <octachron> No shortcut apart from reading the typechecker code I fear. The typedtree is not intended for general use.
<d_bot> <ostera> that's okay, i'm ready to get my hands dirty ๐Ÿ™‚
<d_bot> <ostera> i'm also wondering if the ordering in which I'm reading the .cmi file could be a problem here
<d_bot> <ostera> (for context, i'm hooking into driver/compile.ml's implementation function to get my hands on the fresh typedtred)
<d_bot> <octachron> I will say more bloody than dirty.
<d_bot> <octachron> If you are hooking after the implementation, you get the typedtree coerced by the signature if it exists.
<d_bot> <octachron> But arguments analysis should not misbehave like this.
<d_bot> <ostera> so you're saying that the coerced typedtree _on the second compilation_ may be different
malc_ has joined #ocaml
<d_bot> <ostera> if the signature .cmi exists
malc_ has left #ocaml [#ocaml]
<d_bot> <ostera> need to dump out that typedtree to see the differences now
<d_bot> <octachron> Note that this should require a companion .mli? Any way, none of this should matter if your analysis function is not bugged.
<d_bot> <ostera> yeah, when I have the .mli in place this behaves as I expect
<d_bot> <ostera> my analysis function is the `match` you see above
<d_bot> <ostera> before that I'm essentially doing a `typedtree.str_type |> List.map`
<d_bot> <ostera> unless the .cmi is present, then it's a `(sig: Types.signature) |> List.map`
borne has joined #ocaml
<d_bot> <ostera> @octachron what I'd love to _not have to do_ is to build the thing twice if I can't find the corresponding .cmi the first time
<d_bot> <ostera> my guess is that there's another way of traversing the initial `typedtree.str_type` that'd get me the same information
<d_bot> <octachron> The traversal and cmi question seem to be a red herring to me. You should focus on debugging your analysis function.
<d_bot> <ostera> i'm doing that atm
<d_bot> <ostera> @octachron aaand of course. the first time its a Tlink
<d_bot> <ostera> ๐Ÿคฆ
<d_bot> <ostera> thanks @octachron ๐Ÿ™Œ
osa1 has quit [Ping timeout: 260 seconds]
osa1 has joined #ocaml
ggole has joined #ocaml
borne has quit [Ping timeout: 244 seconds]
kleisli_ has quit [Ping timeout: 256 seconds]
kleisli_ has joined #ocaml
jnavila has joined #ocaml
borne has joined #ocaml
ransom has joined #ocaml
decentpenguin has joined #ocaml
borne has quit [Ping timeout: 260 seconds]
<inkbottle> craigfe: thanks for the example `let ( let+ ) x _ = x in let ( and+ ) = ( * ) in let+ x = 3 and+ y = 2 in x ^ y;;` dropping the supposedly functional part of `(let+)` was a smart move. I'd really like to know more about the "desugaring transformation" which is hardly described in https://ocaml.org/manual/bindingops.html.
osa1 has quit [Quit: osa1]
narimiran has joined #ocaml
narimiran has quit [Ping timeout: 240 seconds]
osa1 has joined #ocaml
Anarchos has joined #ocaml
osa1 has quit [Ping timeout: 272 seconds]
jbrown has quit [Ping timeout: 272 seconds]
ransom has quit [Ping timeout: 244 seconds]
<inkbottle> What is that use of `type` keyword? `let rec eval (type a) : a term -> a = function`
<d_bot> <craigfe> It's a locally-abstract type: https://caml.inria.fr/pub/docs/manual-ocaml/locallyabstract.html
narimiran has joined #ocaml
<d_bot> <craigfe> (Someone should build a tool that takes a cryptic OCaml AST fragment and emits a few links to explain the dark syntax corners involved...)
<d_bot> <stab> Thatโ€™s a tricky problem
<ggole> That's a locally abstract type, you need those in order to use type equalities that come from matching on GADTS
<ggole> The syntax is a bit funny, I think they wanted to avoid a new keyword
<d_bot> <stab> Youโ€™d need like a formal specification of the Ocaml grammar that is like labeled with links to the relevant manual pages
<d_bot> <craigfe> It could be implemented as a PPX tool; similar to `dump_ast`
<d_bot> <craigfe> No need to bother with formal specifications of the grammar; the parsetree types are enough
<d_bot> <stab> I mean if youโ€™re willing to go through the effort to manually assign links to each syntax object lol
<d_bot> <craigfe> There's not _that_ much going on in OCaml
<d_bot> <stab> Maybe you could try to do something clever like match it with the snippets
<d_bot> <ggole> A docstring for each node in the syntax tree would be doable
<d_bot> <stab> Probably way too tricky to do that
<d_bot> <stab> Lisp syntax is truly ideal , why is there anything besides function application tbh
<inkbottle> thanks
jbrown has joined #ocaml
<inkbottle> Now, how can I have the 3rd constructor, `App` currified? (instead of taking a pair) https://caml.inria.fr/pub/docs/manual-ocaml/gadts.html
<inkbottle> type _term = App : ('b -> 'a) term -> 'b term -> 'a term doesn't work, syntax error
<octachron> Constructor are not currified in OCaml.
<inkbottle> ok
<inkbottle> thanks
vicfred has quit [Quit: Leaving]
vicfred has joined #ocaml
silver has joined #ocaml
_ks has quit [Quit: WeeChat 2.3]
<d_bot> <rgrinberg> I wonder if we need a channel for discussing compiler internals
narimiran has quit [Quit: leaving]
jbrown has quit [Ping timeout: 272 seconds]
osa1 has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
_ks has joined #ocaml
jbrown has joined #ocaml
wagle has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
wagle has joined #ocaml
reynir has quit [Ping timeout: 258 seconds]
reynir has joined #ocaml
jbrown has quit [Ping timeout: 272 seconds]
jbrown has joined #ocaml
osa1 has quit [Ping timeout: 260 seconds]
<d_bot> <rgrinberg> @Bluddy ?
jbrown has quit [Ping timeout: 272 seconds]
<d_bot> <octachron> I would propose to have a more generic channel for long-winded arcane discussions. Maybe named "arcane"? "abstract nonsense"? or the more prosaic "veterans"?
<d_bot> <octachron> In order to also have a home for talking about type tricks, memory representation, and the compiler internals
<d_bot> <stab> To be fair if there was a channel named abstract nonsense, without knowing what it is Iโ€™d probably never click on it
<d_bot> <stab> Idk โ€œlanguage featuresโ€? Thatโ€™s a little opaque
<d_bot> <rgrinberg> The name "arcane" seems counter intuitive to me, such a channel would contain so much useful knowledge ๐Ÿ™‚
<d_bot> <rgrinberg> veterans sounds alright as well
<d_bot> <stab> Eh imo feels weird to discourage beginners from clicking in as well (from the perspective of someone who isnโ€™t great at Ocaml)
kleisli_ has quit [Ping timeout: 260 seconds]
<d_bot> <octachron> Between, "veterans", "advanced", "expert", "technical discussion", it is hard to convey the idea that everyone is welcome to discuss and ask questions, but that the discussion might end up being hard to follow. And I don't know how many people will be scared by "veterans" but not by "compiler internals" (or the reverse).
<d_bot> <ostera> if my vote counts for anything, I'd ๐Ÿ‘ a #compiler channel
<d_bot> <stab> Yeah to be fair compiler internals sounds like itโ€™s all discussion of implementation which is a scary place to be compared to like weird language features
<d_bot> <octachron> At the same time, it is true that "compiler" would be at its place in the ecosystem category.
<d_bot> <stab> Also to be fair all of this is very bikesheddy any of the names above would probably do
delysin has quit [Ping timeout: 246 seconds]
jnavila has quit [Quit: Konversation terminated!]
delysin has joined #ocaml
ggole has quit [Quit: Leaving]
<inkbottle> Here a nice "embedded language", allowing recursion, but this way of defining the fix point won't work with a call-by-value language (https://en.wikipedia.org/wiki/Generalized_algebraic_data_type, https://pastebin.com/TX7dh3dZ)
Tuplanolla has quit [Quit: Leaving.]
<inkbottle> cbv fix-point can be expressed like so: `let rec fix f x = f (fix f) x in fix (fun f x -> if x = 1 then 1 else (f (x-1)) * x) 3`. So the problem must be elsewhere.
leah2 has quit [Ping timeout: 272 seconds]
leah2 has joined #ocaml
cantstanya has quit [Ping timeout: 240 seconds]
cantstanya has joined #ocaml
_ks has quit [Quit: WeeChat 2.3]