Compare commits

...

2 Commits

Author SHA1 Message Date
Ivy 24ed67ae71 Added install instructions 2021-01-29 00:24:05 +01:00
Ivy 2e3f9d321e I Now uses haskeline to improve repl 2021-01-29 00:19:19 +01:00
4 changed files with 30 additions and 22 deletions

View File

@ -10,4 +10,15 @@ cherry> (+ 2 3 4)
9
```
## Instructions
```
# apt install haskell-stack
$ git clone https://git.fai.su/Suguivy/cherry-lisp
$ cd cherry-lisp
# stack upgrade
$ stack build
$ stack install
$ cherry
```
Work in progress...

View File

@ -28,4 +28,5 @@ executable cherry
build-depends: base >= 4.7 && < 5,
containers,
parsec
parsec,
haskeline

View File

@ -3,24 +3,22 @@ module Main where
import Evaluator
import ExprParser
import Text.Parsec.Error
import Data.Either
import System.IO
import Control.Monad
import Data.Maybe
import System.Console.Haskeline
main :: IO ()
main = do
putStrLn ""
putLogo
putStrLn ""
cycle
where cycle = do
putPrompt
hFlush stdout
s <- getLine
let r = readEval s
putStrLn $ case r of
(Right res) -> res
(Left err) -> show err
cycle
putStrLn logo
runInputT defaultSettings loop
where loop = do
line <- getInputLine "cherry> "
unless (isNothing line) $ do
let r = readEval $ fromJust line
outputStrLn $ case r of
Right res -> res
Left err -> show err
loop
readEval :: String -> Either ParseError String
readEval s = do
@ -28,8 +26,5 @@ readEval s = do
let result = eval expr
return $ show result
putLogo :: IO ()
putLogo = putStr . concat $ map (++"\n") [" /\\", " | \\", " @ @"]
putPrompt :: IO ()
putPrompt = putStr "chery> "
logo :: String
logo = unlines [""," /\\", " | \\", " @ @",""]

View File

@ -34,7 +34,8 @@ packages:
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
extra-deps:
#- readline-1.0.3.0
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a