[Haskell-cafe] Info about List with terminal element
David Kraeutmann
kane at kane.cx
Wed Nov 25 21:16:19 UTC 2015
Oh, sorry. Yes, I missed the t. Thanks for clearing it up.
On Wed, Nov 25, 2015 at 9:47 PM, Silvio Frischknecht
<silvio.frischi at gmail.com> wrote:
>
>
> On 25.11.2015 20:38, David Kraeutmann wrote:
>> I'm not quite sure I understand the purpose of this structure. As far
>> as I can tell, it's isomorphic to list (even under laziness) with
>> some minor differences in performance characteristics (determining
>> whether a cons cell is terminal requires evaluating the subsequent
>> list to WHNF, whereas in your structure it follows from the
>> constructor. But I think that's just a minor performance detail).
>
> I think you misunderstand the structure. It is just a list that has an
> element of a type t at the end. It might not terminate.
>
> data List t e = Cons e (List t e) | Null | Terminal t
> data List t e = Cons e (List t e) | Null t
>
> are somewhat similar to
>
> ([e],Maybe t)
> ([e],t)
>
> respectively.
>
> but it is guaranteed that all cons of [e] are evaluated before t can be
> touched.
>
> Silvio
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list