{-# 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 :: Lens' IOException String
location String -> f String
f IOException
s = String -> f String
f (IOException -> String
ioe_location IOException
s) f String -> (String -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \String
e -> IOException
s { ioe_location = e }
{-# INLINE location #-}
description :: Lens' IOException String
description :: Lens' IOException String
description String -> f String
f IOException
s = String -> f String
f (IOException -> String
ioe_description IOException
s) f String -> (String -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \String
e -> IOException
s { ioe_description = e }
{-# INLINE description #-}
handle :: Lens' IOException (Maybe Handle)
handle :: Lens' IOException (Maybe Handle)
handle Maybe Handle -> f (Maybe Handle)
f IOException
s = Maybe Handle -> f (Maybe Handle)
f (IOException -> Maybe Handle
ioe_handle IOException
s) f (Maybe Handle) -> (Maybe Handle -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Maybe Handle
e -> IOException
s { ioe_handle = e }
{-# INLINE handle #-}
fileName :: Lens' IOException (Maybe FilePath)
fileName :: Lens' IOException (Maybe String)
fileName Maybe String -> f (Maybe String)
f IOException
s = Maybe String -> f (Maybe String)
f (IOException -> Maybe String
ioe_filename IOException
s) f (Maybe String) -> (Maybe String -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Maybe String
e -> IOException
s { ioe_filename = e }
{-# INLINE fileName #-}
errno :: Lens' IOException (Maybe CInt)
errno :: Lens' IOException (Maybe CInt)
errno Maybe CInt -> f (Maybe CInt)
f IOException
s = Maybe CInt -> f (Maybe CInt)
f (IOException -> Maybe CInt
ioe_errno IOException
s) f (Maybe CInt) -> (Maybe CInt -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Maybe CInt
e -> IOException
s { ioe_errno = e }
{-# INLINE errno #-}
errorType :: Lens' IOException IOErrorType
errorType :: Lens' IOException IOErrorType
errorType IOErrorType -> f IOErrorType
f IOException
s = IOErrorType -> f IOErrorType
f (IOException -> IOErrorType
ioe_type IOException
s) f IOErrorType -> (IOErrorType -> IOException) -> f IOException
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \IOErrorType
e -> IOException
s { ioe_type = e }
{-# INLINE errorType #-}
_AlreadyExists :: Prism' IOErrorType ()
_AlreadyExists :: Prism' IOErrorType ()
_AlreadyExists = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
AlreadyExists
_NoSuchThing :: Prism' IOErrorType ()
_NoSuchThing :: Prism' IOErrorType ()
_NoSuchThing = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
NoSuchThing
_ResourceBusy :: Prism' IOErrorType ()
_ResourceBusy :: Prism' IOErrorType ()
_ResourceBusy = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
ResourceBusy
_ResourceExhausted :: Prism' IOErrorType ()
_ResourceExhausted :: Prism' IOErrorType ()
_ResourceExhausted = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
ResourceExhausted
_EOF :: Prism' IOErrorType ()
_EOF :: Prism' IOErrorType ()
_EOF = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
EOF
_IllegalOperation :: Prism' IOErrorType ()
_IllegalOperation :: Prism' IOErrorType ()
_IllegalOperation = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
IllegalOperation
_PermissionDenied :: Prism' IOErrorType ()
_PermissionDenied :: Prism' IOErrorType ()
_PermissionDenied = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
PermissionDenied
_UserError :: Prism' IOErrorType ()
_UserError :: Prism' IOErrorType ()
_UserError = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
UserError
_UnsatisfiedConstraints :: Prism' IOErrorType ()
_UnsatisfiedConstraints :: Prism' IOErrorType ()
_UnsatisfiedConstraints = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
UnsatisfiedConstraints
_SystemError :: Prism' IOErrorType ()
_SystemError :: Prism' IOErrorType ()
_SystemError = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
SystemError
_ProtocolError :: Prism' IOErrorType ()
_ProtocolError :: Prism' IOErrorType ()
_ProtocolError = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
ProtocolError
_OtherError :: Prism' IOErrorType ()
_OtherError :: Prism' IOErrorType ()
_OtherError = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
OtherError
_InvalidArgument :: Prism' IOErrorType ()
_InvalidArgument :: Prism' IOErrorType ()
_InvalidArgument = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
InvalidArgument
_InappropriateType :: Prism' IOErrorType ()
_InappropriateType :: Prism' IOErrorType ()
_InappropriateType = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
InappropriateType
_HardwareFault :: Prism' IOErrorType ()
_HardwareFault :: Prism' IOErrorType ()
_HardwareFault = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
HardwareFault
_UnsupportedOperation :: Prism' IOErrorType ()
_UnsupportedOperation :: Prism' IOErrorType ()
_UnsupportedOperation = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
UnsupportedOperation
_TimeExpired :: Prism' IOErrorType ()
_TimeExpired :: Prism' IOErrorType ()
_TimeExpired = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
TimeExpired
_ResourceVanished :: Prism' IOErrorType ()
_ResourceVanished :: Prism' IOErrorType ()
_ResourceVanished = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
ResourceVanished
_Interrupted :: Prism' IOErrorType ()
_Interrupted :: Prism' IOErrorType ()
_Interrupted = IOErrorType -> Prism' IOErrorType ()
forall a. Eq a => a -> Prism' a ()
only IOErrorType
Interrupted