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
Haudegen has quit [Ping timeout: 256 seconds]
spew has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #ocaml
_whitelogger has joined #ocaml
mfp has quit [Ping timeout: 256 seconds]
reynir has quit [Ping timeout: 265 seconds]
reynir has joined #ocaml
rpcope has quit [Quit: ZNC - http://znc.in]
rpcope has joined #ocaml
laokz has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
mfp has joined #ocaml
_whitelogger has joined #ocaml
_whitelogger has joined #ocaml
u0_a331 has joined #ocaml
u0_a331 is now known as gewaltdisney
laokz has quit [Ping timeout: 240 seconds]
mmohammadi9812 has joined #ocaml
_whitelogger has joined #ocaml
lopex has quit [Quit: Connection closed for inactivity]
mbuf has joined #ocaml
ggole has joined #ocaml
laokz has joined #ocaml
dckc has quit [Ping timeout: 240 seconds]
dckc has joined #ocaml
<d_bot> <dj charlie> curious as to how ocaml people do distributed logging
<d_bot> <dj charlie> if there's a product you like 🙂
Lopx has joined #ocaml
<d_bot> <dj charlie> i mean a way to aggregate logging across our docker driven infra
<Lopx> please why isnt this code running? https://pastebin.com/a3GseHi5
<d_bot> <dj charlie> sml?
<Lopx> yes
<Lopx> evenP is a function that test whether a number is even
<Lopx> forgot to include in the code
<d_bot> <dj charlie> surround your cases with ( ) if it's anything like ocaml
<Lopx> ok
<Lopx> gives me this error https://pastebin.com/0JTxnExA
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> <ggole> eg, `fprintf Format.std_formatter` = `printf`
inkbottle has quit [Ping timeout: 264 seconds]
<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> ah dammit! that's the pattern i've looking for: `%a` !
malc_ has joined #ocaml
<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]
mmohammadi9812 has joined #ocaml
<zebrag> `dune utop`; `open Dummy.Applicative_parsing;;`; `Parser.Fail "hello";;`; `- : 'a Parser.t = Dummy.Applicative_parsing.Parser.Fail "hello"`
<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> Regarding `utop` itself, the following documentation says `-short-paths` is the default (https://opam.ocaml.org/blog/about-utop/#Other-features)
<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> that! how do I do that? 😄
<d_bot> <Drup> ctyp_type field
<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
vicfred has joined #ocaml
Tuplanolla has joined #ocaml
<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>
<d_bot> <ostera> let table : (Types.type_expr, char) Hashtbl.t = Hashtbl.create 1024
<d_bot> <ostera>
<d_bot> <ostera> let find t =
<d_bot> <ostera> match Hashtbl.find_opt table t with
<d_bot> <ostera> | None ->
<d_bot> <ostera> Hashtbl.add table t !last_char;
<d_bot> <ostera> let ret = String.make 1 !last_char in
<d_bot> <ostera> last_char := Char.chr ((Char.code !last_char) + 1);
<d_bot> <ostera> ret
<d_bot> <ostera> | Some v -> String.make 1 v
<d_bot> <ostera>
<d_bot> <ostera> end
<d_bot> <ostera> ```
<d_bot> <ostera>
<d_bot> <ostera> this seemed to work
<d_bot> <ostera> ```erlang
<d_bot> <ostera> -| -spec map(fun((any()) -> any()), fun((any()) -> any()), pair(any())) :: pair(any()).
<d_bot> <ostera> +| -spec map(fun((E) -> F), fun((E) -> F), pair(E)) :: pair(F).
<d_bot> <ostera> | map(F, G, #{ fst := Fst, snd := Snd }) ->
<d_bot> <ostera> | #{ fst => F(Fst)
<d_bot> <ostera> | , snd => G(Snd)
<d_bot> <ostera> | }.
<d_bot> <ostera> |
<d_bot> <ostera> -| -spec swap_from_expr(any(), fun((any()) -> pair(any()))) :: pair(any()).
<d_bot> <ostera> +| -spec swap_from_expr(G, fun((G) -> pair(H))) :: pair(H).
<d_bot> <ostera> | swap_from_expr(P, F) ->
<d_bot> <ostera> | #{ fst => maps:get(snd, F(P))
<d_bot> <ostera> | , snd => maps:get(fst, F(P))
<d_bot> <ostera> | }.
<d_bot> <ostera> ```
<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`,:
<d_bot> <ostera>
<d_bot> <ostera> 1. `add_named_var type_expr`
<d_bot> <ostera> 2. `new_name ()`
<d_bot> <ostera> 3. `Naming_context.{ add_protected, set, ident_name_simple }`
<d_bot> <ostera> my gut tells me #1 is the one I care about, but its a little hard to find my way around the code still
<d_bot> <octachron> You could simply reuse Printtyp.typexpr?
<d_bot> <ostera> this one?
<d_bot> <ostera> let typexp sch ppf ty =
<d_bot> <ostera> ```ocaml
<d_bot> <ostera>
<d_bot> <ostera> !Oprint.out_type ppf (tree_of_typexp sch ty)
<d_bot> <ostera> ```
<d_bot> <Drup> oh, yeah, you could use `Outcometree` ...
<d_bot> <octachron> that too. And the outcometree outputing function is `tree_of_typexp`.
<d_bot> <ostera> so the i'd just call that and get a `Otyp_var`
<d_bot> <ostera> cool, let me try it
<d_bot> <ostera> @octachron seems to work 🆗 just needs a small hit of the reset button between functions so I get a's and b's again
Haudegen has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
reynir has quit [Ping timeout: 240 seconds]
reynir has joined #ocaml
jnavila has quit [Ping timeout: 272 seconds]
mmohammadi9812 has quit [Quit: I quit (╯°□°)╯︵ ┻━┻]
nullcone has quit [Ping timeout: 246 seconds]
nullcone has joined #ocaml
dhil has quit [Ping timeout: 264 seconds]
tane_ has quit [Quit: Leaving]
Tuplanolla has quit [Quit: Leaving.]
chewbranca has quit [Read error: Connection reset by peer]
chewbranca has joined #ocaml
<rock64_> do we suddenly allow massive code dumps in the channel...?
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
delysin has quit [Read error: Connection reset by peer]
remexre has quit [Read error: Connection reset by peer]
delysin has joined #ocaml