settings-0.1.0.1: Runtime-editable program settings.

Safe HaskellNone
LanguageHaskell2010

Data.Settings.Persist

Synopsis

Documentation

mkSaveSettings :: (TimeUnit t, ToJSON s) => t -> FilePath -> IO (s -> IO ()) Source

Prepare a save action which writes settings into a JSON file. This action defers the work to a separate dedicated thread, and ensures the file isn't saved more than once within the given time interval.

The action is non-blocking but there is a chance a save is missed if saves are triggered

You can call the returned action from your UI thread as a reaction to a settings change, without worrying about delay or IO load.

loadSettings :: FromJSON s => FilePath -> IO (Either (Bool, String) s) Source

Try to load settings from a file.

If an error occurs, Left a pair is returned. The boolean indicates whether reading the file failed (False) or parsing the content failed (True). The string is an error description.

If the operation succeeds, Right the loaded settings are returned.