[Haskell-beginners] homogeneous value list
byorgey at seas.upenn.edu
Sat Mar 13 15:06:44 EST 2010
On Fri, Mar 12, 2010 at 09:44:18AM -0500, Ron Leisti wrote:
> Does this have any implications say, for using infinite data
> structures? When we can we assume laziness (in order to use
> abstractions like infinity), and when can we not?
Not really. Personally, I find this thread a bit pedantic; at some
point it's good to understand the finer points of the Haskell
standard, but this really has almost no bearing on beginners. Use
lazy, infinite data structures to your heart's content. =)
> On Fri, Mar 12, 2010 at 9:39 AM, Thomas Davie <tom.davie at gmail.com> wrote:
> > On 12 Mar 2010, at 14:33, Ozgur Akgun wrote:
> > On 12 March 2010 14:28, Thomas Davie <tom.davie at gmail.com> wrote:
> >> On 12 Mar 2010, at 14:25, Salil Wadnerkar wrote:
> >> On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun <ozgurakgun at gmail.com>
> >> wrote:
> >> Another boring variant from me then.
> >> isHomogeneous xs = all (first==) xs
> >> where first = head xs
> >> Shouldn't
> >> head xs
> >> give an exception on an empty list?
> >> An error, and only if it's evaluated. Lazy evaluation means it's not
> >> evaluated here.
> >> Of course another non-strict algorithm *might* evaluate head xs here, so
> >> this version won't work in all possible Haskell implementations, only the
> >> current ones which use lazy evaluation.
> >> Bob
> > So we need to make sure our code would work in a strict environment, even
> > though we are using a lazily evaluated language, just in case if someone
> > comes up with a not-that-lazy implementation of haskell?
> > If I was thinking this way, I would just stop using haskell at all.
> > Not quite, you need to make sure your code works in *all* non-strict
> > evaluation models. Lazy evaluation is not the only non-strict evaluation
> > method, another implementation of non-strict semantics might actually
> > evaluate head xs.
> > Bob
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners