Created
January 15, 2017 18:50
-
-
Save bgourlie/d7c431d3e458ac3affd06cd21f9be987 to your computer and use it in GitHub Desktop.
Attempting minimal reproduction of a stackoverflow error with elm's debugger
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
import Html exposing (p, text, div, canvas, Html) | |
import Html.Attributes exposing (id, style) | |
import Html.Events exposing (..) | |
import List exposing (repeat, concat) | |
import Array exposing (Array, fromList) | |
import Color exposing (rgb, Color) | |
import Debug exposing (log) | |
main = | |
Html.program | |
{ init = (model, Cmd.none) | |
, view = view | |
, update = update | |
, subscriptions = always Sub.none | |
} | |
-- MODEL | |
type alias Canvas = | |
{ id : String | |
, imageData : ImageData | |
} | |
type alias ImageData = | |
{ width : Int | |
, height : Int | |
, data : Array Int | |
} | |
type alias Model = Canvas | |
type Msg | |
= Draw | |
model : Canvas | |
model = | |
let | |
width = 500 | |
height = 400 | |
in | |
{ id = "the-canvas" | |
, imageData = | |
{ width = width | |
, height = height | |
, data = | |
black | |
|>repeat (width * height) | |
|>concat | |
|>fromList | |
} | |
} | |
black : List Int | |
black = | |
[ 0, 0, 0, 255 ] | |
prettyBlue : Color | |
prettyBlue = | |
rgb 23 92 254 | |
-- UPDATE | |
update : Msg -> Model -> (Model, Cmd Msg) | |
update message canvas = | |
case message of | |
Draw -> | |
let _ = log "draw" "draw" in | |
(canvas, Cmd.none) | |
-- VIEW | |
view : Model -> Html Msg | |
view canvas = | |
div | |
[] | |
[ p [] [ text "v--- stack overflow if you click there :^(" ] | |
, Html.canvas [ onMouseDown Draw ] [] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment