Stream: beginners

Topic: ✔ Without an LSP, how do you check what type something is?


view this post on Zulip Tankor Smash (Dec 02 2023 at 18:09):

In Elm, you could do something like

someFunc x y  =
       let
            x2 : TypeItsNot
            x2 = x
       in
       x + y

and the compiler would say 'thats not TypeItsNot, it's an Int'.

It doesn't appear that the same trick works in roc so far, but maybe there's an equivalent way of getting the type.

view this post on Zulip Tankor Smash (Dec 02 2023 at 18:11):

Oh actually maybe it does work:

someFunc = \fileName ->
    foo : TypeItsNot
    foo = Util.readInputFile fileName
    foo

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 18:13):

yeah, that should work.

view this post on Zulip Tankor Smash (Dec 02 2023 at 18:15):

Thanks! It turns out the reason I thought it didn't work was because I was missing the last returned value there, and the compiler didn't know what I meant.

someFunc = \fileName ->
    foo : TypeItsNot
    foo = Util.readInputFile fileName

and I didn't read the error message closely.

view this post on Zulip Notification Bot (Dec 02 2023 at 18:15):

Tankor Smash has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC