Skip to content

Instantly share code, notes, and snippets.

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
-- Interface
class AnimalInterface a where
name :: a -> String
sayHelloTo :: a -> String -> String
-- Dog Implementation
data Dog = Dog
{ dogName :: String
}
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
model ! []
Add ->
{ model
| uid = model.uid + 1
, field = ""
type Msg
= NoOp
| UpdateField String
| EditingTask Int Bool
| UpdateTask Int String
| Add
| Delete Int
| DeleteComplete
| Check Int Bool
| CheckAll Bool
type TaskMsg
= Check Bool
| Editing Bool
| Update String
type TaskListMsg
= Add Int String
| Delete Int
| DeleteComplete
| CheckAll Bool
update : Msg -> Model -> Model
update msgFor taskList =
case msgFor of
MsgForTaskList msg ->
updateTaskList msg taskList
MsgForTask id msg ->
updateTask id msg taskList
_ ->
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
}
module Main exposing (..)
import ElmTest exposing (..)
import Example
tests : Test
tests =
Example.tests
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'
]))
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