Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/prelude/PreludeIO/Show_IOError.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module Prelude(Show(..)) where

import DIOError
import IO
import NHC.DErrNo
import StrError

instance  Show IOError  where
	showsPrec p (IOError cmd mbfilename mbhandle errno) =
		showString "I/O error:\n  action :  " .
		showString cmd .
		(case mbfilename of
		    Just fn -> showString "\n  on file:  " . showString fn
		    Nothing ->
		        (case mbhandle of
		            Nothing -> id
		            Just handle ->
		                (case hGetFileName handle of
		                    Nothing -> id
		                    Just fn ->
					showString "\n  on file:  " .
					showString fn))) .
		showString "\n  gave   :  " .
		shows errno . showString " (" .
		showString (strError errno) .
		showString ")"
	showsPrec p (EOFError op handle) =
		showString "End of file detected in " .
		showString op . showString " on " .
		(case hGetFileName handle of
			    Nothing -> showString "un-named handle"
			    Just fn -> showString fn) . showChar '.'
	showsPrec p (PatternError "") =
		showString "Pattern match failure in do statement"
	showsPrec p (PatternError str) =
		showString "Pattern match failure in do statement (" .
		showString str . showString ")"
	showsPrec p (UserError "" str) =
		showString "I/O error (user-defined):\n  "  . showString str
	showsPrec p (UserError loc str) =
		showString "I/O error (user-defined), " . showString loc .
		showString ":\n  " . showString str

	showsType a = showString "IOError"


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.