Skip to content

Commit

Permalink
Merge pull request #29 from blaix/homepage-update
Browse files Browse the repository at this point in the history
Add code and compiler examples to homepage
  • Loading branch information
blaix authored Dec 18, 2024
2 parents 901079c + 36c71e9 commit 05afbcb
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions src/Page/Index.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand All @@ -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
[]
Expand Down

0 comments on commit 05afbcb

Please sign in to comment.