combinator-interactive 0.1.1 → 0.1.2
raw patch · 2 files changed
+19/−17 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- combinator-interactive.cabal +1/−1
- main.hs +18/−16
combinator-interactive.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/ name: combinator-interactive -version: 0.1.1 +version: 0.1.2 synopsis: SKI Combinator interpreter description: homepage: https://github.com/fumieval/combinator-interactive
main.hs view
@@ -12,9 +12,10 @@ import System.IO.Unsafe import System.IO.Error hiding (try) import Data.Monoid -import qualified Data.ByteString.Lazy as BS +import qualified Data.ByteString as BS import System.Directory import qualified Data.Serialize as S +import System.Environment import "combinator-interactive" Data.Combinator @@ -27,9 +28,9 @@ | Quit parseCommand :: Parser Command -parseCommand = try define <|> run <|> load <|> del <|> quit <|> eval where +parseCommand = try define <|> run <|> load <|> save <|> del <|> quit <|> eval where run = do - string ":run" + symbol ":run" Run <$> ccParser eval = do Eval <$> ccParser @@ -38,19 +39,19 @@ symbol "=" Define var <$> ccParser load = do - string ":load" + symbol ":load" path <- stringLiteral name <- option "main" $ variable return $ Load path name save = do - string ":load" + symbol ":save" path <- stringLiteral expr <- ccParser return $ Save path expr del = do - string ":del" + symbol ":del" Del <$> variable - quit = Quit <$ string ":quit" + quit = Quit <$ symbol ":quit" consE x xs = S :$ (S :$ I :$ (K :$ x)) :$ (K :$ xs) @@ -132,7 +133,7 @@ dump = do path <- lift $ (++"/.lazyi-env") <$> getHomeDirectory env <- get - lift $ BS.writeFile path $ S.encodeLazy env + lift $ BS.writeFile path $ S.encode env defaultEnv = Env Map.empty @@ -144,11 +145,12 @@ put (Env m) = S.put m get = Env <$> S.get -main = do - path <- (++"/.lazyi-env") <$> getHomeDirectory - b <- doesFileExist path - let w = hPutStrLn stderr "Warning: .lazyi-env is broken." >> return defaultEnv - env <- if b - then S.decodeLazy <$> BS.readFile path >>= either (const w) return - else return defaultEnv - evalStateT prompt env+main = getArgs >>= \r -> case r of + [] -> do + path <- (++"/.lazyi-env") <$> getHomeDirectory + b <- doesFileExist path + let w = hPutStrLn stderr "Warning: .lazyi-env is broken." >> return defaultEnv + env <- if b + then S.decode <$> BS.readFile path >>= either (const w) return + else return defaultEnv + evalStateT prompt env