This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Use The Elm Architecture to generate any type of Signal
version 1.0.0
license BSD3
native-modules False
elm-version 0.15.0 <= v < 0.17.0
Tag 1.0.0
Committed At 2016-02-25 04:43:52 UTC
evancz/elm-effects 2.0.0 <= v < 3.0.0 2.0.1
elm-lang/core 2.0.1 <= v < 4.0.0 3.0.0

README

The Elm Architecture

This package is an abstraction of StartApp, which allows you to build up and create Signals of any type using the Elm Architecture. You could decide to use the core Graphics module to write your view, or maybe you're making an app where the view is rendered by something else other than Elm. You would be able to follow the Elm Architecture, but supply a JSON encoder as the view function and send it out a port.

Example

The following chunk of code sets up a simple counter that you can increment and decrement. Notice that you focus entirely on setting up model, view, and update. That is it, no distractions!

import Graphics.Element exposing (show, flow, down)
import Graphics.Input exposing (button)
import Architecture.Simple as Architecture


main =
  Architecture.start { model = model, view = view, update = update }


model = 0


view address model =
  flow down <|
    [ button (Signal.message address Decrement) "-"
    , show model
    , button (Signal.message address Increment) "+"
    ]


type Action = Increment | Decrement


update action model =
  case action of
    Increment -> model + 1
    Decrement -> model - 1

Further Learning

Check out the full documentation for this library here.

For more guidelines and examples of making apps in Elm, check out the following resources:

  • Language Docs — tons of learning resources that go from syntax to language features to design guidelines.
  • The Elm Architecture — simple examples demonstrating how our basic counter app can scale to huge applications that are easy to test, maintain, and refactor.
  • elm-todomvc — a typical TodoMVC program (live) built on the Elm Architecture. You will see the model, update, view pattern but for a more realistic application than a counter.
  • dreamwriter — a writing app built in Elm that again uses the Elm Architecture. The creator has never had a runtime exception in his Elm code. Unlike JavaScript, Elm is designed for reliability that scales to any size.