# Need help with getting / understanding Random

**URL:** <https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966>\
**Category:** Learn\
**Created:** [February 25, 2023, 9:06pm UTC](https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966 "2023-02-25T21:06:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msszczep](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/msszczep/32/4817_2.png) [@msszczep](https://discourse.elm-lang.org/u/msszczep)\
**Post date:** [February 25, 2023, 9:06pm UTC](https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966/1 "2023-02-25T21:06:27Z")

</div>

I love coding in Elm, but I dread having to deal with the Random or elm-community Random packages.

I’m trying to get it to work, and I just don’t understand why it doesn’t. I’m trying at the very basic super-simple level.

I’ve opened up a repl and I’m going through the example in the [generate function](https://package.elm-lang.org/packages/elm/random/1.0.0/Random#generate).

```auto
$ elm repl
---- Elm 0.19.1 ----------------------------------------------------------------
Say :help for help and :exit to exit! More at <https://elm-lang.org/0.19.1/repl>
--------------------------------------------------------------------------------
> import Random
> 
> point =
| Random.pair (Random.int -100 100) (Random.int -100 100)
|   
Generator <function> : Random.Generator ( Int, Int )
> type Msg = NewPoint (Int, Int)
> 
> newPoint =
| Random.generate NewPoint point
|   
<internals> : Cmd Msg
> newPoint
<internals> : Cmd Msg

```

The document says:

> Each time you run the `newPoint` command, it will produce a new 2D point like `(57, 18)` or `(-82, 6)`.

So why do I see `<internals> : Cmd Msg` instead of a new 2D point? What am I doing wrong? Am I missing something? Do I need to do something further?

Thanks.  
– Mitchell

---

<div class="post-metadata">

**Author:** ![Augustin82](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/augustin82/32/1591_2.png) [@Augustin82](https://discourse.elm-lang.org/u/Augustin82)\
**Post date:** [February 25, 2023, 9:31pm UTC](https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966/2 "2023-02-25T21:31:57Z")

</div>

In Elm, you don’t directly “run” commands; instead you create `Cmd`s and you “hand them” to the Elm runtime, which runs it for you.  
In the REPL, when you input a function/value, the REPL tells you the type of the thing you’ve written. When you create a `Cmd`, it gives you the type of `Cmd`, which is actually an “internal” type, as in “closed to view”. Regardless, the type is confirmed to be `Cmd Msg`, which means that if you use it within an `update` function, it will work as intended.  
As a sidenote, this has nothing to do specifically with Random, it’d be the same with any type of `Cmd`.

---

<div class="post-metadata">

**Author:** ![msszczep](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/msszczep/32/4817_2.png) [@msszczep](https://discourse.elm-lang.org/u/msszczep)\
**Post date:** [February 26, 2023, 1:23am UTC](https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966/3 "2023-02-26T01:23:41Z")

</div>

This helped. It helped me get over the conceptual block I had. I’ve got Random working now. Thank you @Augustin82

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [March 8, 2023, 1:23am UTC](https://discourse.elm-lang.org/t/need-help-with-getting-understanding-random/8966/4 "2023-03-08T01:23:50Z")

</div>

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