From aba67dcfe413cf2a58869be511c1a5032d0dd818 Mon Sep 17 00:00:00 2001 From: rbasso Date: Wed, 21 Sep 2016 00:31:19 +0900 Subject: [PATCH] forth: Move hints to HINTS.md --- exercises/forth/HINTS.md | 12 ++++++++++++ exercises/forth/src/Forth.hs | 12 ++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 exercises/forth/HINTS.md diff --git a/exercises/forth/HINTS.md b/exercises/forth/HINTS.md new file mode 100644 index 000000000..13947360e --- /dev/null +++ b/exercises/forth/HINTS.md @@ -0,0 +1,12 @@ +## Hints + +To complete this exercise, you need to create the data type `ForthState` +and implement the following functions: + +- `empty` returns an empty `ForthState`. +- `evalText` evaluates an input Text, returning the new state. +- `formatStack` returns the current stack as Text, with the element on top +of the stack being the rightmost element in the output + +You will find the type signatures already in place, but it is up to you +to define the functions. diff --git a/exercises/forth/src/Forth.hs b/exercises/forth/src/Forth.hs index d40219dcd..c9860f6c0 100644 --- a/exercises/forth/src/Forth.hs +++ b/exercises/forth/src/Forth.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} + module Forth ( ForthError(..) , ForthState @@ -9,8 +10,6 @@ module Forth import Data.Text (Text) -data ForthState -- TODO: define this data type - data ForthError = DivisionByZero | StackUnderflow @@ -19,13 +18,10 @@ data ForthError deriving (Show, Eq) empty :: ForthState -empty = error "TODO: An empty ForthState" +empty = undefined evalText :: Text -> ForthState -> Either ForthError ForthState -evalText = error "TODO: Evaluate an input Text, returning the new state" +evalText = undefined formatStack :: ForthState -> Text -formatStack = error "TODO: Return the current stack as Text with the element \ - \on top of the stack being the rightmost element in the \ - \output" - +formatStack = undefined