-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Concat_or_split #849
Conversation
65b6bbb
to
a9d3b5c
Compare
Putting this up separately and I'm a bit surprised this doesn't break any tests. I guess we don't have a test suite for this? |
src/action.ml
Outdated
| Paths (_, Concat) | Strings (_, Concat) -> false | ||
| Paths [_] -> false | ||
| Strings [_] -> false | ||
| _ -> false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why is that? If we only have 1 value then we aren't multivalued.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this function is the same as this one:
let is_multivalued _ = false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes. Oops.
I think some of the cases we could represent with the previous types didn't make much sense in practice, so there probably never appear. BTW, the error messages in
|
a9d3b5c
to
c87f7e6
Compare
@diml I've added the length to the error message, though I'm not sure the boilerplate necessary to do it is worth it. |
846d6d3
to
51ed37a
Compare
What about getting rid of |
|
I don't think it matters indeed since it's only going to be slow in error cases. |
Why's that? we checked for multivalued-ness for every valid substitution. |
I've implemented the desired behavior for actions by adding a |
the only place where we call
We can only go in the error case if the list is not of length 1. And if the list is of length 1, then |
I propose the following API for String_with_vars (without functors): module Mode : sig
type 'a t =
| Single : Value.t t
| Many : Value.t list t
end
val expand
: t
-> mode:'a Mode.t
-> dir:Path.t
-> f:(Loc.t -> string -> Value.t list option)
-> 'a
module Expand_partial : sig
type nonrec 'a t =
| Expansion of 'a
| Unexpanded of t
end
val partial_expand
: t
-> mode:'a Mode.t
-> dir:Path.t
-> f:(Loc.t -> string -> Value.t list option)
-> 'a Expand_partial.t where type t =
| String of string
| Path of Path.t and later we'll add Overall this will simplify the code and implement the desired semantic in a more obvious way. |
@diml that looks good, I will work towards that. Is it desirable that |
One case I was thinking of is program and arguments: we want the first element to be a path but the rest to be strings. |
@diml have a look |
src/action.ml
Outdated
| Strings (s :: l, Split) -> | ||
(P.of_string ~dir s, l) | ||
end | ||
let var_expansion_to_prog_and_args p ~dir = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about prog_and_args_of_values
?
17e5b49
to
72277f9
Compare
src/string_with_vars.ml
Outdated
| Text s :: items -> loop (s :: acc_text) acc items | ||
| Var (syntax, v) as it :: items -> | ||
begin match f t.loc v with | ||
| Some (([] | _::_) as e) when not t.quoted -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be _::_::_
. BTW, I suggest to use the same branches in expand
and partial_expand
. I was a bit surprised at first that there were different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is ugly. I'll try to factor it out as well.
src/stdune/either.mli
Outdated
@@ -3,3 +3,5 @@ | |||
type ('a, 'b) t = | |||
| Left of 'a | |||
| Right of 'b | |||
|
|||
val either : ('a, 'b) t -> l:('a -> 'c) -> r:('b -> 'c) -> 'c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this function map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Though this function is called either
in Haskell for example.
@rgrinberg looks good. It's much cleaner than master. I suggest that we also add |
The I suggest that we simply change |
@diml btw, another way to make the code more DRY would be to implement expansion in terms of partial expansion. I'm thinking that we can just try a partial expansion and modify |
I might be missing something here, why can't we just add them |
a2f7e64
to
babaea1
Compare
@diml the misc tests are fixed. |
785939d
to
eb60f68
Compare
How would this work for |
c7a46a0
to
a14169d
Compare
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Thie property will now be determined from the context Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Since it's used more than once Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This is useful for an error message that includes the number of items we've expanded to. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
These variables can occur outside actions so such expansions shouldn't live under Var_expansion. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Multivalues are no longer allowed when unquoted, and paths are no longer needlessly converted. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Make it expand only to Value.t since the string only version wasn't really used. Variable expansions are now Value.t list. Which also gives the flexibility for a value to expand to a collection of more than 1 value. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
The partial expansion had a bug in its condition for a 1 element value list. This fixes the bug by implementing the condition once and for all. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
a14169d
to
9fc161d
Compare
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
9fc161d
to
abfa90b
Compare
@diml done. this PR seems to build bin_prot (and the rest of the workspace) just fine. |
Thie property will now be determined from the context
Signed-off-by: Rudi Grinberg rudi.grinberg@gmail.com