From 219f419bae6d35d34391ac4bfcf05574c28bf9f4 Mon Sep 17 00:00:00 2001 From: Nilstrieb Date: Wed, 7 Apr 2021 17:06:36 +0200 Subject: [PATCH] nothing working for now --- bfi-haskell/app/Main.hs | 2 +- bfi-haskell/src/Lib.hs | 29 ++++++++++++++++++++++++++--- bfi-haskell/test/Spec.hs | 2 -- 3 files changed, 27 insertions(+), 6 deletions(-) delete mode 100644 bfi-haskell/test/Spec.hs diff --git a/bfi-haskell/app/Main.hs b/bfi-haskell/app/Main.hs index de1c1ab..e8b7ed8 100644 --- a/bfi-haskell/app/Main.hs +++ b/bfi-haskell/app/Main.hs @@ -3,4 +3,4 @@ module Main where import Lib main :: IO () -main = someFunc +main = main diff --git a/bfi-haskell/src/Lib.hs b/bfi-haskell/src/Lib.hs index 2cd4f41..715be5b 100644 --- a/bfi-haskell/src/Lib.hs +++ b/bfi-haskell/src/Lib.hs @@ -1,6 +1,29 @@ module Lib - ( someFunc + ( main ) where -someFunc :: IO () -someFunc = putStrLn "someFunc" \ No newline at end of file +import System.Environment +import Data.List +import System.IO + +main :: IO () +main = do + args <- getArgs + program <- readFile $ head args + interpret program + +data Memory = Memory [Int] Int [Int] + +interpret :: String -> IO () +interpret [] = IO() +interpret [x:xs] = do + eval x + interpret xs + + +eval :: String -> Memory -> IO Memory +eval s (Memory sx x xs) +| x == "+" = Memory sx (x + 1) xs +| x == "-" = Memory sx (x - 1) xs +otherwise = undefined +eval _ = undefined \ No newline at end of file diff --git a/bfi-haskell/test/Spec.hs b/bfi-haskell/test/Spec.hs deleted file mode 100644 index cd4753f..0000000 --- a/bfi-haskell/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = putStrLn "Test suite not yet implemented"