diff --git a/src/Page/Index.elm b/src/Page/Index.elm index ba3b04b..6a0a16d 100644 --- a/src/Page/Index.elm +++ b/src/Page/Index.elm @@ -82,6 +82,62 @@ view _ _ _ = , Html.p [] [ Html.text "Programs written in Gren are simple, have few or no runtime exceptions and are fun to work with." ] ] + , Html.article + [] + [ Html.h3 [] + [ Html.text "Runs Anywhere" ] + , Html.pre [] + [ Html.code [] + [ Html.text + """viewItems : Array String -> String +viewItems items = + items + |> Array.sort + |> String.join ", " +""" + ] + ] + , Html.p [] + [ Html.text "In the " + , Html.a + [ Attribute.href "https://packages.gren-lang.org/package/gren-lang/browser/version/latest/overview" ] + [ Html.text "browser:" ] + ] + , Html.pre [] + [ Html.code [] + [ Html.text + """Html.p [] [ Html.text (viewItems model.items) ]""" + ] + ] + , Html.p [] + [ Html.text "In the " + , Html.a + [ Attribute.href "https://packages.gren-lang.org/package/gren-lang/node/version/latest/overview" ] + [ Html.text "terminal:" ] + ] + , Html.pre [] + [ Html.code [] + [ Html.text + """Stream.writeLineAsBytes (viewItems model.items) model.stdout""" + ] + ] + , Html.p [] + [ Html.text "On the " + , Html.a + [ Attribute.href "https://packages.gren-lang.org/package/gren-lang/node/version/latest/module/HttpServer" ] + [ Html.text "server:" ] + ] + , Html.pre [] + [ Html.code [] + [ Html.text + """response + |> Response.setHeader "Content-type" "text/csv" + |> Response.setBody (viewItems model.items) + |> Response.send +""" + ] + ] + ] , Html.article [] [ Html.h3 [] @@ -90,6 +146,32 @@ view _ _ _ = [ Html.text "Since side effects and error handling is represented in Gren's type system, the compiler can catch a lot of errors which are usually only discovered when the program is running in other languages." ] , Html.p [] [ Html.text "In Gren, a lot of time has been invested in how error messages are presented to you, so that the compiler feels more like a helpful assistant." ] + , Html.pre [] + [ Html.code [] + [ Html.span + [ Attribute.style "color" "rgb(36, 163, 175)" ] + [ Html.text "-- TYPE MISMATCH ------------------------------------------------- src/Main.gren\n\n" ] + , Html.text "The 1st argument to `viewItems` is not what I expect:\n\n14| \"Item IDs: \" ++ (viewItems [1, 2, 3])\n" + , Html.span + [ Attribute.style "color" "rgb(194, 54, 33)" ] + [ Html.text <| (String.repeat 34 " ") ++ "^^^^^^^^^\n" ] + , Html.text "This argument is an array of type:\n\n Array " + , Html.span + [ Attribute.style "color" "rgb(173, 173, 39)" ] + [ Html.text "number\n\n" ] + , Html.text "But `viewItems` needs the 1st argument to be:\n\n Array " + , Html.span + [ Attribute.style "color" "rgb(173, 173, 39)" ] + [ Html.text "String\n\n" ] + , Html.span + [ Attribute.style "text-decoration" "underline" ] + [ Html.text "Hint" ] + , Html.text ": Try using ", Html.span + [ Attribute.style "color" "rgb(40, 187, 28)" ] + [ Html.text "String.fromInt" ] + , Html.text " to convert it to a String?" + ] + ] ] , Html.article []