{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module System.IO.Error.Lens where
import Control.Lens
import GHC.IO.Exception
import System.IO
import Foreign.C.Types
location :: Lens' IOException String
location f s = f (ioe_location s) <&> \e -> s { ioe_location = e }
{-# INLINE location #-}
description :: Lens' IOException String
description f s = f (ioe_description s) <&> \e -> s { ioe_description = e }
{-# INLINE description #-}
handle :: Lens' IOException (Maybe Handle)
handle f s = f (ioe_handle s) <&> \e -> s { ioe_handle = e }
{-# INLINE handle #-}
fileName :: Lens' IOException (Maybe FilePath)
fileName f s = f (ioe_filename s) <&> \e -> s { ioe_filename = e }
{-# INLINE fileName #-}
errno :: Lens' IOException (Maybe CInt)
errno f s = f (ioe_errno s) <&> \e -> s { ioe_errno = e }
{-# INLINE errno #-}
errorType :: Lens' IOException IOErrorType
errorType f s = f (ioe_type s) <&> \e -> s { ioe_type = e }
{-# INLINE errorType #-}
_AlreadyExists :: Prism' IOErrorType ()
_AlreadyExists = only AlreadyExists
_NoSuchThing :: Prism' IOErrorType ()
_NoSuchThing = only NoSuchThing
_ResourceBusy :: Prism' IOErrorType ()
_ResourceBusy = only ResourceBusy
_ResourceExhausted :: Prism' IOErrorType ()
_ResourceExhausted = only ResourceExhausted
_EOF :: Prism' IOErrorType ()
_EOF = only EOF
_IllegalOperation :: Prism' IOErrorType ()
_IllegalOperation = only IllegalOperation
_PermissionDenied :: Prism' IOErrorType ()
_PermissionDenied = only PermissionDenied
_UserError :: Prism' IOErrorType ()
_UserError = only UserError
_UnsatisfiedConstraints :: Prism' IOErrorType ()
_UnsatisfiedConstraints = only UnsatisfiedConstraints
_SystemError :: Prism' IOErrorType ()
_SystemError = only SystemError
_ProtocolError :: Prism' IOErrorType ()
_ProtocolError = only ProtocolError
_OtherError :: Prism' IOErrorType ()
_OtherError = only OtherError
_InvalidArgument :: Prism' IOErrorType ()
_InvalidArgument = only InvalidArgument
_InappropriateType :: Prism' IOErrorType ()
_InappropriateType = only InappropriateType
_HardwareFault :: Prism' IOErrorType ()
_HardwareFault = only HardwareFault
_UnsupportedOperation :: Prism' IOErrorType ()
_UnsupportedOperation = only UnsupportedOperation
_TimeExpired :: Prism' IOErrorType ()
_TimeExpired = only TimeExpired
_ResourceVanished :: Prism' IOErrorType ()
_ResourceVanished = only ResourceVanished
_Interrupted :: Prism' IOErrorType ()
_Interrupted = only Interrupted