Skip to content

Add hello-world exercise #475

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
Feb 20, 2017
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
6 changes: 6 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"repository": "https://github.com/exercism/xhaskell",
"active": true,
"exercises": [
{
"slug": "hello-world",
"difficulty": 1,
"topics": [
]
},
{
"slug": "leap",
"difficulty": 1,
Expand Down
6 changes: 6 additions & 0 deletions exercises/hello-world/HINTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Hints

To complete this exercise, you need to implement the `hello` function.

You will find the type signature for `hello` already in place,
but it is up to you to define the function.
16 changes: 16 additions & 0 deletions exercises/hello-world/examples/success-standard/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: hello-world

dependencies:
- base

library:
exposed-modules: HelloWorld
source-dirs: src

tests:
test:
main: Tests.hs
source-dirs: test
dependencies:
- hello-world
- hspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module HelloWorld (hello) where

hello :: String
hello = "Hello, World!"
Copy link
Contributor

@rbasso rbasso Feb 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry a little that maybe this way the student will be able to pass the tests without finding the source file that needs to be changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. Isn't this (putting the sample in an examples directory) the way other exercises also work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh...sorry! It is perfect. I just confused the files. 👍

19 changes: 19 additions & 0 deletions exercises/hello-world/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: hello-world

dependencies:
- base

library:
exposed-modules: HelloWorld
source-dirs: src
dependencies:
# - foo # List here the packages you
# - bar # want to use in your solution.

tests:
test:
main: Tests.hs
source-dirs: test
dependencies:
- hello-world
- hspec
4 changes: 4 additions & 0 deletions exercises/hello-world/src/HelloWorld.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module HelloWorld (hello) where

hello :: String
hello = error "You need to implement this function."
1 change: 1 addition & 0 deletions exercises/hello-world/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver: lts-7.16
13 changes: 13 additions & 0 deletions exercises/hello-world/test/Tests.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import HelloWorld (hello)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs

specs :: Spec
specs = describe "hello-world" $

it "hello" $
hello `shouldBe` "Hello, World!"