'iterate' is the right way to do what you're looking for. No idea why they
chose to expose that.
generate : Generator a -> Seed -> LazyList a
generate generator seed =
let start = Random.step generator seed in
LL.iterate
(\(v,s) -> Random.step generator s)
start
|> LL.map Tuple.first
On Mon, Nov 13, 2017 at 1:48 AM, 'Rupert Smith' via Elm Discuss <
[email protected]> wrote:
> On Saturday, November 11, 2017 at 6:33:34 PM UTC, art yerkes wrote:
>>
>> I always interpreted the warning in the documentation as "Don't use the
>> name LazyListView or the Nil and Cons constructors, instead using head,
>> tail and headAndTail for most pattern matchng". I think it makes sense not
>> to use the internal representation given that Dict and Array change when
>> better implementations arise. Does any code elm code actually pattern
>> match these instead of using the functions? Always thought it was weird to
>> have this type exposed at all.
>>
>
> I cannot use the 'cons' constructor though, as it is not lazy enough:
>
> generate : Generator a -> Seed -> LazyList a
> generate generator seed =
> let
> ( value, newSeed ) =
> Random.step generator seed
> in
> cons value (generate generator newSeed)
>
>
> Runs out of stack space, as the recursive step is evaluated eagerly.
>
> I think it is strange to expose a type but recommend not using it. Either
> a type is opaque and cannot be used directly, or exposed and it is
> perfectly ok to use it.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/BM_ZmUk-vck/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.