mirror of
https://github.com/correl/elm.git
synced 2024-12-18 11:06:17 +00:00
Update docs and hello-world to reflect exercise specific elm-package.json files.
This commit is contained in:
parent
c71f090a4e
commit
114961fd89
5 changed files with 58 additions and 23 deletions
|
@ -23,7 +23,7 @@ Please keep the following in mind:
|
||||||
|
|
||||||
- Please open an issue before creating a PR that makes significant (breaking) changes to an existing exercise or makes changes across many exercises. It is best to discuss these changes before doing the work.
|
- Please open an issue before creating a PR that makes significant (breaking) changes to an existing exercise or makes changes across many exercises. It is best to discuss these changes before doing the work.
|
||||||
|
|
||||||
- Follow the coding standards found in [The Elm Style Guide](http://elm-lang.org/docs/style-guide).
|
- Follow the coding standards found in [The Elm Style Guide](http://elm-lang.org/docs/style-guide). Please consider running [elm-format](https://github.com/avh4/elm-format) before submitting a pull request.
|
||||||
|
|
||||||
- Watch out for trailing spaces, extra blank lines, and spaces in blank lines.
|
- Watch out for trailing spaces, extra blank lines, and spaces in blank lines.
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ Please keep the following in mind:
|
||||||
- Please do not add a README or README.md file to the exercise directory. The READMEs are constructed using shared metadata, which lives in the
|
- Please do not add a README or README.md file to the exercise directory. The READMEs are constructed using shared metadata, which lives in the
|
||||||
[exercism/x-common](https://github.com/exercism/x-common) repository.
|
[exercism/x-common](https://github.com/exercism/x-common) repository.
|
||||||
|
|
||||||
- Each problem should have a test suite, an example solution, and a template file for the real implementation. The CI build expects files to be named using the following convention. The example solution should be named `ExerciseModuleName.example`. The template file should be named `ExerciseModuleName.elm`. Test file should be named `ExerciseModuleNameTest.elm`.
|
- Each exercise should have a test suite, an example solution, a template file for the real implementation and an `elm-package.json` file with the `elm-test` and `elm-console` dependencies. The CI build expects files to be named using the following convention. The example solution should be named `ExerciseModuleName.example`. The template file should be named `ExerciseModuleName.elm`. Test file should be named `ExerciseModuleNameTest.elm`.
|
||||||
|
|
||||||
- Test files should use the following format:
|
- Test files should use the following format:
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ port runner =
|
||||||
|
|
||||||
- All the tests for xElm exercises can be run from the top level of the repo with `bin/build.sh`. Please run this command before submitting your PR.
|
- All the tests for xElm exercises can be run from the top level of the repo with `bin/build.sh`. Please run this command before submitting your PR.
|
||||||
|
|
||||||
- If you are submitting a new exercise, be sure to add it to the appropriate place in `config.json` and `elm-package.json` files. Also, please run `bin/fetch-configlet && bin/configlet` to ensure the exercise is configured correctly.
|
- If you are submitting a new exercise, be sure to add it to the appropriate place in the `config.json` and `elm-package.json` files. Also, please run `bin/fetch-configlet && bin/configlet` to ensure the exercise is configured correctly.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
Download and install a recent Elm Platform for your OS from [elm-lang.org/install](http://elm-lang.org/install).
|
## Installing on any platform
|
||||||
|
|
||||||
## MacOS
|
The simplest way to install Elm is via Node.js/NPM.
|
||||||
|
|
||||||
|
If you don't already have Node.js installed on your computer, you can download it from [the official site](https://nodejs.org/). Once you have Node.js up and running, follow these steps to install the Elm platform and elm-test.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm install --global elm elm-test
|
$ npm install --global elm elm-test
|
||||||
$ elm-package install -y
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
Run tests with soemthing like the following command:
|
Elm exercises within your exercism project directory can be run by changing to the exercise directory, and running `elm-test NameOfTests.elm`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ elm-test exercises/bob/BobTests.elm
|
$ cd exercism/project/directory/elm/hello-world
|
||||||
|
$ elm-test HelloWorldTests.elm
|
||||||
```
|
```
|
||||||
|
|
||||||
## Making Your First Elm Module
|
When you first run `elm-test` for an exercise it will prompt you to install the test library dependencies. If you type "y" and hit enter, the script should take care of the rest.
|
||||||
|
|
||||||
To create a module that can be loaded with `import BobExample exposing (responseFor)`, put this code in `BobExample.elm`:
|
## Hints and tips
|
||||||
|
|
||||||
```elm
|
### Coding the exercise
|
||||||
module BobExample where
|
|
||||||
|
|
||||||
responseFor : String -> String
|
The README.md for each exercise gives a general description but the Elm test program will be very specific. Open the test program and give it a quick look - if it seems like cheating, do it anyway. Look for helpful comments, test data, and just the names of the test functions. Try running the test command before you have written anything and see if the error messages give you an idea of where to start.
|
||||||
responseFor statement = undefined
|
|
||||||
```
|
Your first goal it to get something to compile, even though it fails tests. For this, you should "stub" functions. That means leave the body empty, except for whatever it must return. Write something like `myFunc param = 0` or whatever it takes just to get it to compile. Sometimes to figure out function types you will have to go back to the test program and read in more detail. Once you have figured out all the required function signatures, the test program will complain that `0` is the wrong answer. Now start filling in function bodies.
|
||||||
|
|
||||||
|
### Fixing
|
||||||
|
|
||||||
|
It will often be helpful to focus on the first failing test. Fix that one, repeat until no errors. Compile errors and warnings will produce lots of helpful output.
|
||||||
|
|
||||||
|
### Cleaning up your code
|
||||||
|
|
||||||
|
Consider running [`elm-format`](https://github.com/avh4/elm-format) on your code before submitting it.
|
||||||
|
|
|
@ -1 +1,25 @@
|
||||||
module HelloWorld where
|
{-
|
||||||
|
This is a "stub" file. It's a little start on your solution. It's not a
|
||||||
|
complete solution though; you have to write some code.
|
||||||
|
|
||||||
|
The module name is expected by the test program and must match the name of this
|
||||||
|
file. It has to stay just the way it is.
|
||||||
|
-}
|
||||||
|
|
||||||
|
|
||||||
|
module HelloWorld (..) where
|
||||||
|
|
||||||
|
-- It's good style to include a types at the top level of your modules.
|
||||||
|
|
||||||
|
|
||||||
|
helloWorld : Maybe String -> String
|
||||||
|
helloWorld name =
|
||||||
|
"replace with your code!"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{-
|
||||||
|
When you have a working solution, REMOVE ALL THE STOCK COMMENTS.
|
||||||
|
They're here to help you get started but they only clutter a finished solution.
|
||||||
|
If you leave them in, nitpickers will protest!
|
||||||
|
-}
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import String
|
module Main (..) where
|
||||||
import Task
|
|
||||||
|
|
||||||
|
import Task
|
||||||
import Console
|
import Console
|
||||||
import ElmTest exposing (..)
|
import ElmTest exposing (..)
|
||||||
import HelloWorld exposing (..)
|
import HelloWorld exposing (helloWorld)
|
||||||
|
|
||||||
|
|
||||||
tests : Test
|
tests : Test
|
||||||
tests =
|
tests =
|
||||||
suite "Hello, World!"
|
suite
|
||||||
[ test "Hello with no name" (assertEqual "Hello, World!" (helloworld Nothing))
|
"Hello, World!"
|
||||||
, test "Hello to a sample name" (assertEqual "Hello, Alice!" (helloworld (Just "Alice")))
|
[ test "Hello with no name" (assertEqual "Hello, World!" (helloWorld Nothing))
|
||||||
, test "Hello to another sample name" (assertEqual "Hello, Bob!" (helloworld (Just "Bob")))
|
, test "Hello to a sample name" (assertEqual "Hello, Alice!" (helloWorld (Just "Alice")))
|
||||||
|
, test "Hello to another sample name" (assertEqual "Hello, Bob!" (helloWorld (Just "Bob")))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue