;lib: drop SystemString left from GHC pre 7.2
We are relying on base-4.9 or newer. Thus we don't compile anymore with GHC version lower than 8.0.1.
This commit is contained in:
		
							parent
							
								
									68b1cacf0f
								
							
						
					
					
						commit
						31ae3d3aaf
					
				| @ -29,7 +29,7 @@ module Hledger.Utils (---- provide these frequently used modules - or not, for c | ||||
|                           -- Debug.Trace.trace, | ||||
|                           -- module Data.PPrint, | ||||
|                           -- module Hledger.Utils.UTF8IOCompat | ||||
|                           SystemString,fromSystemString,toSystemString,error',userError',usageError, | ||||
|                           error',userError',usageError, | ||||
|                           -- the rest need to be done in each module I think | ||||
|                           ) | ||||
| where | ||||
| @ -66,7 +66,7 @@ import Hledger.Utils.Color | ||||
| import Hledger.Utils.Tree | ||||
| -- import Prelude hiding (readFile,writeFile,appendFile,getContents,putStr,putStrLn) | ||||
| -- import Hledger.Utils.UTF8IOCompat   (readFile,writeFile,appendFile,getContents,putStr,putStrLn) | ||||
| import Hledger.Utils.UTF8IOCompat (SystemString,fromSystemString,toSystemString,error',userError',usageError) | ||||
| import Hledger.Utils.UTF8IOCompat (error',userError',usageError) | ||||
| 
 | ||||
| 
 | ||||
| -- tuples | ||||
|  | ||||
| @ -15,6 +15,9 @@ Example usage: | ||||
| do the right thing, so this file is a no-op and on its way to being removed. | ||||
| Not carefully tested. | ||||
| 
 | ||||
| 2019/10/20 update: all packages have base>=4.9 which corresponds to GHC v8.0.1 | ||||
| and higher. Tear this file apart! | ||||
| 
 | ||||
| -} | ||||
| -- TODO obsolete ? | ||||
| 
 | ||||
| @ -29,9 +32,6 @@ module Hledger.Utils.UTF8IOCompat ( | ||||
|   hPutStr, | ||||
|   hPutStrLn, | ||||
|   -- | ||||
|   SystemString, | ||||
|   fromSystemString, | ||||
|   toSystemString, | ||||
|   error', | ||||
|   userError', | ||||
|   usageError, | ||||
| @ -85,37 +85,19 @@ import System.IO -- (Handle) | ||||
| -- bs_hPutStr        = B8.hPut | ||||
| -- bs_hPutStrLn h bs = B8.hPut h bs >> B8.hPut h (B.singleton 0x0a) | ||||
| 
 | ||||
| 
 | ||||
| -- | A string received from or being passed to the operating system, such | ||||
| -- as a file path, command-line argument, or environment variable name or | ||||
| -- value. With GHC versions before 7.2 on some platforms (posix) these are | ||||
| -- typically encoded. When converting, we assume the encoding is UTF-8 (cf | ||||
| -- <http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#UTF8>). | ||||
| type SystemString = String | ||||
| 
 | ||||
| -- | Convert a system string to an ordinary string, decoding from UTF-8 if | ||||
| -- it appears to be UTF8-encoded and GHC version is less than 7.2. | ||||
| fromSystemString :: SystemString -> String | ||||
| fromSystemString = id | ||||
| 
 | ||||
| -- | Convert a unicode string to a system string, encoding with UTF-8 if | ||||
| -- we are on a posix platform with GHC < 7.2. | ||||
| toSystemString :: String -> SystemString | ||||
| toSystemString = id | ||||
| 
 | ||||
| -- | A SystemString-aware version of error. | ||||
| error' :: String -> a | ||||
| error' = | ||||
| #if __GLASGOW_HASKELL__ < 800 | ||||
| -- (easier than if base < 4.9) | ||||
|   error . toSystemString | ||||
|   error | ||||
| #else | ||||
|   errorWithoutStackTrace . toSystemString | ||||
|   errorWithoutStackTrace | ||||
| #endif | ||||
| 
 | ||||
| -- | A SystemString-aware version of userError. | ||||
| userError' :: String -> IOError | ||||
| userError' = userError . toSystemString | ||||
| userError' = userError | ||||
| 
 | ||||
| -- | A SystemString-aware version of error that adds a usage hint. | ||||
| usageError :: String -> a | ||||
|  | ||||
| @ -396,7 +396,7 @@ defcliopts = CliOpts | ||||
| 
 | ||||
| -- | Convert possibly encoded option values to regular unicode strings. | ||||
| decodeRawOpts :: RawOpts -> RawOpts | ||||
| decodeRawOpts = map (\(name',val) -> (name', fromSystemString val)) | ||||
| decodeRawOpts = id  -- TODO: drop usage of this | ||||
| 
 | ||||
| -- | Default width for hledger console output, when not otherwise specified. | ||||
| defaultWidth :: Int | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user