avsm changed the topic of #mirage to: mirage 2 released! party on!
aconz2 has quit [Quit: aconz2]
rgrinberg has quit [Quit: WeeChat 1.5]
rgrinberg has joined #mirage
seangrove has quit [Ping timeout: 244 seconds]
aconz2 has joined #mirage
aconz2 has left #mirage [#mirage]
srenatus[m] has quit [Read error: Connection reset by peer]
rgrinberg has quit [Ping timeout: 250 seconds]
srenatus[m] has joined #mirage
nullcat has joined #mirage
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nullcat has joined #mirage
nullcat has quit [Client Quit]
copy` has quit [Quit: Connection closed for inactivity]
dexterph` has joined #mirage
AltGr has joined #mirage
agarwal1975 has quit [Quit: agarwal1975]
rgrinberg has joined #mirage
mort___ has joined #mirage
<mort___>
Drup: there? got a dumb question about functoria that must be obvious but i can't find the answer
<mort___>
ah, think i have it - never mind
<Drup>
mort___: what was the question ?
<Drup>
:)
<mort___>
how to access the string value in a required key so as to call `generic_kv_ro` on the right thing
<mort___>
but it seems that `match_impl` is my friend in this instance...?
<mort___>
(that is, actually accessing at configuration time the value of a required configuration time key)
<Drup>
Ah, yes.
<mort___>
btw, are there some outstanding doc issues in functoria docs? seems that there are refs to `Bootvar_gen` rather than `Key_gen` etc in places — do you want PRs for such?
<Drup>
There is no "bind" operator that would allow you to do really dynamic dispatch, that's on purpose
<Drup>
Oh, yes, absolutely
<mort___>
cool
<Drup>
I though I changed all of them
<mort___>
(may just be the current live docs)
<mort___>
haven't checked code
<mort___>
anyway — what's the reason for no bind oeprator?
<mort___>
in this case i'd rather blow up at configuration time — that is, when exectuing `mirage configure` — if the user requests me to crunch a file that doesn't exist
<mort___>
ie i dont want to provide a default value
<mort___>
is there some equivalent of a `exception impl` ?
<Drup>
Ah, but you can do that fine, just change the configuration call to check the file exists, and blow up
<mort___>
hm - i don't understand - you mean just before the point i call Key.create ?
<Drup>
What is not allowed is to take a value v and use that value to invent a new device
<Drup>
I mean inside the device, the "configure" method
<mort___>
ah
<mort___>
hm
<Drup>
look at crunch's configure method
<mort___>
but won't that defer the check to build time? rather than blowing up at configuration time?
<mort___>
oh i see
<mort___>
so i let the device handle the case, i don't try to handle it myself in config.ml
<Drup>
it already does what you want
<mort___>
gotcha
<mort___>
so i call match_impl with some bogus `default` value and hope that no-one ever creates a file named with the bogus default value ?
<mort___>
(in the directory in which i execute mirage confiugre)
<Drup>
hum, what for ?
<mort___>
doh. sorry. being an idiot.
<mort___>
the default value is the impl
<Drup>
To go back to "why no bind", It has to do with static knowledge and documentation. Basically, when you have an applicative dsl, you can know the graph statically. If you have a monadic DSL, you only have partial knowledge, the rest is hidden behind functions that are not yet executed
<Drup>
So, if you want good documentation, applicative is prefered, hence no bind.
<mort___>
oh ok
<mort___>
so i think i'm still confused (sorry!)
<mort___>
if i want to allow the user to pass in a directory for me to pass to crunch, how do i do that?
<mort___>
that is, at the `mirage configure` stage
<mort___>
i thought i'd create a required configure stage string key, and then use that value subseuqently
<mort___>
but crunch expects a string, not a string key (or a string value)
<Drup>
huum, we could make it a string value
<Drup>
that would be better indeed, and would allow your use case
<mort___>
ok— so long as i'm not missing anything obvious then, and it does require mirage patching :)
<mort___>
though that would be quite a breaking change wouldn't it?
<mort___>
(or require changing api to add a crunch_key or somesuch)
<Drup>
Yes
<mort___>
ok — i'll take a look at doing that later — gtg for lunch now — thanks!
<Drup>
It really would be better if everything was taking a value, so that it could be a constant (Key.pure) or a key.
<mort___>
yes that would seem more uniform an interface
mort___ has quit [Quit: Leaving.]
agarwal1975 has joined #mirage
danielh1234 has joined #mirage
<danielh1234>
Hi, when using Batteries (the library) the project compiles fine for Unix but fails with linker errors for Xen: undefined reference to lor_digit_nat and other nat stuff from https://github.com/ocaml/ocaml/blob/trunk/otherlibs/num/nat_stubs.c#L322 . Why are these implementations not linked for Xen?
mort___ has joined #mirage
mort___ has quit [Read error: Connection reset by peer]
danielh1234 has quit [Quit: Page closed]
mort___ has joined #mirage
mort___ has quit [Quit: Leaving.]
brson has joined #mirage
rgrinberg has quit [Quit: WeeChat 1.5]
rgrinberg has joined #mirage
mort___ has joined #mirage
dexterph` has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Ping timeout: 264 seconds]
<mort___>
Drup: been looking more into this
<mort___>
i must be missing something
<mort___>
even if the parameter passed to (eg) generic_kv_ro is a proper ` 'a value `, it seems unreasonable to expect the target libraries (ocaml-crunch etc) to take an 'a value rather than an 'a
<Drup>
ah, no, you don't
<Drup>
configure receives the various values as argument
<mort___>
so i need to resolve the 'a value to an 'a inside the config.ml or inside the relevant function (generic_kv_ro, etc) in mirage.ml
<Drup>
let me find you a device that shows this
<Drup>
mort___: look at "network_conf"
<mort___>
so i think i need to use `Info.context` on something somewhere to do that resolution — so is the only way to do that from within mirage.ml ?
<Drup>
hum, this might need more modification than I though
<Drup>
Yes, you need Info.context
<Drup>
precisely
<Drup>
(and Key.eval)
<Drup>
there is going to be an issue, though, because you can't add your value in the "keys" array, grmbl
<mort___>
ok— so i need to modify eg https://github.com/mirage/mirage/blob/master/lib/mirage.ml#L362-L367 so that before the `match_impl` on L363 it first uses Info.context to extract the 'a of the 'a value i pass in before calling `crunch` and friends with the extracted 'a ?
<mort___>
and i *cannot* hack around this from within the config.ml , correct?
<mort___>
for a concrete example,
<mort___>
let privkey =
<mort___>
~docv:"FILE"
<mort___>
let doc = Key.Arg.info
<mort___>
~doc:"The full path to PEM encoded unencrypted private key in FILE"
<mort___>
match Key.(default @@ value privkey) with
<mort___>
| None -> failwith "BAD PRIVKEY! BAD!"
<mort___>
| Some file -> generic_kv_ro file
<Drup>
No, that's not right at all
<mort___>
except i need the real context not the Key.default context?
<Drup>
1) the context is only available inside the various methods of the device
<Drup>
you don't have control when you will have it, functoria will give it to you when it needs to configure the device
<Drup>
In particular, *you don't have when executing config.ml*
<Drup>
+it
<mort___>
ok so that answers one question i think — i cannot hack around this inside config.ml, i need to patch mirage.ml itself
<Drup>
Yeah, I kept the various APIs, but with the insight now, I think we should move all the APIs towards accepting values, for better flexibility
<Drup>
Also, as I said, you don't have bind, and you won't emulate bind with match_impl (or match, for that matter)
<mort___>
ok
<Drup>
the good way to solve this is to let the device itself check that the values are correct. It's part of the configure step after all ...
<Drup>
Something I wanted to do, but didn't in the end, was to expose the various classes, so that people could inherit from them and built their own devices like that. but I never did that :/
<Drup>
(it would add a lot of stuff to the API)
<mort___>
so when I propose a patch for mirage.ml to have those APIs now take values instead, should they take values or keys? and presumably i then must extract the 'a from the 'a value using something like "Key.eval (Info.context i) value" ?
<Drup>
yes, that's the good way to extra things
<Drup>
about values or keys ...
<Drup>
values are either keys or constants, keys can only be keys
<Drup>
so, values are more general
<mort___>
yup, i see that now
copy` has joined #mirage
<Drup>
but we are going to bump in a limitation in functoria's API here, I think. the "keys" method only accept keys, not values, but it's used to compute the keys that needs to end up in the command line
<Drup>
so we will need to make functoria bit more liberal here
<mort___>
i don't follow :)
<Drup>
Yeaah, it's a bit technical
<Drup>
:/
<Drup>
so, to obtain the list of things that should end up in the command line
<Drup>
we look at all devices and get the list of keys with the #keys method
<Drup>
now, imagine you pass your value around, and it depends on a key. You want this one to end up in the command line.
<Drup>
Currently, there is no proper way to do that cleanly
<Drup>
Oh, actually, there is one, "Key.deps", but it's a bit inconvenient
<Drup>
We will cross that bridge when we get there, I'm thinking aloud :D
<mort___>
:)
<Drup>
Modifying all the devices that takes arguments is going to be a bit of work
<Drup>
it's probably worthwile for mirage 3.0 though
<mort___>
ye
<mort___>
s
<mort___>
i'm adding a comment to the relevant issue
<mort___>
i wanted to try and make my comment useful hence all these questions :)