-- | Returns the sequence of unicode space characters closest to the
-- specified width.
getSpaceChars :: Rational -> [Char]
getSpaceChars n =
  case n of
       _ | n < 0      -> "\x200B"  -- no negative space chars in unicode
         | n <= 2/18  -> "\x200A"
         | n <= 3/18  -> "\x2006"
         | n <= 4/18  -> "\xA0"   -- could also be "\x2005"
         | n <= 5/18  -> "\x2005"
         | n <= 7/18  -> "\x2004"
         | n <= 9/18  -> "\x2000"
         | n < 1      -> '\x2000' : getSpaceChars (n - (1/2))
         | n == 1     -> "\x2001"
         | otherwise  -> '\x2001' : getSpaceChars (n - 1)

-- Accents which go under the character
getSpaceChars :: Rational -> [Char]
getSpaceChars n =
  case n of
       _ | n < 0      -> "\x200B"  -- no negative space chars in unicode
         | n <= 2/18  -> "\x200A"
         | n <= 3/18  -> "\x2006"
         | n <= 4/18  -> "\xA0"   -- could also be "\x2005"
         | n <= 5/18  -> "\x2005"
         | n <= 7/18  -> "\x2004"
         | n <= 9/18  -> "\x2000"
         | n < 1      -> '\x2000' : getSpaceChars (n - (1/2))
         | n == 1     -> "\x2001"
         | otherwise  -> '\x2001' : getSpaceChars (n - 1)

-- Accents which go under the character
getSpaceChars n =
  case n of
       _ | n < 0      -> "\x200B"  -- no negative space chars in unicode
         | n <= 2/18  -> "\x200A"
         | n <= 3/18  -> "\x2006"
         | n <= 4/18  -> "\xA0"   -- could also be "\x2005"
         | n <= 5/18  -> "\x2005"
         | n <= 7/18  -> "\x2004"
         | n <= 9/18  -> "\x2000"
         | n < 1      -> '\x2000' : getSpaceChars (n - (1/2))
         | n == 1     -> "\x2001"
         | otherwise  -> '\x2001' : getSpaceChars (n - 1)

-- Accents which go under the character