-
-
Save colinmccabe/56abf3c8a602834401cac1933c38ba7f to your computer and use it in GitHub Desktop.
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
{ | |
"version": "0.1.0", | |
"summary": "", | |
"repository": "http://github.com/colinmccabe/html-bug.git", | |
"license": "BSD3", | |
"source-directories": [ | |
"." | |
], | |
"exposed-modules": [], | |
"dependencies": { | |
"elm-lang/core": "4.0.0 <= v < 5.0.0", | |
"elm-lang/html": "1.0.0 <= v < 2.0.0" | |
}, | |
"elm-version": "0.17.0 <= v < 0.18.0" | |
} |
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 (main) -- where | |
import Html | |
import Html.App | |
import Platform.Cmd | |
import Time | |
type alias Model = | |
List String | |
init : (Model, Cmd a) | |
init = | |
( [] | |
, Cmd.none | |
) | |
type Msg | |
= Tick Time.Time | |
| NoOp | |
update : Msg -> Model -> (Model, Cmd a) | |
update msg model = | |
case msg of | |
Tick time -> | |
( (toString time) :: model | |
, Cmd.none | |
) | |
NoOp -> | |
( model, Cmd.none ) | |
main : Program Never | |
main = | |
Html.App.program | |
{ init = init | |
, update = update | |
, view = view | |
, subscriptions = \_ -> Time.every (500 * Time.millisecond) Tick | |
} | |
view : Model -> Html.Html Msg | |
view model = | |
let html = | |
-- I don't know why, but this case that returns either a div | |
-- or a table, passed to Html.App.map, causes an exception. | |
-- Remove either, and there is no exception. | |
case model of | |
[] -> | |
Html.div [] [ Html.text "No items, displaying div with text" ] | |
xs -> | |
viewTable xs | |
in | |
Html.App.map (\_ -> NoOp) html | |
viewTable : Model -> Html.Html a | |
viewTable model = | |
Html.table | |
[] | |
[ Html.thead | |
[] | |
[ Html.tr [] [ Html.text "Table:" ] ] | |
, Html.tbody | |
[] | |
(List.map (\item -> Html.tr [] [ Html.td [] [ Html.text item ] ]) model) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment