This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
type alias Animal = { name : String, sayHello : String } -- class | |
animal : String -> Animal -- object creator | |
animal name = | |
{ name = name | |
, sayHello = Debug.crash <| "Missing implementation" | |
} | |
type alias Cat = Animal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Interface | |
class AnimalInterface a where | |
name :: a -> String | |
sayHelloTo :: a -> String -> String | |
-- Dog Implementation | |
data Dog = Dog | |
{ dogName :: String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg model = | |
case msg of | |
NoOp -> | |
model ! [] | |
Add -> | |
{ model | |
| uid = model.uid + 1 | |
, field = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Msg | |
= NoOp | |
| UpdateField String | |
| EditingTask Int Bool | |
| UpdateTask Int String | |
| Add | |
| Delete Int | |
| DeleteComplete | |
| Check Int Bool | |
| CheckAll Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TaskMsg | |
= Check Bool | |
| Editing Bool | |
| Update String | |
type TaskListMsg | |
= Add Int String | |
| Delete Int | |
| DeleteComplete | |
| CheckAll Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update : Msg -> Model -> Model | |
update msgFor taskList = | |
case msgFor of | |
MsgForTaskList msg -> | |
updateTaskList msg taskList | |
MsgForTask id msg -> | |
updateTask id msg taskList | |
_ -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update : Msg -> Model -> Model | |
update msg model = | |
{ model | |
| taskEntry = Task.update msg model.taskEntry | |
, taskList = TaskList.update msg model.taskList | |
, control = Control.update msg model.control | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import ElmTest exposing (..) | |
import Example | |
tests : Test | |
tests = | |
Example.tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
shell = require('gulp-shell'); | |
gulp.task('build-tests', shell.task([ | |
'elm-make --warn test/TestRunner.elm --output test.js' | |
])) | |
gulp.task('run-tests', ['build-tests'], shell.task([ | |
'node test.js' | |
])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Example where | |
import ElmTestBDDStyle exposing (..) | |
import Check.Producer exposing (..) | |
tests : Test | |
tests = | |
describe "A Test Suite" | |
[ it "adds two numbers" <| | |
expect (3 + 7) toBe 10 |