Thiago Negri | 22 Aug 17:51 2013
Picon

Lifting strictness to types

I've just read the post "Destroying Performance with Strictness" by Neil Mitchell [1].

One of the comments from an Anonymous says:

How hard would it be to lift strictness annotations to type-level? E.g. instead of
f :: Int -> Int
f !x = x + 1
write
f :: !Int -> Int
f x = x + 1
which would have the same effect. At least it would be transparent to the developer using a particular function.

The problem I see with this approach is on type classes, as it would be impossible to declare a type instance with strict implementation to a type class that used lazy types.

Is this a real problem? Is it the only one?
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Tom Ellis | 22 Aug 18:10 2013
Picon

Re: Lifting strictness to types

On Thu, Aug 22, 2013 at 12:51:24PM -0300, Thiago Negri wrote:
> How hard would it be to lift strictness annotations to type-level? E.g.
> instead of
> f :: Int -> Int
> f !x = x + 1
> write
> f :: !Int -> Int
> f x = x + 1
> which would have the same effect. At least it would be transparent to the
> developer using a particular function.

See also the recent Reddit thread

    http://www.reddit.com/r/haskell/comments/1ksu0v/reasoning_about_space_leaks_with_space_invariants/cbsac5m

where I and others considered the possibility of a strict language with
explicit thunk datatype.  NB OCaml essentially already has this

    http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html

but I think Haskellers would do it better because we have a lot of
experience with purity, laziness and monad and comonad transformers.

Tom
Thiago Negri | 22 Aug 18:19 2013
Picon

Re: Lifting strictness to types

I think Scala has this optional laziness too.
The problem with default-strictness is that libraries that are built with no laziness in mind turn up to be too strict.
Going from lazy to strict is possible in the client side, but the other way is impossible.



2013/8/22 Tom Ellis <tom-lists-haskell-cafe-2013 <at> jaguarpaw.co.uk>
On Thu, Aug 22, 2013 at 12:51:24PM -0300, Thiago Negri wrote:
> How hard would it be to lift strictness annotations to type-level? E.g.
> instead of
> f :: Int -> Int
> f !x = x + 1
> write
> f :: !Int -> Int
> f x = x + 1
> which would have the same effect. At least it would be transparent to the
> developer using a particular function.

See also the recent Reddit thread

    http://www.reddit.com/r/haskell/comments/1ksu0v/reasoning_about_space_leaks_with_space_invariants/cbsac5m

where I and others considered the possibility of a strict language with
explicit thunk datatype.  NB OCaml essentially already has this

    http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html

but I think Haskellers would do it better because we have a lot of
experience with purity, laziness and monad and comonad transformers.

Tom

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Bardur Arantsson | 22 Aug 18:57 2013
Picon

Re: Lifting strictness to types

On 2013-08-22 18:19, Thiago Negri wrote:
> I think Scala has this optional laziness too.

Indeed, but it's _not_ apparent in types (which can be an issue).

Due to the somewhat weird constructor semantics of the JVM it also means
you can have immutable values which start out(!) as null and end up
being non-null.

Regards,

Gmane