vicfred has quit [Remote host closed the connection]
vicfred has joined #ocaml
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #ocaml
mbuf has quit [Ping timeout: 246 seconds]
gewaltdisney has quit [Ping timeout: 272 seconds]
Haudegen has joined #ocaml
Lopx has quit [Ping timeout: 245 seconds]
tane_ has joined #ocaml
narimiran has joined #ocaml
_whitelogger has joined #ocaml
gewaltdisney has joined #ocaml
laokz has quit [Remote host closed the connection]
laokz has joined #ocaml
Tuplanolla has joined #ocaml
mbuf has joined #ocaml
mmohammadi98128 has joined #ocaml
mmohammadi98128 has quit [Client Quit]
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #ocaml
inkbottle has quit [Quit: Konversation terminated!]
inkbottle has joined #ocaml
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #ocaml
dhil has joined #ocaml
<d_bot>
<Et7f3> Pareenthese aren't balanced and try (-1.0)
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
mmohammadi98121 has joined #ocaml
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi98121 is now known as mmohammadi9812
jnavila has joined #ocaml
dhil has quit [Ping timeout: 260 seconds]
mmohammadi98124 has joined #ocaml
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi98124 is now known as mmohammadi9812
mfp has joined #ocaml
mmohammadi9812 has quit [Ping timeout: 240 seconds]
Anarchos has joined #ocaml
<d_bot>
<craigfe> (unary negation is `~` in SML)
laokz has quit [Ping timeout: 246 seconds]
malc_ has joined #ocaml
gewaltdisney has quit [Ping timeout: 272 seconds]
gewaltdisney has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
nullcone has quit [Quit: Connection closed for inactivity]
sonologico has joined #ocaml
laokz has joined #ocaml
<d_bot>
<ostera> what is the correct way of composing pretty printers using `Format.fprintf` and the `%@` pattern in the format string? 🤔
<d_bot>
<ostera> alternatively, what's your favorite pretty printer written in ocaml out there -- i'm trying to scout out good patterns as the thing I've written right now is getting a little harder to refactor cleanly 🙂
malc_ has quit [Remote host closed the connection]
<d_bot>
<ggole> What do you mean? `%@` just prints a `@`.
<d_bot>
<ostera> huh, why is it changing the type of the formatter then?
<d_bot>
<ggole> ```ocaml
<d_bot>
<ggole> # Format.printf "%@";;
<d_bot>
<ggole> @- : unit = ()
<d_bot>
<ggole> # Format.printf "foo";;
<d_bot>
<ggole> foo- : unit = ()
<d_bot>
<ggole> #
<d_bot>
<ggole> ```
<d_bot>
<ostera> try `fprintf`
zebrag has joined #ocaml
<d_bot>
<ggole> `fprintf` is just `printf` with a formatter argument though
<d_bot>
<ostera> hm. let me try to replicate in a smaller context
<d_bot>
<ostera> ah, yes, you are right
<d_bot>
<ostera> the type of the rest of formatter does change, but now its got _one parameter less_
<d_bot>
<ostera> ugh, I need to get better at Format
<d_bot>
<ostera> @ggole thanks! how would you approach composing pretty printers that rely on the `Format` module? and do you have any examples you refer to from time to time?
<d_bot>
<ggole> It's a confusing module, yeah
<d_bot>
<ggole> Although things mostly make sense after you figure out wtf is happening
<d_bot>
<ggole> Composition is pretty easy, mostly you can just use a `%a` and pass a pretty printer + arg
<d_bot>
<ggole> The standard library is a bit short on useful combinators, so some people like to use `Fmt` for that
<d_bot>
<ostera> i think most of the time I've had to break down a print to just invoke another pretty printer and that's made some of them a little hard to read
<d_bot>
<ostera> eg.
<d_bot>
<ostera>
<d_bot>
<ostera> open parens
<d_bot>
<ostera> check if there's stuff in the list
<d_bot>
<ostera> iterate, call another printer each time
<d_bot>
<ostera> do some other printing
<d_bot>
<ostera> close parents
<d_bot>
<ggole> Sometimes you do need to do that
<d_bot>
<ostera> whereas with the `%a` it could get a little cleaner
<d_bot>
<ggole> eg, if you have a rule to always print 'large' things on the next line in a particular context, then you might need to use different format strings depending on a test
<d_bot>
<ostera> right
<d_bot>
<ostera> tbf in my case its just print rather than pretty print for now
<d_bot>
<ostera> but soon enough i'll have some time to make it smarter/prettier
malc_ has left #ocaml [#ocaml]
<d_bot>
<ggole> Boxes can be a bit fiddly
<d_bot>
<ggole> I often forget the exact interaction between the different types of box and `@ `, `@,` and `@;` and have to figure it out on the fly
lopex has joined #ocaml
mbuf has quit [Quit: Leaving]
reynir has quit [Ping timeout: 246 seconds]
reynir has joined #ocaml
waleee-cl has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
mmohammadi9812 has joined #ocaml
mbuf has joined #ocaml
amiloradovsky has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
Anarchos has joined #ocaml
mmohammadi9812 has quit [Read error: Connection reset by peer]
amiloradovsky has quit [Ping timeout: 260 seconds]
mmohammadi9812 has joined #ocaml
mbuf has quit [Ping timeout: 272 seconds]
laokz has quit [Remote host closed the connection]
laokz has joined #ocaml
mmohammadi98120 has joined #ocaml
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi98120 is now known as mmohammadi9812
gewaltdisney has quit [Ping timeout: 246 seconds]
laokz has quit [Ping timeout: 256 seconds]
clockish_ has joined #ocaml
laokz has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
zozozo has quit [*.net *.split]
jimt[m] has quit [*.net *.split]
labor[m] has quit [*.net *.split]
clockish has quit [*.net *.split]
clockish_ is now known as clockish
gahr has quit [*.net *.split]
zozozo has joined #ocaml
gahr has joined #ocaml
labor[m] has joined #ocaml
jimt[m] has joined #ocaml
gewaltdisney has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
<gewaltdisney>
laokz has quit [Remote host closed the connection]
laokz has joined #ocaml
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #ocaml
mmohammadi98128 has joined #ocaml
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi98128 is now known as mmohammadi9812
laokz has quit [Quit: Leaving]
dhil has joined #ocaml
<gewaltdisney>
x1
gewaltdisney has quit [Quit: leaving]
amiloradovsky has joined #ocaml
Anarchos has joined #ocaml
amiloradovsky has quit [Ping timeout: 240 seconds]
amiloradovsky has joined #ocaml
dhil has quit [Ping timeout: 256 seconds]
mmohammadi9812 has quit [Ping timeout: 264 seconds]
<zebrag>
Is there a reason why `utop` is displaying the longest possible path here?
<zebrag>
Alternatively can I configure it to show a shorter version?
<zebrag>
I understand `-short-paths` is default
<d_bot>
<ostera> hey @Drup if I had my hands on a `Types.type_expr` with a `type_desc` that was a `Tvar None`, how would you recommend getting a fresh (but coherent) type variable name as a string?
<def>
zebrag: utop -short-paths
<def>
I don't think it is the default.
<zebrag>
def: how do I pass that option when calling utop with dune?
<zebrag>
dune utop -short-path doesn't work
amiloradovsky has quit [Ping timeout: 240 seconds]
<zebrag>
I did: `dune utop ./ -- -short-paths`; the option has been accepted (no error reported); but the type displayed is still the longest path
<zebrag>
but that might be modified when called from dune
mmohammadi9812 has quit [Ping timeout: 256 seconds]
nicknotch has joined #ocaml
dhil has joined #ocaml
RalfJ has quit [Remote host closed the connection]
RalfJ has joined #ocaml
RalfJ has quit [Remote host closed the connection]
RalfJ has joined #ocaml
mmohammadi9812 has joined #ocaml
nicknotch has quit [Quit: leaving]
vicfred has quit [Quit: Leaving]
amiloradovsky has joined #ocaml
nicknotch has joined #ocaml
nicknotch has quit [Remote host closed the connection]
rock64_ has joined #ocaml
hnOsmium0001 has joined #ocaml
nullcone has joined #ocaml
<d_bot>
<Drup> @ostera huh, what's your goal here ?
<d_bot>
<Drup> iirc, `Tvar None` was a `_`
<d_bot>
<Drup> but, I'm slightly confused what you want to do with a type variable name, given you are translating to an untyped language
<d_bot>
<ostera> Oh, Erlang does have a static analyzer, Dialyzer, that works with success typings -- unfortunately it is slow and full of adorable quirks
<d_bot>
<ostera> but the type language allows for specifying variables, which I'm intending to use mostly for documentation purposes
<d_bot>
<Drup> huh, ok, I ... don't understand the point
<d_bot>
<ostera> so if you pick up some generated Erlang code, there's a little more to it to guide you on how to use it
<d_bot>
<ostera> right now when the `Tvar None` appears, I fallback to an `any()` type in dialyzer
<d_bot>
<Drup> why don't you just look at the type that the variable was infered with ?
<d_bot>
<ostera> hm, in this case I'm starting off a Types.type_expr
<d_bot>
<Drup> `Typedtree` is the parsetree, annotated with types. This also applies to `Typedtree.core_type`: it's just the AST of the types. The actual calculus of types that is used for computing/unifying/stuff is in `Types`.
<d_bot>
<Drup> So, as soon as you want infered/semantic types, look for stuff from `Types`
<d_bot>
<ostera> Yes, I understand that
<d_bot>
<ostera> I've got both traversals in place atm
raver has joined #ocaml
<d_bot>
<ostera> and for the one that begins on a value binding, i'm starting at the inferred types
<d_bot>
<ostera> just filter_mapping over the `Typedtree.str_type` i eventually build up an uncuried function from the `Tarrow`'s
<d_bot>
<ostera> that's all great
<d_bot>
<ostera> i hit a wall when mapping over the specific arguments/return type_expr's of that function, because some seem to be `TVar None`'s
<d_bot>
<ostera> wheres when I print them out with `Printtype.type_expr` I'll get nice variable names in the right spots
<d_bot>
<ostera> i guess I could reimplement the `reset_and_mark_loops` from Printtyp
<d_bot>
<Drup> you probably have to do something like that
<d_bot>
<Drup> variables in the typers are implemented through physical identity of mutable references :x
<d_bot>
<ostera> sweet
<d_bot>
<Drup> well, efficient.
<d_bot>
<ostera> i meant, a chance to flex my mutable ocaml foo
<d_bot>
<ostera> I was hoping you'd know of a specific way of retrieving these variable names given that I already have access to the type_expr, and the environment is still built
<d_bot>
<Drup> the notion of "variable name" only makes sense in the AST
<d_bot>
<Drup> you shouldn't really use the AST for anything that is not very syntactic
<d_bot>
<Drup> you want semantic info, you gotta use the real types, and names don't exists there 🙂
<d_bot>
<ostera> sorry, i should've said "inferred type variable name"
<d_bot>
<ostera> what's the right lingo here?
<d_bot>
<Drup> well, just "variable" :p
<d_bot>
<ostera> aight
<d_bot>
<Drup> but yeah, if you want names, you need to invent them again
<d_bot>
<ostera> gonna go reimplement this naming then
<d_bot>
<Drup> which is what `Printtyp` does
<d_bot>
<ostera> this is not what I wanted my saturday night to be like but here we are _grunts his way back into vim_
<d_bot>
<Drup> @octachron is the expert on the whole printing env stuff to name variables
dhil has quit [Ping timeout: 246 seconds]
ggole has quit [Quit: Leaving]
<d_bot>
<ostera> ```ocaml
<d_bot>
<ostera> module Type_var_names = struct
<d_bot>
<ostera> let last_char : char ref = ref 'a'
<d_bot>
<ostera> just needs a reset between functions
<d_bot>
<Drup> huh, I don't think that's going to really work. Look at how it's done in the compiler. Hashtbls uses structural equality which are not going to work on refs-as-unique-pointers
<d_bot>
<ostera> i expect it to be broken somewhere
Anarchos has left #ocaml [#ocaml]
dhil has joined #ocaml
narimiran has quit [Quit: leaving]
<d_bot>
<ostera> hm. it looks like there's 3 different ways of registering names in `Printtyp`,: