Karya, built on Sun Nov 26 01:04:37 PST 2017 (patch 0a920b2bde70c0cbac8ee09d158064798b61bbe5)

Safe HaskellNone




Functions to save and restore state to and from files.

The naming convention is that load and save functions either load the given file, replace the state with it, and set the SaveFile, or save the current state and set the SaveFile. read and write functions are lower level and either read the file and return the state, or write the given state, without messing with the SaveFile.



save :: Cmd.CmdT IO () Source #

Save to the current Cmd.state_save_file, or create a new git repo if there is none.

load :: FilePath -> Cmd.CmdT IO () Source #

Like read, but replace the current state and set Cmd.state_save_file.

read :: FilePath -> Cmd.CmdT IO (Ui.State, StateSaveFile) Source #

Try to guess whether the given path is a git save or state save. If it's a directory, look inside for a .git or .state save.

load_template :: FilePath -> Cmd.CmdT IO () Source #

Like load, but don't set SaveFile, so you can't overwrite the loaded file when you save.

infer_save_type :: FilePath -> IO (Either Text Cmd.SaveFile) Source #

Given a path, which is either a file or a directory, try to figure out what to load. Saves can be either a plain saved state, or a directory containing either a git repo save.git, or a state save.state. If both are present, the git repo is preferred.


save_state_as :: FilePath -> Cmd.CmdT IO () Source #

Save the state to the given file and set Cmd.state_save_file.

The directory of the filename will become the project directory, so things like the saved REPL history and the ly subdirectory will go there.

read_state :: FilePath -> Cmd.CmdT IO (Ui.State, StateSaveFile) Source #


state_path_for_repo :: Repo -> FilePath Source #

Get a state save path based on a repo path. This is for saving a backup state, or when switching from SaveRepo to SaveState.

infer_state_path :: Id.Namespace -> Cmd.State -> FilePath Source #

Figure out a path for a save state based on the namespace.


save_git :: Cmd.CmdT IO () Source #

Save a SavePoint to the git repo in Cmd.state_save_file, or start a new one. Set the Cmd.state_save_file to the repo, so I'll keep saving to that repo.

save_git_as Source #


:: Repo

Save to this repo, or create it. maintain_history will start checkpointing to it. .git is appended if it doesn't already have that suffix.

-> Cmd.CmdT IO () 

revert :: Maybe String -> Cmd.CmdT IO () Source #

Revert to given save point, or the last one.



save_views :: Cmd.State -> Ui.State -> IO () Source #

Git repos don't checkpoint views, but because I'm accustomed to them checkpointing everything else I expect the views to always be saved.

So call this when quitting or switching away from a save file to save the views.

They could theoretically checkpoint view changes, but it would be complicated (they mostly come from the GUI, not diff) and inefficient (scrolling emits tons of them).