Tidal icon indicating copy to clipboard operation
Tidal copied to clipboard

declare strict constructor arguments - instead of trying to deepseq later

Open jwaldmann opened this issue 5 years ago • 5 comments
trafficstars

(related: #606 https://github.com/rd--/hosc/pull/2#issuecomment-639522092)

If we do know that we never want lazy values - then we should declare strict constructor arguments. This is much better than sprinkling the code with rdeepseq later.

This states the intent, clearly, and in the right place (when we define the type), and it will check it automatically, every time, as early as possible (when the constructor is called).

By default, this should apply to

  • all data types that have NFData instances (currently, ArcF, Context, Value, Pattern)
  • all data types (e.g., Tempo, State, Config, EventF)? The latter could be achieved by pragma StrictData https://gitlab.haskell.org/ghc/ghc/-/wikis/strict-pragma I will give this a try.

What would be the remaining non-strict data? I think

  • Pattern (because it contains a function)
  • all prelude data types (List, Maybe)

Is there any part of the public API (Tidal's pattern combinators) that relies on laziness?

jwaldmann avatar Jun 05 '20 14:06 jwaldmann

Is there any part of the public API (Tidal's pattern combinators) that relies on laziness?

No, is this short answer..

yaxu avatar Jun 05 '20 22:06 yaxu

travis-CI tells me that StrictData is not available in ghc before 8.

If keeping compatibility with ghc-7 is important (for some folks it is, see this thread https://mail.haskell.org/pipermail/libraries/2020-May/030475.html ) then we have to put ! manually in data declarations.

jwaldmann avatar Jun 06 '20 16:06 jwaldmann

Yes I think it would be best to keep support of older versions of ghc, if it's just a matter of adding some !s.

yaxu avatar Jun 06 '20 23:06 yaxu

If it's important to keep support for ghc 7.x we can add a build on the ci

ndr-brt avatar Feb 03 '21 09:02 ndr-brt

Centos 6 that is mentioned in that thread is no longer maintained. Ubuntu Xenial is still supported and is on ghc 7.10.3. It might be worth adding that.

yaxu avatar Feb 03 '21 14:02 yaxu