-
Notifications
You must be signed in to change notification settings - Fork 2
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
tab-separated columns #30
Comments
I agree but maybe not just tuples. Every container that contains more than one value should separate them with > hawk -e '[(1, 2)]'
1\t2
> hawk -e '[["foo bar", "foo bar"]]'
foo bar\tfoo bar A bonus is that you can print on the same line many tab-separated strings that are easy to parse: > hawk -e '[["hello world","foo bar"]]'
hello world\tfoo bar
> hawk -e '[["hello world","foo bar"]]' | hawk -m "L.map (L.length . words) . split '\t'"
2\t2 |
Considering I have already done the code to do this for hsp, if you both agree I can push it |
I have concerns about allowing a list to represent a single line, as this will interact badly with --magic. As you know, the whole point of --magic is to use the type of the user's expression to infer whether the expression is supposed to be a map...
a fold...
or an operation on a list of lines:
But if we allow lists to represent the content of a single line, then it is no longer clear whether 'L.drop 7' is supposed to drop the first 7 lines or, interpreted as a map, the first 7 columns. I think the first interpretation is going to be more common, so if we do allow lists to represent lines, magic won't complain that the type is ambiguous, it should instead try to do the most-probably-correct thing:
Therefore, I am slightly worried that if we teach the user that a list of lists represents lines of tab-separated items, then the user will expect to be able to use --map to omit the outer list, and if we allow that, then the user will expect --magic to detect that a map is expected, and that won't work. It's a slippery slope.
Notice that the third attempt has a different behaviour than the first two. |
I prefer the distinction between lists and tuples, ie, lists items are separate lines, tuples are tab separated. |
@gelisam this is a delicate topic. I see the imput of a unix command as a list of list of strings, where the first list is the list of lines and the second list is the list of words in a single line. So for me the example
For me, the user must understand the types involved in
I like this way to be honest. Eventually, a solution could be to let magic work with -d and -m:
@ssadler |
I'm fine with the behaviour of the above 6 examples. |
How about tab-separated tuples, but whitespace-separated lists? |
hawk currently outputs tuples as space-separated columns by default. I think tabs should be the default.
The text was updated successfully, but these errors were encountered: