From 639a513ad41d4250fbce41e46b131d2128fbd9ae Mon Sep 17 00:00:00 2001 From: hellerve Date: Thu, 27 Apr 2017 19:29:42 +0200 Subject: [PATCH] initial skeleton --- .gitignore | 1 + LICENSE | 20 ++++++++++++++++++++ README.md | 4 ++++ Setup.hs | 2 ++ bc.cabal | 20 ++++++++++++++++++++ src/BC/Config.hs | 5 +++++ src/BC/Prompt.hs | 24 ++++++++++++++++++++++++ src/Main.hs | 6 ++++++ 8 files changed, 82 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Setup.hs create mode 100644 bc.cabal create mode 100644 src/BC/Config.hs create mode 100644 src/BC/Prompt.hs create mode 100644 src/Main.hs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..91d054b --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2017 Veit Heller + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..124849a --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# bc + +A better basic calculator. Like the original `bc`, but with a better +prompt. diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/bc.cabal b/bc.cabal new file mode 100644 index 0000000..f22b9d6 --- /dev/null +++ b/bc.cabal @@ -0,0 +1,20 @@ +name: bc +version: 0.1.0.0 +synopsis: A better calculator +description: Like bc, but with a better prompt. +license: MIT +license-file: LICENSE +author: Veit Heller +maintainer: veit@veitheller.de +copyright: +category: Language +build-type: Simple +extra-source-files: ChangeLog.md, README.md +cabal-version: >=1.10 + +executable bc + main-is: Main.hs + other-modules: + build-depends: base >=4.9 && <4.10 + hs-source-dirs: src + default-language: Haskell2010 diff --git a/src/BC/Config.hs b/src/BC/Config.hs new file mode 100644 index 0000000..e3524f6 --- /dev/null +++ b/src/BC/Config.hs @@ -0,0 +1,5 @@ +module Bc.Prompt where + +versionStr = "0.1.0.0" + +prompt = "> " diff --git a/src/BC/Prompt.hs b/src/BC/Prompt.hs new file mode 100644 index 0000000..7d3af51 --- /dev/null +++ b/src/BC/Prompt.hs @@ -0,0 +1,24 @@ +module BC.Prompt (startPrompt) where + +import BC.Config + +printHeader :: IO () +printHeader = do + putStrLn "bc (better calculator) version " ++ versionStr + putStrLn "Copyright 2017 Veit Heller" + putStrLn "This is free software with ABSOLUTELY NO WARRANTY.\n" + + +prompt :: IO () +prompt = runInputT settings $ poll prompt + where poll p = do + input <- getInputLine p + case input of + Nothing -> return "" + Just str -> return str + + +startPrompt :: IO () +startPrompt = do + printHeader + prompt diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..d291995 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import BC.Prompt + +main :: IO () +main = startPrompt