From 40b4d55cda92ac36da2f0b4bb8206eb59fb60f06 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 6 Oct 2021 13:17:22 -0300 Subject: [PATCH] Exercism: Hello world --- haskell/hello-world/.exercism/config.json | 28 ++++++ haskell/hello-world/.exercism/metadata.json | 1 + haskell/hello-world/HELP.md | 88 +++++++++++++++++++ haskell/hello-world/README.md | 45 ++++++++++ .../examples/success-standard/package.yaml | 16 ++++ haskell/hello-world/hello-world.cabal | 34 +++++++ haskell/hello-world/package.yaml | 21 +++++ haskell/hello-world/src/HelloWorld.hs | 4 + haskell/hello-world/stack.yaml | 1 + haskell/hello-world/stack.yaml.lock | 12 +++ haskell/hello-world/test/Tests.hs | 13 +++ 11 files changed, 263 insertions(+) create mode 100644 haskell/hello-world/.exercism/config.json create mode 100644 haskell/hello-world/.exercism/metadata.json create mode 100644 haskell/hello-world/HELP.md create mode 100644 haskell/hello-world/README.md create mode 100644 haskell/hello-world/examples/success-standard/package.yaml create mode 100644 haskell/hello-world/hello-world.cabal create mode 100644 haskell/hello-world/package.yaml create mode 100644 haskell/hello-world/src/HelloWorld.hs create mode 100644 haskell/hello-world/stack.yaml create mode 100644 haskell/hello-world/stack.yaml.lock create mode 100644 haskell/hello-world/test/Tests.hs diff --git a/haskell/hello-world/.exercism/config.json b/haskell/hello-world/.exercism/config.json new file mode 100644 index 0000000..f5dd671 --- /dev/null +++ b/haskell/hello-world/.exercism/config.json @@ -0,0 +1,28 @@ +{ + "blurb": "The classical introductory exercise. Just say \"Hello, World!\"", + "authors": [ + "ErikSchierboom" + ], + "contributors": [ + "iHiD", + "kytrinyx", + "petertseng", + "ppartarr", + "rbasso", + "sshine", + "tejasbubane" + ], + "files": { + "solution": [ + "src/HelloWorld.hs" + ], + "test": [ + "test/Tests.hs" + ], + "example": [ + "examples/success-standard/src/HelloWorld.hs" + ] + }, + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "http://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/haskell/hello-world/.exercism/metadata.json b/haskell/hello-world/.exercism/metadata.json new file mode 100644 index 0000000..cff2b4f --- /dev/null +++ b/haskell/hello-world/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"haskell","exercise":"hello-world","id":"dc1da3a0365842e698c8f3f230d2c553","url":"https://exercism.org/tracks/haskell/exercises/hello-world","handle":"JBiason","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/haskell/hello-world/HELP.md b/haskell/hello-world/HELP.md new file mode 100644 index 0000000..b81145a --- /dev/null +++ b/haskell/hello-world/HELP.md @@ -0,0 +1,88 @@ +# Help + +## Running the tests + +To run the test suite, execute the following command: + +```bash +tacktack test +``` + +#### If you get an error message like this... + +``` +No .cabal file found in directory +``` + +or + +``` +RedownloadInvalidResponse Request { +... +} + "/home/username/.stack/build-plan/lts-xx.yy.yaml" (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, +``` + +You are probably running an old stack version and need +to upgrade it. Try running: + +```bash +stack upgrade +``` + +Or see other options for upgrading at [Stack documentation](https://docs.haskellstack.org/en/stable/install_and_upgrade/#upgrade). + +#### Otherwise, if you get an error message like this... + +``` +No compiler found, expected minor version match with... +Try running "stack setup" to install the correct GHC... +``` + +Just do as it says and it will download and install +the correct compiler version: + +```bash +stack setup +``` + + +If you want to play with your solution in GHCi, just run the command: + +```bash +stack ghci +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit src/HelloWorld.hs` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Haskell track's documentation](https://exercism.org/docs/tracks/haskell) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Getting Started + +Please refer to the [installation](https://exercism.io/tracks/haskell/installation) +and [learning](https://exercism.io/tracks/haskell/learning) help pages. + +## Feedback, Issues, Pull Requests + +The [exercism/haskell](https://github.com/exercism/haskell) repository on +GitHub is the home for all of the Haskell exercises. + +If you have feedback about an exercise, or want to help implementing a new +one, head over there and create an issue. We'll do our best to help you! +{{ with .Spec.Credits }} diff --git a/haskell/hello-world/README.md b/haskell/hello-world/README.md new file mode 100644 index 0000000..f454ebc --- /dev/null +++ b/haskell/hello-world/README.md @@ -0,0 +1,45 @@ +# Hello World + +Welcome to Hello World on Exercism's Haskell Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +The classical introductory exercise. Just say "Hello, World!". + +["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is +the traditional first program for beginning programming in a new language +or environment. + +The objectives are simple: + +- Write a function that returns the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +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. + +## Source + +### Created by + +- @ErikSchierboom + +### Contributed to by + +- @iHiD +- @kytrinyx +- @petertseng +- @ppartarr +- @rbasso +- @sshine +- @tejasbubane + +### Based on + +This is an exercise to introduce users to using Exercism - http://en.wikipedia.org/wiki/%22Hello,_world!%22_program \ No newline at end of file diff --git a/haskell/hello-world/examples/success-standard/package.yaml b/haskell/hello-world/examples/success-standard/package.yaml new file mode 100644 index 0000000..7e8f159 --- /dev/null +++ b/haskell/hello-world/examples/success-standard/package.yaml @@ -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 diff --git a/haskell/hello-world/hello-world.cabal b/haskell/hello-world/hello-world.cabal new file mode 100644 index 0000000..da91d3b --- /dev/null +++ b/haskell/hello-world/hello-world.cabal @@ -0,0 +1,34 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.34.2. +-- +-- see: https://github.com/sol/hpack + +name: hello-world +version: 1.1.0.5 +build-type: Simple + +library + exposed-modules: + HelloWorld + other-modules: + Paths_hello_world + hs-source-dirs: + src + ghc-options: -Wall + build-depends: + base + default-language: Haskell2010 + +test-suite test + type: exitcode-stdio-1.0 + main-is: Tests.hs + other-modules: + Paths_hello_world + hs-source-dirs: + test + build-depends: + base + , hello-world + , hspec + default-language: Haskell2010 diff --git a/haskell/hello-world/package.yaml b/haskell/hello-world/package.yaml new file mode 100644 index 0000000..20feca0 --- /dev/null +++ b/haskell/hello-world/package.yaml @@ -0,0 +1,21 @@ +name: hello-world +version: 1.1.0.5 + +dependencies: + - base + +library: + exposed-modules: HelloWorld + source-dirs: src + ghc-options: -Wall + # 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 diff --git a/haskell/hello-world/src/HelloWorld.hs b/haskell/hello-world/src/HelloWorld.hs new file mode 100644 index 0000000..3dcb711 --- /dev/null +++ b/haskell/hello-world/src/HelloWorld.hs @@ -0,0 +1,4 @@ +module HelloWorld (hello) where + +hello :: String +hello = "Hello, World!" diff --git a/haskell/hello-world/stack.yaml b/haskell/hello-world/stack.yaml new file mode 100644 index 0000000..35c2e5b --- /dev/null +++ b/haskell/hello-world/stack.yaml @@ -0,0 +1 @@ +resolver: lts-16.21 diff --git a/haskell/hello-world/stack.yaml.lock b/haskell/hello-world/stack.yaml.lock new file mode 100644 index 0000000..c646f0b --- /dev/null +++ b/haskell/hello-world/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 532413 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/21.yaml + sha256: 7b5cac89352fa4a88606dc6cb250aee9291f21e2e988d464065f5aa51f5de33d + original: lts-16.21 diff --git a/haskell/hello-world/test/Tests.hs b/haskell/hello-world/test/Tests.hs new file mode 100644 index 0000000..ee88a73 --- /dev/null +++ b/haskell/hello-world/test/Tests.hs @@ -0,0 +1,13 @@ +import Test.Hspec (Spec, it, shouldBe) +import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith) + +import HelloWorld (hello) + +main :: IO () +main = hspecWith defaultConfig {configFastFail = True} specs + +specs :: Spec +specs = it "hello" $ + hello `shouldBe` "Hello, World!" + +-- 5c542864b011fb742aa95ca950d3473ce168ec8c