The classical introductory exercise. Just say "Hello, World!".
"Hello, World!" is the traditional first program for beginning programming in a new language or environment.
The objectives are simple:
If everything goes well, you will be ready to fetch your first real exercise.
npm install -g purescript pulp bower
Install project dependencies:
bower install (inside the "hello-world" directory)
pulp build (gotta do this once before the PureScript editor plugins will work)
Running the test:
exercism submit src/HelloWorld.purs
This is an exercise to introduce users to using Exercism http://en.wikipedia.org/wiki/%22Hello,_world!%22_program
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
module Test.Main where import Prelude import Effect (Effect) import Test.Unit (TestSuite, suite, test) import Test.Unit.Main (runTest) import Test.Unit.Assert as Assert import Data.Maybe (Maybe(Just, Nothing)) import HelloWorld (helloWorld) main :: Effect Unit main = runTest suites suites :: TestSuite suites = do suite "HelloWorld.helloWorld" do test "Hello with no name" do Assert.equal "Hello, World!" (helloWorld Nothing) test "Hello to a sample name" do Assert.equal "Hello, Alice!" (helloWorld (Just "Alice")) test "Hello to another sample name" do Assert.equal "Hello, Bob!" (helloWorld (Just "Bob"))
module HelloWorld where import Prelude import Data.Maybe (Maybe(Just, Nothing)) helloWorld :: Maybe String -> String helloWorld Nothing = "Hello, World!" helloWorld (Just name)= "Hello, " <> name <> "!"
A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.
Here are some questions to help you reflect on this solution and learn the most from it.