Stream: show and tell

Topic: Nea


view this post on Zulip Folkert de Vries (Nov 29 2023 at 16:53):

the first non-trival roc + nea program just worked

app "nea-test"
    packages { pf: "platform/main.roc" }
    imports []
    provides [main] to pf

parseNum : Str -> U32
parseNum = \input ->
    when Str.toU32 input is
        Ok v -> v
        Err _ -> crash "invalid input"

main : Str -> Str
main = \input ->
    input
    |> Str.split "\n"
    |> List.map \line ->
        when Str.split line ", " is
            [ xStr, yStr ] -> ( parseNum xStr, parseNum yStr )
            _ -> crash "invalid input"
    |> List.walk "M 0 0 L" \accum, (x, y) -> "\(accum)\(Num.toStr x) \(Num.toStr y) "
    |> \d ->
        """
        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
          <path d="\(d)" stroke="black" fill="transparent"/>
        </svg>
        """

still lots to do to make it fast and more stable, but this is very exciting

view this post on Zulip Ayaz Hafiz (Nov 29 2023 at 16:54):

Does it stand for "never ever allocate"

view this post on Zulip Ayaz Hafiz (Nov 29 2023 at 16:54):

Oh I see "NEver Allocate"

view this post on Zulip Folkert de Vries (Nov 29 2023 at 17:43):

yes that worked out. its origin is the frisian word for "never"


Last updated: Jul 06 2025 at 12:14 UTC