-
Notifications
You must be signed in to change notification settings - Fork 11
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
measureAlignment can only match first character matching predicate #32
Comments
Actually, I think this can be accomplished without any changes. I think it just requires a somewhat odd implementation of Cell.
I'll close this issue, but it might be good to have a record of it in case anybody comes across a similar need. |
This could be implemented but probably needs a bit more thought:
There is also the more general question whether a text input is sufficient enough to get a good output rendered. For example, for scientific output one might want to use the exponent notation but just for numbers that are too big. But getting semantics into input would probably open up a whole new can of worms. But for anyone interested, knock yourself out. 😆 |
I agree that this is probably too specific to be included in anything we provide. But it's a useful trick to keep in mind for specific use cases people may have. But more generally, the type of |
Based on the way
measureAlignment :: Cell a => (Char -> Bool) -> a -> AlignInfo
is defined and implemented, it will always match the first character within the cell which satisfies the predicate. Unfortunately this is not sufficient for all the cases one might want. You might want to match the first character on the right, or you might want to use a predicate which considers more than characters.In my case, I want to align on decimal points, but among numbers which might use a mix of commas and periods for decimal separators. Furthermore, they might use the other symbol as a thousands separator. Here's an example of the output I'd like:
I haven't yet figured out what the best approach to this problem is, but
measureAlignment
is not up to snuff. Clearly the job of marking which of these characters is the decimal point would not be the job oftable-layout
and would be up to me, but even if I could mark it somehow,measureAlignment
couldn't take it into account since it only sees a single character at a time from the left. At the very least, we'd need to generalise the form of the predicate somehow.The text was updated successfully, but these errors were encountered: