Here is some pretty direct guidance in the elm-sortable-table docs 
<https://github.com/evancz/elm-sortable-table>

One of the core rules of The Elm Architecture is never put functions in 
your Model or Msg types. It may cost a little bit of extra code to model 
everything as data, but the architecture and debugging benefits are worth 
it.

On Tuesday, January 17, 2017 at 9:24:10 PM UTC-6, Marshall handheld Flax 
wrote:
>
> Is it wrong for Cmds to contain functions (as opposed to data within 
> constructors)?  If it is a reasonable practice, it would allow for more 
> functional component-like modules, but does this violate the Elm 
> architecture?  If it does, is it explicitly mentioned in the docs -- I 
> don't remember seeing it. Here's http://elm-lang.org/examples/buttons 
> rewritten in the Cmd-contains-functions style. Thank you!
>
> module Main exposing (..)
>
> import Html exposing (beginnerProgram, div, button, text)
> import Html.Events exposing (onClick)
>
> main =
>     beginnerProgram { model = 0, view = view, update = update }
>
> type Msg
>     = Transform (Int -> Int)
>
> view model =
>     div []
>         [ button [ onClick (Transform ((+) -1)) ] [ text "-" ]
>         , div [] [ text (toString model) ]
>         , button [ onClick (Transform ((+) 1)) ] [ text "+" ]
>         ]
>
> update msg model =
>     case msg of
>         Transform xform ->
>             xform model
>
>
>
On Tuesday, January 17, 2017 at 9:24:10 PM UTC-6, Marshall handheld Flax 
wrote:
>
> Is it wrong for Cmds to contain functions (as opposed to data within 
> constructors)?  If it is a reasonable practice, it would allow for more 
> functional component-like modules, but does this violate the Elm 
> architecture?  If it does, is it explicitly mentioned in the docs -- I 
> don't remember seeing it. Here's http://elm-lang.org/examples/buttons 
> rewritten in the Cmd-contains-functions style. Thank you!
>
> module Main exposing (..)
>
> import Html exposing (beginnerProgram, div, button, text)
> import Html.Events exposing (onClick)
>
> main =
>     beginnerProgram { model = 0, view = view, update = update }
>
> type Msg
>     = Transform (Int -> Int)
>
> view model =
>     div []
>         [ button [ onClick (Transform ((+) -1)) ] [ text "-" ]
>         , div [] [ text (toString model) ]
>         , button [ onClick (Transform ((+) 1)) ] [ text "+" ]
>         ]
>
> update msg model =
>     case msg of
>         Transform xform ->
>             xform model
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to