Skip to content

forth: Move hints to HINTS.md #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions exercises/forth/HINTS.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 4 additions & 8 deletions exercises/forth/src/Forth.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}

module Forth
( ForthError(..)
, ForthState
Expand All @@ -9,8 +10,6 @@ module Forth

import Data.Text (Text)

data ForthState -- TODO: define this data type

data ForthError
= DivisionByZero
| StackUnderflow
Expand All @@ -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