What tutorial would you like to see out there?

Hi everyone!

While learning Elm, have you found yourself blocked at some point by a chunk of knowledge/Howto slightly too large? If you managed to ingest it by successive trials and errors, what kind of tutorial would have eased your learning session, and what is your background?

Finally, does the community has already built something like Built With Elm but for external learning resources?

I’m asking because I would like to contribute in some way :slight_smile:

Have a nice day!


Elm was my first functional programming language. The only thing that confused me a lot was how to use ports.

@dullbanas, It seems many people struggle with ports at some point… what did you read and how did you managed to get it? More generally, could you tell me more about your learning process (eg, are you a top-down person who needs to understands concepts first, or do you need to go through examples or exercises?)? Are you confortable with javascript?
Thanks for your answer

1 Like

I was good at javascript before I learned Elm. I learned about Elm (including ports) here in January 2020. Ports seemed very complex to me and it was especially hard to understand incoming ports (js to elm).

type Msg
    = ReceivedInt Int

port toJs : Int -> Cmd msg
port toElm : (Int -> msg) -> Sub msg

It would have been better if I understood the role of the toJs and toElm values:

  • toJs takes an Int and creates a Cmd msg that sends the value to js when you return it from update.
  • toElm takes a function that converts an Int to msg and creates a Sub msg that allows you to receive the values sent from js. It creates a separate function on the js side that allows js code to send a value through this port when you return it from subscriptions.

In other words, toJs allows you to send a value to Javascript, and toElm allows you to receive values from Javascript and convert that to a Msg value. I understood the role of toJs, but not toElm. I saw it as a function that is like toJs except it’s called from javascript. I also didn’t understand that the (Int -> msg) is ReceivedInt.

I also remember feeling like there weren’t enough examples of sending various types of values through ports. It might have been easier to understand if I knew that the way values are converted to and from javascript and elm through ports is the same as how it’s converted in flags.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.