git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
History file works.
3fcc176joneshf
psci/Main.hs+11−2
@@ -26,8 +26,9 @@ import Data.Maybe (mapMaybe)
26import Data.Traversable (traverse)
26import Data.Traversable (traverse)
27
27
28import System.Console.Haskeline
28import System.Console.Haskeline
29−import System.Directory (findExecutable)
29+import System.Directory (createDirectoryIfMissing, findExecutable)
30import System.Exit
30import System.Exit
31+import System.Environment.XDG.BaseDir
31import System.Process
32import System.Process
32
33
33import qualified Language.PureScript as P
34import qualified Language.PureScript as P
@@ -120,11 +121,19 @@ findNodeProcess :: IO (Maybe String)
120findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
121findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
121 where names = ["nodejs", "node"]
122 where names = ["nodejs", "node"]
122
123
124+getHistoryFilename :: IO FilePath
125+getHistoryFilename = do
126+ purescriptConfig <- getUserConfigDir "purescript"
127+ createDirectoryIfMissing True purescriptConfig
128+ getUserConfigFile "purescript" "psci_history"
129+
123main :: IO ()
130main :: IO ()
124main = do
131main = do
125 preludeFilename <- getPreludeFilename
132 preludeFilename <- getPreludeFilename
126 (Right prelude) <- loadModule preludeFilename
133 (Right prelude) <- loadModule preludeFilename
134+ historyFilename <- getHistoryFilename
135+ let settings = defaultSettings {historyFile = Just historyFilename}
127− runInputT (setComplete (completion prelude) defaultSettings) $ do
136+ runInputT (setComplete (completion prelude) settings) $ do
128 outputStrLn " ____ ____ _ _ "
137 outputStrLn " ____ ____ _ _ "
129 outputStrLn "| _ \\ _ _ _ __ ___/ ___| ___ _ __(_)_ __ | |_ "
138 outputStrLn "| _ \\ _ _ _ __ ___/ ___| ___ _ __(_)_ __ | |_ "
130 outputStrLn "| |_) | | | | '__/ _ \\___ \\ / __| '__| | '_ \\| __|"
139 outputStrLn "| |_) | | | | '__/ _ \\___ \\ / __| '__| | '_ \\| __|"
purescript.cabal+2−1
@@ -79,7 +79,8 @@ executable psc
79executable psci
79executable psci
80 build-depends: base >=4 && <5, containers -any, directory -any,
80 build-depends: base >=4 && <5, containers -any, directory -any,
81 mtl -any, parsec -any, haskeline <=0.7.1.1, purescript -any,
81 mtl -any, parsec -any, haskeline <=0.7.1.1, purescript -any,
82− syb -any, transformers -any, utf8-string -any, process -any
82+ syb -any, transformers -any, utf8-string -any, process -any,
83+ xdg-basedir -any
83 main-is: Main.hs
84 main-is: Main.hs
84 buildable: True
85 buildable: True
85 hs-source-dirs: psci
86 hs-source-dirs: psci