starmelon/examples/single-page/src/Main.elm
2025-11-23 19:34:17 -08:00

78 lines
1.4 KiB
Elm

module Main exposing (view, view2, view3, view4, view5, view6, view7, view8, badReturnType, true, main)
import Html exposing (Html, div, text)
import Svg exposing (Svg, svg)
import Array exposing (Array)
import Bytes exposing (Bytes)
import Bytes.Decode
main = text "main"
type alias Model =
{ a : Int
, b : Array Int
}
view : String -> Html msg
view model =
div []
[ text <| "Hello world" ++ model ]
view2 : String -> Svg msg
view2 model =
svg [] []
view3: Bytes -> Html msg
view3 model =
case
Bytes.Decode.decode
(Bytes.Decode.string (Bytes.width model))
model
of
Just decoded ->
div []
[ text <| "Hello world" ++ decoded ]
Nothing ->
text "Failed to decode"
view4 : String -> Html msg
view4 model =
if model == "bar" then
div []
[ text <| "Hello world" ++ model ]
else
div []
[ text "Hello world" ]
view5 : { t | x : String } -> Html msg
view5 { x } =
div []
[ text x ]
view6 : String -> Html msg
view6 model =
let
f = div []
in
f [ text model ]
view7 : String -> Html msg
view7 model =
(if True then div [] else div []) [ text model ]
view8 : String -> Html msg
view8 model =
privateFunction [] []
badReturnType : String -> Int
badReturnType _ =
42
privateFunction = div
true : Bool
true =
True