Stream: beginners

Topic: Result inside Builtin


view this post on Zulip Luke Boswell (Mar 14 2023 at 22:44):

Am I missing something here? Having trouble using the Result builtin inside the Json builtin. Could this be because i'm working inside a builtin?

# Test json array decode empty list
expect
    input = Str.toUtf8 "[ ]"

    actual : Result (List U8) _
    actual = Decode.fromBytes input fromUtf8

    expected = Ok []

    actual == expected
luke$ roc test Json.roc

── UNRECOGNIZED NAME ──────────────────────────────────────────────── Json.roc ─

Nothing is named `Result` in this scope.

514│      actual : Result (List U8) _
                   ^^^^^^^^^^^^^^^^^^

Did you mean one of these?

    List
    input
    Dec
    actual

view this post on Zulip Luke Boswell (Mar 14 2023 at 22:48):

Actually... I needed to add Result.{ Result } to imports... I guess for some reason I had in my mind that builtins were automatically imported.

view this post on Zulip Brendan Hansknecht (Mar 14 2023 at 23:04):

Yeah, for builtin files, like Json.roc, imports have to be explicit.

view this post on Zulip Richard Feldman (Mar 14 2023 at 23:17):

that shouldn't be necessary once Json is broken out into a separate package


Last updated: Jul 05 2025 at 12:14 UTC