[Haskell-cafe] Re: If wishes were horses... (was: Re: definition of sum)

David Virebayre dav.vire+haskell at gmail.com
Fri Mar 12 05:07:24 EST 2010

On Fri, Mar 12, 2010 at 10:29 AM, Johannes Waldmann
<waldmann at imn.htwk-leipzig.de> wrote:

> Well, meaningful identifier names is nice, but I think
> here we have a case of the code smell "type info embedded in the name".
> Strictness of a function should be expressed in the function's type instead.
> But that seems impossible with Haskell at the moment.
> (At best, we can express strictness of constructors?)
> Hence we have "underspecified" behaviour:
> Prelude Data.List> :t foldl'
> foldl' :: (a -> b -> a) -> a -> [b] -> a
> Prelude Data.List> :t foldl
> foldl :: (a -> b -> a) -> a -> [b] -> a

Even if we had a syntax to express that the function is strict,
wouldn't we still need two distinct function names for the strict and
lazy case ? In that case, some sort of convention on naming is nice,
because if I want to change a function to its strict version, I know
there's a good chance it's the one that ends with a '

> and need to resort to the awkward workaround via naming conventions.
> Of course Haskell implementations do have some kind of strictness
> information (e.g., in ghc interface files), so it's not impossible
> to define some kind of annotation system.
> Although I did not check what the compiler's strictness info is
> for foldl and fold' - and what was actually needed (at the source level).
> The current textual definition (Data.List API docs: "foldl' = a
> strict version of foldl") is not too precise, either.
> Well, I guess there's a huge design space. But it's a huge problem
> (describing/controlling the behaviour of lazy programs).
> Best - J.W.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list