bjornbm / dimensional

Dimensional library variant built on Data Kinds, Closed Type Families, TypeNats (GHC 7.8+).
BSD 3-Clause "New" or "Revised" License
102 stars 15 forks source link

Non-breaking space between numerical value and unit symbol? #191

Closed bjornbm closed 5 years ago

bjornbm commented 6 years ago

I try to always use non-breaking spaces between the numerical value and the unit symbol when I write. Would be nice to have that in dimensional too but don't know if it may cause any headaches?

Would also apply to the space in, for example, “° s^-1”, if applicable.

dmcclean commented 6 years ago

I don't see why this would be a problem, as the character has been around forever and has a low codepoint. The only potential issue might be with the zaniness of console output on Windows, I will try it.

dmcclean commented 5 years ago

This has a significant effect on doctests, but I am writing some comments to warn of it and powering through because I think it is valuable.

bjornbm commented 5 years ago

👍 Is the impact that the doctest author must remember to put a non-breaking space in the reference output (if handwritten)? Or something more (doctest parser breaking or something??)?

dmcclean commented 5 years ago

Primarily the former, although there is a single one that I am having trouble fixing that way, for a reason that is currently perplexing me (but may have to do with the escaping behavior of the show instance for strings).

dmcclean commented 5 years ago

The strange one used showIn and then the result line had a quoted string that would have resulted from the Show instance for String. I added an explicit putStrLn.

bjornbm commented 5 years ago

For what it's worth I got a successful doctest with:

-- >>> showIn watt $ (37 *~ volt) * (4 *~ ampere)
-- "148.0\160W"

Doesn't that work on you system?

dmcclean commented 5 years ago

I had put in an actual non-breaking space, not an escaped one. I got a complaint where the expected version had "\"148.0\160W\"" and the actual version had "\"148.0\\160W\"" (or vice versa). I decided the putStrLn version seemed cleaner.