Open acapi opened 5 years ago
This is probably an issue with your terminal/stdout not being set up to support unicode characters. This is more an issue of the environment; although I think that using unicode characters in the show instance instead of the more compatible ascii alternative should be avoided.
c.f. https://stackoverflow.com/questions/28003875/haskell-save-unicode-string-characters-to-file
Now I use this pretty function:
import qualified Data.Map as M
prettyMatrixASCII = putStrLn . f . prettyMatrix
where
f xs = map (\x -> case M.lookup x conv of
Nothing -> x
Just y -> y) xs
where
conv = M.fromList [('\9488','\\'),('\9474','|'),('\9484','/'),('\9492','\\'),('\9496','/')]
With results similar to the original function:
/ \
| 1 0 -1 -2 |
| 3 2 1 0 |
| 5 4 3 2 |
| 7 6 5 4 |
\ /
However it is very inconvenient to have to repopulate this function in every module that uses Data.Matrix.
Could you insert in the library a function similar to mine?
Thanks for pinging again and providing some code. I will get this fixed over the weekend.
It is not possible to correctly display an array in WinGHCi.
prettyMatrix $ matrix 4 4 $ \(i,j) -> 2*i - j
"\9484 \9488\n\9474 1 0 -1 -2 \9474\n\9474 3 2 1 0 \9474\n\9474 5 4 3 2 \9474\n\9474 7 6 5 4 \9474\n\9492 \9496" it :: String (0.00 secs, 193,072 bytes)
putStrLn it
*** Exception:It's all OK if:
putStrLn $ filter (
notElem['\9488','\9474','\9484','\9492','\9496'] ) $ prettyMatrix $ matrix 4 4 $ \(i,j) -> 2*i - j
1 0 -1 -2 3 2 1 0 5 4 3 2 7 6 5 4