yam-0.5.17: Yam Web

Safe HaskellNone
LanguageHaskell2010

Yam.Types

Contents

Synopsis

App Monad

data App a Source #

Instances
Monad App Source # 
Instance details

Defined in Yam.Types

Methods

(>>=) :: App a -> (a -> App b) -> App b #

(>>) :: App a -> App b -> App b #

return :: a -> App a #

fail :: String -> App a #

Functor App Source # 
Instance details

Defined in Yam.Types

Methods

fmap :: (a -> b) -> App a -> App b #

(<$) :: a -> App b -> App a #

Applicative App Source # 
Instance details

Defined in Yam.Types

Methods

pure :: a -> App a #

(<*>) :: App (a -> b) -> App a -> App b #

liftA2 :: (a -> b -> c) -> App a -> App b -> App c #

(*>) :: App a -> App b -> App b #

(<*) :: App a -> App b -> App a #

MonadIO App Source # 
Instance details

Defined in Yam.Types

Methods

liftIO :: IO a -> App a #

MonadUnliftIO App Source # 
Instance details

Defined in Yam.Types

Methods

askUnliftIO :: App (UnliftIO App) #

withRunInIO :: ((forall a. App a -> IO a) -> IO b) -> App b #

HasValid App Source # 
Instance details

Defined in Yam.Types

Methods

invalid :: HasI18n a => a -> App b #

mark :: String -> App a -> App a #

MonadLogger App Source # 
Instance details

Defined in Yam.Types

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> App () #

MonadLoggerIO App Source # 
Instance details

Defined in Yam.Types

Methods

askLoggerIO :: App (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadTracing App Source # 
Instance details

Defined in Yam.Middleware.Trace

Methods

runInSpan :: SpanName -> (Span -> App ()) -> (Span -> App a) -> App a Source #

MonadTracer App Source # 
Instance details

Defined in Yam.Middleware.Trace

Methods

askSpanContext :: App SpanContext Source #

MonadReader Env App Source # 
Instance details

Defined in Yam.Types

Methods

ask :: App Env #

local :: (Env -> Env) -> App a -> App a #

reader :: (Env -> a) -> App a #

runApp :: MonadIO m => Env -> App a -> m a Source #

runTestApp :: Key a -> a -> App b -> IO b Source #

askAttr :: Key a -> App (Maybe a) Source #

withAttr :: Key a -> a -> App b -> App b Source #

Environment

data AppConfig Source #

Constructors

AppConfig 

Fields

Instances
Eq AppConfig Source # 
Instance details

Defined in Yam.Types.Env

Show AppConfig Source # 
Instance details

Defined in Yam.Types.Env

Default AppConfig Source # 
Instance details

Defined in Yam.Types.Env

Methods

def :: AppConfig #

FromProp AppConfig Source # 
Instance details

Defined in Yam.Types.Env

data Env Source #

Instances
Default Env Source # 
Instance details

Defined in Yam.Types.Env

Methods

def :: Env #

MonadReader Env App Source # 
Instance details

Defined in Yam.Types

Methods

ask :: App Env #

local :: (Env -> Env) -> App a -> App a #

reader :: (Env -> a) -> App a #

getAttr :: Key a -> Env -> Maybe a Source #

reqAttr :: Default a => Key a -> Env -> a Source #

setAttr :: Key a -> a -> Env -> Env Source #

Utilities

showText :: Show a => a -> Text Source #

Reexport Functions

type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #

class Default a where #

A class for types with a default value.

Minimal complete definition

Nothing

Methods

def :: a #

The default value for this type.

Instances
Default Double 
Instance details

Defined in Data.Default.Class

Methods

def :: Double #

Default Float 
Instance details

Defined in Data.Default.Class

Methods

def :: Float #

Default Int 
Instance details

Defined in Data.Default.Class

Methods

def :: Int #

Default Int8 
Instance details

Defined in Data.Default.Class

Methods

def :: Int8 #

Default Int16 
Instance details

Defined in Data.Default.Class

Methods

def :: Int16 #

Default Int32 
Instance details

Defined in Data.Default.Class

Methods

def :: Int32 #

Default Int64 
Instance details

Defined in Data.Default.Class

Methods

def :: Int64 #

Default Integer 
Instance details

Defined in Data.Default.Class

Methods

def :: Integer #

Default Ordering 
Instance details

Defined in Data.Default.Class

Methods

def :: Ordering #

Default Word 
Instance details

Defined in Data.Default.Class

Methods

def :: Word #

Default Word8 
Instance details

Defined in Data.Default.Class

Methods

def :: Word8 #

Default Word16 
Instance details

Defined in Data.Default.Class

Methods

def :: Word16 #

Default Word32 
Instance details

Defined in Data.Default.Class

Methods

def :: Word32 #

Default Word64 
Instance details

Defined in Data.Default.Class

Methods

def :: Word64 #

Default () 
Instance details

Defined in Data.Default.Class

Methods

def :: () #

Default All 
Instance details

Defined in Data.Default.Class

Methods

def :: All #

Default Any 
Instance details

Defined in Data.Default.Class

Methods

def :: Any #

Default CShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CShort #

Default CUShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CUShort #

Default CInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CInt #

Default CUInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CUInt #

Default CLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLong #

Default CULong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULong #

Default CLLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLLong #

Default CULLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULLong #

Default CFloat 
Instance details

Defined in Data.Default.Class

Methods

def :: CFloat #

Default CDouble 
Instance details

Defined in Data.Default.Class

Methods

def :: CDouble #

Default CPtrdiff 
Instance details

Defined in Data.Default.Class

Methods

def :: CPtrdiff #

Default CSize 
Instance details

Defined in Data.Default.Class

Methods

def :: CSize #

Default CSigAtomic 
Instance details

Defined in Data.Default.Class

Methods

def :: CSigAtomic #

Default CClock 
Instance details

Defined in Data.Default.Class

Methods

def :: CClock #

Default CTime 
Instance details

Defined in Data.Default.Class

Methods

def :: CTime #

Default CUSeconds 
Instance details

Defined in Data.Default.Class

Methods

def :: CUSeconds #

Default CSUSeconds 
Instance details

Defined in Data.Default.Class

Methods

def :: CSUSeconds #

Default CIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntPtr #

Default CUIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntPtr #

Default CIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntMax #

Default CUIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntMax #

Default PropConfig 
Instance details

Defined in Salak

Methods

def :: PropConfig #

Default Env Source # 
Instance details

Defined in Yam.Types.Env

Methods

def :: Env #

Default AppConfig Source # 
Instance details

Defined in Yam.Types.Env

Methods

def :: AppConfig #

Default LogConfig Source # 
Instance details

Defined in Yam.Logger

Methods

def :: LogConfig #

Default ClientConfig Source # 
Instance details

Defined in Yam.Middleware.Client

Methods

def :: ClientConfig #

Default TraceConfig Source # 
Instance details

Defined in Yam.Middleware.Trace

Methods

def :: TraceConfig #

Default [a] 
Instance details

Defined in Data.Default.Class

Methods

def :: [a] #

Default (Maybe a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Maybe a #

Integral a => Default (Ratio a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Ratio a #

Default a => Default (IO a) 
Instance details

Defined in Data.Default.Class

Methods

def :: IO a #

(Default a, RealFloat a) => Default (Complex a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Complex a #

Default (First a) 
Instance details

Defined in Data.Default.Class

Methods

def :: First a #

Default (Last a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Last a #

Default a => Default (Dual a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Dual a #

Default (Endo a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Endo a #

Num a => Default (Sum a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Sum a #

Num a => Default (Product a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Product a #

Default (AuthChecker principal) Source # 
Instance details

Defined in Yam.Middleware.Auth

Methods

def :: AuthChecker principal #

Default r => Default (e -> r) 
Instance details

Defined in Data.Default.Class

Methods

def :: e -> r #

(Default a, Default b) => Default (a, b) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b) #

(Default a, Default b, Default c) => Default (a, b, c) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c) #

(Default a, Default b, Default c, Default d) => Default (a, b, c, d) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d) #

(Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e) #

(Default a, Default b, Default c, Default d, Default e, Default f) => Default (a, b, c, d, e, f) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f) #

(Default a, Default b, Default c, Default d, Default e, Default f, Default g) => Default (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f, g) #

data Text #

A space efficient, packed, unboxed Unicode text type.

Instances
Hashable Text 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Text -> Int #

hash :: Text -> Int #

ToJSON Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

KeyValue Object

Constructs a singleton HashMap. For calling functions that demand an Object for constructing objects. To be used in conjunction with mconcat. Prefer to use object where possible.

Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Object #

KeyValue Pair 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

ToJSONKey Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

Chunk Text 
Instance details

Defined in Data.Attoparsec.Internal.Types

Associated Types

type ChunkElem Text :: Type #

ToValue Text 
Instance details

Defined in Text.Blaze

ToMarkup Text 
Instance details

Defined in Text.Blaze

FoldCase Text 
Instance details

Defined in Data.CaseInsensitive.Internal

Methods

foldCase :: Text -> Text #

foldCaseList :: [Text] -> [Text]

ToLogStr Text 
Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Text -> LogStr #

ToFormKey Text 
Instance details

Defined in Web.Internal.FormUrlEncoded

Methods

toFormKey :: Text -> Text #

FromFormKey Text 
Instance details

Defined in Web.Internal.FormUrlEncoded

ToHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

QueryKeyLike Text 
Instance details

Defined in Network.HTTP.Types.QueryLike

QueryValueLike Text 
Instance details

Defined in Network.HTTP.Types.QueryLike

Ixed Text 
Instance details

Defined in Control.Lens.At

AsEmpty Text 
Instance details

Defined in Control.Lens.Empty

Methods

_Empty :: Prism' Text () #

Reversing Text 
Instance details

Defined in Control.Lens.Internal.Iso

Methods

reversing :: Text -> Text #

HasValidSize Text 
Instance details

Defined in Data.Menshen

FromProp Text 
Instance details

Defined in Salak.Prop

Methods

fromProp :: Prop Text #

ToSchema Text 
Instance details

Defined in Data.Swagger.Internal.Schema

ToSchema Object 
Instance details

Defined in Data.Swagger.Internal.Schema

ToParamSchema Text 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Text -> ParamSchema t #

Strict Text Text 
Instance details

Defined in Control.Lens.Iso

Methods

strict :: Iso' Text Text0 #

HasDescription Response Text 
Instance details

Defined in Data.Swagger.Lens

HasTitle Info Text 
Instance details

Defined in Data.Swagger.Lens

Methods

title :: Lens' Info Text #

HasVersion Info Text 
Instance details

Defined in Data.Swagger.Lens

Methods

version :: Lens' Info Text #

HasName License Text 
Instance details

Defined in Data.Swagger.Lens

Methods

name :: Lens' License Text #

HasName Param Text 
Instance details

Defined in Data.Swagger.Lens

Methods

name :: Lens' Param Text #

HasName Tag TagName 
Instance details

Defined in Data.Swagger.Lens

Methods

name :: Lens' Tag TagName #

(a ~ Char, b ~ Char) => Each Text Text a b
each :: Traversal Text Text Char Char
Instance details

Defined in Control.Lens.Each

Methods

each :: Traversal Text Text a b #

Cons Text Text Char Char 
Instance details

Defined in Control.Lens.Cons

Methods

_Cons :: Prism Text Text (Char, Text) (Char, Text) #

Snoc Text Text Char Char 
Instance details

Defined in Control.Lens.Cons

Methods

_Snoc :: Prism Text Text (Text, Char) (Text, Char) #

FromPairs Value (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromPairs :: DList Pair -> Value

v ~ Value => KeyValuePair v (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: String -> v -> DList Pair

HasNamespace Xml (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasPrefix Xml (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

Methods

prefix :: Lens' Xml (Maybe Text) #

HasParamSchema s (ParamSchema t) => HasFormat s (Maybe Format) 
Instance details

Defined in Data.Swagger.Lens

Methods

format :: Lens' s (Maybe Format) #

HasParamSchema s (ParamSchema t) => HasPattern s (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

Methods

pattern :: Lens' s (Maybe Text) #

HasDiscriminator Schema (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasRequired Schema [ParamName] 
Instance details

Defined in Data.Swagger.Lens

HasOperationId Operation (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasSummary Operation (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasEmail Contact (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Info (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Operation (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Param (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Schema (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Header (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription SecurityScheme (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription Tag (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasDescription ExternalDocs (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasTermsOfService Info (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasTitle Schema (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasName Contact (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasName NamedSchema (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

HasName Xml (Maybe Text) 
Instance details

Defined in Data.Swagger.Lens

Methods

name :: Lens' Xml (Maybe Text) #

HasDefinitions Swagger (Definitions Schema) 
Instance details

Defined in Data.Swagger.Lens

HasParameters Swagger (Definitions Param) 
Instance details

Defined in Data.Swagger.Lens

HasResponses Swagger (Definitions Response) 
Instance details

Defined in Data.Swagger.Lens

HasSecurityDefinitions Swagger (Definitions SecurityScheme) 
Instance details

Defined in Data.Swagger.Lens

HasTags Operation (Set TagName) 
Instance details

Defined in Data.Swagger.Lens

HasHeaders Response (InsOrdHashMap HeaderName Header) 
Instance details

Defined in Data.Swagger.Lens

HasProperties Schema (InsOrdHashMap Text (Referenced Schema)) 
Instance details

Defined in Data.Swagger.Lens

MimeRender PlainText Text
fromStrict . TextS.encodeUtf8
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextS.decodeUtf8' . toStrict
Instance details

Defined in Servant.API.ContentTypes

HasFormat (ParamSchema t) (Maybe Format) 
Instance details

Defined in Data.Swagger.Lens

HasPattern (ParamSchema t) (Maybe Pattern) 
Instance details

Defined in Data.Swagger.Lens

type State Text 
Instance details

Defined in Data.Attoparsec.Internal.Types

type State Text = Buffer
type ChunkElem Text 
Instance details

Defined in Data.Attoparsec.Internal.Types

type Item Text 
Instance details

Defined in Data.Text

type Item Text = Char
type Index Text 
Instance details

Defined in Control.Lens.At

type Index Text = Int
type IxValue Text 
Instance details

Defined in Control.Lens.At

pack :: String -> Text #

O(n) Convert a String into a Text. Subject to fusion. Performs replacement on invalid scalar values.

type HasCallStack = ?callStack :: CallStack #

Request a CallStack.

NOTE: The implicit parameter ?callStack :: CallStack is an implementation detail and should not be considered part of the CallStack API, we may decide to change the implementation in the future.

Since: base-4.9.0.0

class Monad m => MonadError e (m :: Type -> Type) | m -> e where #

The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.

Is parameterized over the type of error information and the monad type constructor. It is common to use Either String as the monad type constructor for an error monad in which error descriptions take the form of strings. In that case and many other common cases the resulting monad is already defined as an instance of the MonadError class. You can also define your own error type and/or use a monad type constructor other than Either String or Either IOError. In these cases you will have to explicitly define instances of the MonadError class. (If you are using the deprecated Control.Monad.Error or Control.Monad.Trans.Error, you may also have to define an Error instance.)

Methods

throwError :: e -> m a #

Is used within a monadic computation to begin exception processing.

catchError :: m a -> (e -> m a) -> m a #

A handler function to handle previous errors and return to normal execution. A common idiom is:

do { action1; action2; action3 } `catchError` handler

where the action functions can call throwError. Note that handler and the do-block must have the same return type.

Instances
MonadError () Maybe

Since: mtl-2.2.2

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: () -> Maybe a #

catchError :: Maybe a -> (() -> Maybe a) -> Maybe a #

MonadError IOException IO 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: IOException -> IO a #

catchError :: IO a -> (IOException -> IO a) -> IO a #

MonadError ServantError ClientM 
Instance details

Defined in Servant.Client.Internal.HttpClient

MonadError ServantErr Handler 
Instance details

Defined in Servant.Server.Internal.Handler

(Functor m, MonadError e m) => MonadError e (Free m) 
Instance details

Defined in Control.Monad.Free

Methods

throwError :: e -> Free m a #

catchError :: Free m a -> (e -> Free m a) -> Free m a #

MonadError e m => MonadError e (MaybeT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> MaybeT m a #

catchError :: MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadError e m => MonadError e (ListT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ListT m a #

catchError :: ListT m a -> (e -> ListT m a) -> ListT m a #

MonadError e (Either e) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> Either e a #

catchError :: Either e a -> (e -> Either e a) -> Either e a #

MonadError e m => MonadError e (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

throwError :: e -> ResourceT m a #

catchError :: ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadError e m => MonadError e (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwError :: e -> NoLoggingT m a #

catchError :: NoLoggingT m a -> (e -> NoLoggingT m a) -> NoLoggingT m a #

MonadError e m => MonadError e (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwError :: e -> LoggingT m a #

catchError :: LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #

(Functor f, MonadError e m) => MonadError e (FreeT f m) 
Instance details

Defined in Control.Monad.Trans.Free

Methods

throwError :: e -> FreeT f m a #

catchError :: FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a #

(Monoid w, MonadError e m) => MonadError e (WriterT w m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> WriterT w m a #

catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(Monoid w, MonadError e m) => MonadError e (WriterT w m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> WriterT w m a #

catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

MonadError e m => MonadError e (StateT s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> StateT s m a #

catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadError e m => MonadError e (StateT s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> StateT s m a #

catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadError e m => MonadError e (ReaderT r m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ReaderT r m a #

catchError :: ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadError e m => MonadError e (IdentityT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> IdentityT m a #

catchError :: IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

Monad m => MonadError e (ExceptT e m)

Since: mtl-2.2

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ExceptT e m a #

catchError :: ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a #

(Monad m, Error e) => MonadError e (ErrorT e m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ErrorT e m a #

catchError :: ErrorT e m a -> (e -> ErrorT e m a) -> ErrorT e m a #

MonadError e m => MonadError e (ConduitT i o m) 
Instance details

Defined in Data.Conduit.Internal.Conduit

Methods

throwError :: e -> ConduitT i o m a #

catchError :: ConduitT i o m a -> (e -> ConduitT i o m a) -> ConduitT i o m a #

(Monoid w, MonadError e m) => MonadError e (RWST r w s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> RWST r w s m a #

catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(Monoid w, MonadError e m) => MonadError e (RWST r w s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> RWST r w s m a #

catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

MonadError e m => MonadError e (Pipe l i o u m) 
Instance details

Defined in Data.Conduit.Internal.Pipe

Methods

throwError :: e -> Pipe l i o u m a #

catchError :: Pipe l i o u m a -> (e -> Pipe l i o u m a) -> Pipe l i o u m a #

class MonadIO m => MonadUnliftIO (m :: Type -> Type) where #

Monads which allow their actions to be run in IO.

While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO.

Laws. For any value u returned by askUnliftIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:

  • unliftIO u . return = return
  • unliftIO u (m >>= f) = unliftIO u m >>= unliftIO u . f

The third is a currently nameless law which ensures that the current context is preserved.

  • askUnliftIO >>= (u -> liftIO (unliftIO u m)) = m

If you have a name for this, please submit it in a pull request for great glory.

Since: unliftio-core-0.1.0.0

Minimal complete definition

askUnliftIO | withRunInIO

Methods

askUnliftIO :: m (UnliftIO m) #

Capture the current monadic context, providing the ability to run monadic actions in IO.

See UnliftIO for an explanation of why we need a helper datatype here.

Since: unliftio-core-0.1.0.0

withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b #

Convenience function for capturing the monadic context and running an IO action with a runner function. The runner function is used to run a monadic action m in IO.

Since: unliftio-core-0.1.0.0

Instances
MonadUnliftIO IO 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: IO (UnliftIO IO) #

withRunInIO :: ((forall a. IO a -> IO a) -> IO b) -> IO b #

MonadUnliftIO App Source # 
Instance details

Defined in Yam.Types

Methods

askUnliftIO :: App (UnliftIO App) #

withRunInIO :: ((forall a. App a -> IO a) -> IO b) -> App b #

MonadUnliftIO m => MonadUnliftIO (ResourceT m)

Since: resourcet-1.1.10

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

askUnliftIO :: ResourceT m (UnliftIO (ResourceT m)) #

withRunInIO :: ((forall a. ResourceT m a -> IO a) -> IO b) -> ResourceT m b #

MonadUnliftIO m => MonadUnliftIO (NoLoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

askUnliftIO :: NoLoggingT m (UnliftIO (NoLoggingT m)) #

withRunInIO :: ((forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b #

MonadUnliftIO m => MonadUnliftIO (LoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

askUnliftIO :: LoggingT m (UnliftIO (LoggingT m)) #

withRunInIO :: ((forall a. LoggingT m a -> IO a) -> IO b) -> LoggingT m b #

MonadUnliftIO m => MonadUnliftIO (IdentityT m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: IdentityT m (UnliftIO (IdentityT m)) #

withRunInIO :: ((forall a. IdentityT m a -> IO a) -> IO b) -> IdentityT m b #

MonadUnliftIO m => MonadUnliftIO (ReaderT r m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: ReaderT r m (UnliftIO (ReaderT r m)) #

withRunInIO :: ((forall a. ReaderT r m a -> IO a) -> IO b) -> ReaderT r m b #

data SomeException where #

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Constructors

SomeException :: forall e. Exception e => e -> SomeException 

bracket #

Arguments

:: IO a

computation to run first ("acquire resource")

-> (a -> IO b)

computation to run last ("release resource")

-> (a -> IO c)

computation to run in-between

-> IO c 

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release).

A common example is opening a file:

bracket
  (openFile "filename" ReadMode)
  (hClose)
  (\fileHandle -> do { ... })

The arguments to bracket are in this order so that we can partially apply it, e.g.:

withFile name mode = bracket (openFile name mode) hClose

throw :: Exception e => e -> a #

Throw an exception. Exceptions may be thrown from purely functional code, but may only be caught within the IO monad.

try :: Exception e => IO a -> IO (Either e a) #

Similar to catch, but returns an Either result which is (Right a) if no exception of type e was raised, or (Left ex) if an exception of type e was raised and its value is ex. If any other type of exception is raised than it will be propogated up to the next enclosing exception handler.

 try a = catch (Right `liftM` a) (return . Left)

catch #

Arguments

:: Exception e 
=> IO a

The computation to run

-> (e -> IO a)

Handler to invoke if an exception is raised

-> IO a 

This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example:

  catch (readFile f)
        (\e -> do let err = show (e :: IOException)
                  hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
                  return "")

Note that we have to give a type signature to e, or the program will not typecheck as the type is ambiguous. While it is possible to catch exceptions of any type, see the section "Catching all exceptions" (in Control.Exception) for an explanation of the problems with doing so.

For catching exceptions in pure (non-IO) expressions, see the function evaluate.

Note that due to Haskell's unspecified evaluation order, an expression may throw one of several possible exceptions: consider the expression (error "urk") + (1 `div` 0). Does the expression throw ErrorCall "urk", or DivideByZero?

The answer is "it might throw either"; the choice is non-deterministic. If you are catching any type of exception then you might catch either. If you are calling catch with type IO Int -> (ArithException -> IO Int) -> IO Int then the handler may get run with DivideByZero as an argument, or an ErrorCall "urk" exception may be propogated further up. If you call it again, you might get a the opposite behaviour. This is ok, because catch is an IO computation.

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

module Data.Proxy

type Vault = Vault RealWorld #

A persistent store for values of arbitrary types.

This variant is the simplest and creates keys in the IO monad. See the module Data.Vault.ST if you want to use it with the ST monad instead.

newKey :: IO (Key a) #

Create a new key for use with a vault.

type Key = Key RealWorld #

Keys for the vault.

module Data.Maybe

module Data.Word

encodeUtf8 :: Text -> ByteString #

Encode text using UTF-8 encoding.

decodeUtf8 :: ByteString -> Text #

Decode a ByteString containing UTF-8 encoded text that is known to be valid.

If the input contains any invalid UTF-8 data, an exception will be thrown that cannot be caught in pure code. For more control over the handling of invalid data, use decodeUtf8' or decodeUtf8With.