salak-0.3.5.3: Configuration (re)Loader and Parser.

Copyright2019 Daniel YU
LicenseMIT
Maintainerleptonyu@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Salak

Contents

Description

Configuration (re)Loader and Parser.

Synopsis

How to use this library

| This library defines a universal procedure to load configurations and parse properties, also supports reload configurations.

We can load configurations from command lines, environment, configuration files such as yaml or toml etc., and we may want to have our own strategies to load configurations from multiply sources and overwrite properties by orders of these sources.

PropConfig defines a common loading strategy:

1. loadCommandLine
2. loadEnvironment
3. loadConfFiles
4. load file from folder `application.dir` if defined
5. load file from current folder if enabled
6. load file from home folder if enabled
7. file extension matching, support yaml or toml or any other loader.

Load earlier has higher priority. Priorities cannot be changed.

After loading configurations, we can use require to parse properties. For example:

a :: Bool              <- require "bool.key"
b :: Maybe Int         <- require "int.optional.key"
c :: Either String Int <- require "int.error.key"
d :: IO Int            <- require "int.reloadable.key"

Salak supports parse IO values, which actually wrap a MVar variable and can be reseted by reloading configurations. Normal value will not be affected by reloading configurations.

GHCi play

>>> :set -XFlexibleInstances -XMultiParamTypeClasses -XOverloadedStrings
>>> import Salak
>>> import Data.Default
>>> import Data.Text(Text)
>>> data Config = Config { name :: Text, dir  :: Maybe Text, ext  :: Int} deriving (Eq, Show)
>>> instance FromProp m Config where fromProp = Config <$> "user" <*> "dir" <*> "ext" .?= 1
>>> runSalak def (require "") :: IO Config
Config {name = "daniel", dir = Nothing, ext = 1}

Salak Main Functions

runSalak :: (MonadCatch m, MonadIO m) => PropConfig -> RunSalakT m a -> m a Source #

Run salak, load strategy refer to loadSalak

runSalakWith :: (MonadCatch m, MonadIO m, HasLoad file) => String -> file -> RunSalakT m a -> m a Source #

Run salak, load strategy refer to loadSalakWith

loadAndRunSalak :: (MonadThrow m, MonadIO m) => LoadSalakT m () -> RunSalakT m a -> m a Source #

Standard salak functions, by load and run with RunSalakT.

loadAndRunSalak' :: (MonadThrow m, MonadIO m) => LoadSalakT m () -> (SourcePack -> m a) -> m a Source #

Standard salak functions, by load and with a SourcePack instance. Users should use SourcePack to create custom MonadSalak instances, then you get will an instance of MonadSalak.

data PropConfig Source #

Prop load configuration

Constructors

PropConfig 

Fields

Instances
Default PropConfig Source # 
Instance details

Defined in Salak

Methods

def :: PropConfig #

Parsing Properties Function

class Monad m => MonadSalak m where Source #

Core type class of salak, which provide function to parse properties.

Minimal complete definition

askSourcePack

Methods

askSourcePack :: m SourcePack Source #

Monad has the ability to get a SourcePack instance.

askReload :: m (IO ReloadResult) Source #

Get reload action which used for reload profiles

setLogF :: MonadIO m => (CallStack -> Text -> IO ()) -> m () Source #

logSalak :: (HasCallStack, MonadIO m) => Text -> m () Source #

require :: (MonadThrow m, MonadIO m, FromProp m a) => Text -> m a Source #

Parse properties using FromProp. For example:

a :: Bool              <- require "bool.key"
b :: Maybe Int         <- require "int.optional.key"
c :: Either String Int <- require "int.error.key"
d :: IO Int            <- require "int.reloadable.key"

require supports parse IO values, which actually wrap a MVar variable and can be reseted by reloading configurations. Normal value will not be affected by reloading configurations.

data RunSalakT m a Source #

Standard MonadSalak instance.

Instances
MonadTrans RunSalakT Source # 
Instance details

Defined in Salak.Internal

Methods

lift :: Monad m => m a -> RunSalakT m a #

Monad m => MonadReader SourcePack (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

ask :: RunSalakT m SourcePack #

local :: (SourcePack -> SourcePack) -> RunSalakT m a -> RunSalakT m a #

reader :: (SourcePack -> a) -> RunSalakT m a #

Monad m => Monad (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

(>>=) :: RunSalakT m a -> (a -> RunSalakT m b) -> RunSalakT m b #

(>>) :: RunSalakT m a -> RunSalakT m b -> RunSalakT m b #

return :: a -> RunSalakT m a #

fail :: String -> RunSalakT m a #

Functor m => Functor (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

fmap :: (a -> b) -> RunSalakT m a -> RunSalakT m b #

(<$) :: a -> RunSalakT m b -> RunSalakT m a #

Applicative m => Applicative (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

pure :: a -> RunSalakT m a #

(<*>) :: RunSalakT m (a -> b) -> RunSalakT m a -> RunSalakT m b #

liftA2 :: (a -> b -> c) -> RunSalakT m a -> RunSalakT m b -> RunSalakT m c #

(*>) :: RunSalakT m a -> RunSalakT m b -> RunSalakT m b #

(<*) :: RunSalakT m a -> RunSalakT m b -> RunSalakT m a #

MonadIO m => MonadIO (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

liftIO :: IO a -> RunSalakT m a #

MonadThrow m => MonadThrow (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

throwM :: Exception e => e -> RunSalakT m a #

MonadCatch m => MonadCatch (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

catch :: Exception e => RunSalakT m a -> (e -> RunSalakT m a) -> RunSalakT m a #

(MonadThrow m, MonadUnliftIO m) => MonadUnliftIO (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

askUnliftIO :: RunSalakT m (UnliftIO (RunSalakT m)) #

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

MonadIO m => MonadSalak (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

type RunSalak = RunSalakT IO Source #

Simple IO Monad

Operators

class PropOp f a where Source #

Prop operators.

Suppose we have the following definition:

data Config = Config
  { enabled :: Bool
  , level   :: IO LogLevel
  }

Minimal complete definition

(.?=)

Methods

(.?=) :: f a -> a -> f a infixl 5 Source #

Parse or default value

instance MonadThrow m => FromProp m Config where
  fromProp = Config
    <$> "enabled" .?= True
    <*> "level"   .?= (return LevelInfo)

IO value will work right.

(.?:) :: Default b => f a -> (b -> a) -> f a infixl 5 Source #

Parse or auto extract default value from a Default value

instance Default Config where
  def = Config True (return LevelInfo)
instance MonadThrow m => FromProp m Config where
  fromProp = Config
    <$> "enabled" .?: enabled
    <$> "level"   .?: level
Instances
Alternative f => PropOp f a Source #

Support for setting default normal value.

Instance details

Defined in Salak.Internal.Prop

Methods

(.?=) :: f a -> a -> f a Source #

(.?:) :: Default b => f a -> (b -> a) -> f a Source #

(MonadIO m, FromProp IO a) => PropOp (Prop m) (IO a) Source #

Support for setting default IO value.

Instance details

Defined in Salak.Internal.Prop

Methods

(.?=) :: Prop m (IO a) -> IO a -> Prop m (IO a) Source #

(.?:) :: Default b => Prop m (IO a) -> (b -> IO a) -> Prop m (IO a) Source #

class FromProp m a where Source #

Type class used to parse properties.

Minimal complete definition

Nothing

Methods

fromProp :: MonadIO m => Prop m a Source #

Parse properties from Value.

fromProp :: (Generic a, GFromProp m (Rep a), MonadIO m) => Prop m a Source #

Parse properties from Value.

Instances
FromProp m CDouble Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CFloat Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CULLong Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CLLong Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CULong Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CLong Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m CLong Source #

FromProp m CUInt Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m CUInt Source #

FromProp m CInt Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m CInt Source #

FromProp m CUShort Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CShort Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m CBool Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m CBool Source #

FromProp m DiffTime Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m NominalDiffTime Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Word64 Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Word32 Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Word16 Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Word8 Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Word8 Source #

FromProp m Word Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Word Source #

FromProp m Int64 Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Int64 Source #

FromProp m Int32 Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Int32 Source #

FromProp m Int16 Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Int16 Source #

FromProp m Int8 Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Int8 Source #

FromProp m Int Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Int Source #

FromProp m Integer Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Double Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Float Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Float Source #

FromProp m Scientific Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m String Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m ByteString Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m ByteString Source # 
Instance details

Defined in Salak.Internal.Prop

FromProp m Text Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Text Source #

FromProp m Text Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Text Source #

FromProp m Bool Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m Bool Source #

(HasResolution a, Monad m) => FromProp m (Fixed a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Fixed a) Source #

FromProp m a => FromProp m (Option a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Option a) Source #

FromProp m a => FromProp m (Product a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Product a) Source #

FromProp m a => FromProp m (Sum a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Sum a) Source #

FromProp m a => FromProp m (Dual a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Dual a) Source #

FromProp m a => FromProp m (Last a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Last a) Source #

FromProp m a => FromProp m (First a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (First a) Source #

FromProp m a => FromProp m (Max a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Max a) Source #

FromProp m a => FromProp m (Min a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Min a) Source #

FromProp m a => FromProp m (Identity a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Identity a) Source #

(MonadIO m, FromProp IO a, FromProp m a) => FromProp m (IO a) Source #

Supports for parsing IO value.

Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (IO a) Source #

(IsString s, FromProp m a) => FromProp m [(s, a)] Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m [(s, a)] Source #

FromProp m a => FromProp m [a] Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m [a] Source #

FromProp m a => FromProp m (Maybe a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Maybe a) Source #

(FromProp m a, FromProp m b) => FromProp m (a, b) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b) Source #

(Eq s, Ord s, IsString s, FromProp m a) => FromProp m (Map s a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Map s a) Source #

(Eq s, Hashable s, IsString s, FromProp m a) => FromProp m (HashMap s a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (HashMap s a) Source #

FromProp m a => FromProp m (Either String a) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (Either String a) Source #

(FromProp m a, FromProp m b, FromProp m c) => FromProp m (a, b, c) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d) => FromProp m (a, b, c, d) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d, FromProp m e) => FromProp m (a, b, c, d, e) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d, e) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d, FromProp m e, FromProp m f) => FromProp m (a, b, c, d, e, f) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d, e, f) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d, FromProp m e, FromProp m f, FromProp m g) => FromProp m (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d, e, f, g) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d, FromProp m e, FromProp m f, FromProp m g, FromProp m h) => FromProp m (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d, e, f, g, h) Source #

(FromProp m a, FromProp m b, FromProp m c, FromProp m d, FromProp m e, FromProp m f, FromProp m g, FromProp m h, FromProp m i) => FromProp m (a, b, c, d, e, f, g, h, i) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fromProp :: Prop m (a, b, c, d, e, f, g, h, i) Source #

data Prop m a Source #

Property parser, used to parse property from Value

Instances
MonadTrans Prop Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

lift :: Monad m => m a -> Prop m a #

Monad m => MonadReader SourcePack (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

ask :: Prop m SourcePack #

local :: (SourcePack -> SourcePack) -> Prop m a -> Prop m a #

reader :: (SourcePack -> a) -> Prop m a #

Monad m => MonadError SomeException (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

throwError :: SomeException -> Prop m a #

catchError :: Prop m a -> (SomeException -> Prop m a) -> Prop m a #

Monad m => Monad (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

(>>=) :: Prop m a -> (a -> Prop m b) -> Prop m b #

(>>) :: Prop m a -> Prop m b -> Prop m b #

return :: a -> Prop m a #

fail :: String -> Prop m a #

Functor m => Functor (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fmap :: (a -> b) -> Prop m a -> Prop m b #

(<$) :: a -> Prop m b -> Prop m a #

Monad m => MonadFail (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

fail :: String -> Prop m a #

Monad m => Applicative (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

pure :: a -> Prop m a #

(<*>) :: Prop m (a -> b) -> Prop m a -> Prop m b #

liftA2 :: (a -> b -> c) -> Prop m a -> Prop m b -> Prop m c #

(*>) :: Prop m a -> Prop m b -> Prop m b #

(<*) :: Prop m a -> Prop m b -> Prop m a #

MonadIO m => MonadIO (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

liftIO :: IO a -> Prop m a #

Monad m => Alternative (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

empty :: Prop m a #

(<|>) :: Prop m a -> Prop m a -> Prop m a #

some :: Prop m a -> Prop m [a] #

many :: Prop m a -> Prop m [a] #

Monad m => MonadThrow (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

throwM :: Exception e => e -> Prop m a #

Monad m => MonadCatch (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

catch :: Exception e => Prop m a -> (e -> Prop m a) -> Prop m a #

(MonadIO m, FromProp IO a) => PropOp (Prop m) (IO a) Source #

Support for setting default IO value.

Instance details

Defined in Salak.Internal.Prop

Methods

(.?=) :: Prop m (IO a) -> IO a -> Prop m (IO a) Source #

(.?:) :: Default b => Prop m (IO a) -> (b -> IO a) -> Prop m (IO a) Source #

(MonadIO m, FromProp m a) => IsString (Prop m a) Source #

Automatic convert literal string into an instance of Prop m a.

Instance details

Defined in Salak.Internal.Prop

Methods

fromString :: String -> Prop m a #

readPrimitive :: MonadIO m => (Value -> Either String a) -> Prop m a Source #

Parse primitive value from Value

readEnum :: MonadIO m => (Text -> Either String a) -> Prop m a Source #

Parse enum value from Text

type Salak = SourcePack Source #

Type synonyms of SourcePack

Writable Value

data Writable a Source #

Writable data structure. Writable is designed for working with IO value pased by salak. It provide a way to override IO value provided by salak, can be used in the application which need to change values of some configurations by overriding it directly. For example, logger function can use a log level property to control which level of logs should be printed. By using Writeable value, we can change the property directly.

toWritable :: IO a -> IO (Writable a) Source #

Convert a IO value to Writable value.

getWritable :: Writable a -> IO a Source #

Get value.

setWritable :: Maybe a -> Writable a -> IO () Source #

Set or remove override value.

Load Functions

Monad for Loader

data LoadSalakT m a Source #

Configuration Loader Monad, used for load properties from sources. Custom loaders using loadTrie

Instances
MonadTrans LoadSalakT Source # 
Instance details

Defined in Salak.Internal

Methods

lift :: Monad m => m a -> LoadSalakT m a #

Monad m => Monad (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

(>>=) :: LoadSalakT m a -> (a -> LoadSalakT m b) -> LoadSalakT m b #

(>>) :: LoadSalakT m a -> LoadSalakT m b -> LoadSalakT m b #

return :: a -> LoadSalakT m a #

fail :: String -> LoadSalakT m a #

Functor m => Functor (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

fmap :: (a -> b) -> LoadSalakT m a -> LoadSalakT m b #

(<$) :: a -> LoadSalakT m b -> LoadSalakT m a #

Monad m => Applicative (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

pure :: a -> LoadSalakT m a #

(<*>) :: LoadSalakT m (a -> b) -> LoadSalakT m a -> LoadSalakT m b #

liftA2 :: (a -> b -> c) -> LoadSalakT m a -> LoadSalakT m b -> LoadSalakT m c #

(*>) :: LoadSalakT m a -> LoadSalakT m b -> LoadSalakT m b #

(<*) :: LoadSalakT m a -> LoadSalakT m b -> LoadSalakT m a #

MonadIO m => MonadIO (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

liftIO :: IO a -> LoadSalakT m a #

MonadThrow m => MonadThrow (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

throwM :: Exception e => e -> LoadSalakT m a #

MonadCatch m => MonadCatch (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

catch :: Exception e => LoadSalakT m a -> (e -> LoadSalakT m a) -> LoadSalakT m a #

(MonadThrow m, MonadUnliftIO m) => MonadUnliftIO (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

askUnliftIO :: LoadSalakT m (UnliftIO (LoadSalakT m)) #

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

MonadIO m => MonadSalak (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

type LoadSalak = LoadSalakT IO Source #

Simple IO Monad

Basic loaders

loadCommandLine :: (MonadThrow m, MonadIO m) => ParseCommandLine -> LoadSalakT m () Source #

Default way to parse command line arguments

type ParseCommandLine = [String] -> IO [(Text, Text)] Source #

Convert arguments to properties

defaultParseCommandLine :: ParseCommandLine Source #

Default way to parse command line arguments

loadEnv :: (MonadThrow m, MonadIO m) => LoadSalakT m () Source #

Load environment variables into Source

loadMock :: (MonadThrow m, MonadIO m) => [(Text, Text)] -> LoadSalakT m () Source #

Load mock variables into Source

loadSalak :: (MonadThrow m, MonadIO m) => PropConfig -> LoadSalakT m () Source #

Default load salak. All these configuration sources has orders, from highest priority to lowest priority:

1. loadCommandLine
2. loadEnvironment
3. loadConfFiles
4. load file from folder `salak.conf.dir` if defined
5. load file from current folder if enabled
6. load file from home folder if enabled
7. file extension matching, support yaml or toml or any other loader.

loadSalakWith :: (MonadThrow m, MonadIO m, HasLoad file) => file -> String -> LoadSalakT m () Source #

File Loaders

type ExtLoad = (String, FilePath -> LoadSalak ()) Source #

Load file by extension

loadByExt :: HasLoad a => a -> FilePath -> LoadSalak () Source #

Load files with specified format, yaml or toml, etc.

class HasLoad a where Source #

Methods

loaders :: a -> [ExtLoad] Source #

Instances
(HasLoad a, HasLoad b) => HasLoad (a :|: b) Source # 
Instance details

Defined in Salak

Methods

loaders :: (a :|: b) -> [ExtLoad] Source #

data a :|: b infixr 3 Source #

Constructors

a :|: b infixr 3 
Instances
(HasLoad a, HasLoad b) => HasLoad (a :|: b) Source # 
Instance details

Defined in Salak

Methods

loaders :: (a :|: b) -> [ExtLoad] Source #

Reload Functions

data ReloadResult Source #

Reload result, show erros or changes.

Constructors

ReloadResult 

Fields

  • hasError :: !Bool

    If reload process has errors.

  • msgs :: ![String]

    If hasError then this show error messages, else this show change logs.

Instances
Show ReloadResult Source # 
Instance details

Defined in Salak.Internal.Source

Reexport

class MonadThrow m => MonadCatch (m :: Type -> Type) #

A class for monads which allow exceptions to be caught, in particular exceptions which were thrown by throwM.

Instances should obey the following law:

catch (throwM e) f = f e

Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannot be used by those monads to properly implement a function such as finally. For more information, see MonadMask.

Minimal complete definition

catch

Instances
MonadCatch IO 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IO a -> (e -> IO a) -> IO a #

MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => STM a -> (e -> STM a) -> STM a #

e ~ SomeException => MonadCatch (Either e)

Since: exceptions-0.8.3

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => Either e a -> (e0 -> Either e a) -> Either e a #

MonadCatch m => MonadCatch (MaybeT m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadCatch m => MonadCatch (ListT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ListT m a -> (e -> ListT m a) -> ListT m a #

Monad m => MonadCatch (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

catch :: Exception e => Prop m a -> (e -> Prop m a) -> Prop m a #

MonadCatch m => MonadCatch (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

catch :: Exception e => RunSalakT m a -> (e -> RunSalakT m a) -> RunSalakT m a #

MonadCatch m => MonadCatch (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

catch :: Exception e => LoadSalakT m a -> (e -> LoadSalakT m a) -> LoadSalakT m a #

MonadCatch m => MonadCatch (ExceptT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ExceptT e m a -> (e0 -> ExceptT e m a) -> ExceptT e m a #

MonadCatch m => MonadCatch (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

(Error e, MonadCatch m) => MonadCatch (ErrorT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ErrorT e m a -> (e0 -> ErrorT e m a) -> ErrorT e m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

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

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

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

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

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

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

class Monad m => MonadThrow (m :: Type -> Type) #

A class for monads in which exceptions may be thrown.

Instances should obey the following law:

throwM e >> x = throwM e

In other words, throwing an exception short-circuits the rest of the monadic computation.

Minimal complete definition

throwM

Instances
MonadThrow [] 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> [a] #

MonadThrow Maybe 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> Maybe a #

MonadThrow IO 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> IO a #

MonadThrow Q 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> Q a #

MonadThrow STM 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> STM a #

e ~ SomeException => MonadThrow (Either e) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> Either e a #

MonadThrow (ST s) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ST s a #

MonadThrow m => MonadThrow (MaybeT m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> MaybeT m a #

MonadThrow m => MonadThrow (ListT m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ListT m a #

Monad m => MonadThrow (Prop m) Source # 
Instance details

Defined in Salak.Internal.Prop

Methods

throwM :: Exception e => e -> Prop m a #

MonadThrow m => MonadThrow (RunSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

throwM :: Exception e => e -> RunSalakT m a #

MonadThrow m => MonadThrow (LoadSalakT m) Source # 
Instance details

Defined in Salak.Internal

Methods

throwM :: Exception e => e -> LoadSalakT m a #

MonadThrow m => MonadThrow (ExceptT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> ExceptT e m a #

MonadThrow m => MonadThrow (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> IdentityT m a #

(Error e, MonadThrow m) => MonadThrow (ErrorT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> ErrorT e m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> StateT s m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> StateT s m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> WriterT w m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> WriterT w m a #

MonadThrow m => MonadThrow (ContT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ContT r m a #

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

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ReaderT r m a #

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

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> RWST r w s m a #

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

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> RWST r w s m a #