4 ms·
Haskell is such a language. You can enable strict evaluation on a per module basis, or for an entire package.
by jose_zap 4y ago
Haskell is such a language. You can enable strict evaluation on a per module basis, or for an entire package.
- choeger 4y agoIs that a Haskell or GHC feature?
- mhitza 4y agoGHC extensions, StrictData (strict data structures) or Strict (strict evaluation for everything).
- brewmarche 4y agoWithout extensions you can do it per-case via `seq`, see https://wiki.haskell.org/Seq https://wiki.haskell.org/Seq (although it might get tricky because you might have to do it repeatedly because it only performs one “level" of evaluation) There is also another GHC extension called bang patterns to request strictness on pattern matches. The original bang (`!`) which is Standard Haskell can make fields of data structures strict, see: https://wiki.haskell.org/Performance/Data_types#Strict_fields https://wiki.haskell.org/Performance/Data_types#Strict_field... In general both lazy and strict languages can be strict or lazy. But the way it shows in the data types is different. A strict language can defer evaluation by adding a level of abstraction (instead of type `X` you have `() -> X`). A lazy language can force evaluation (it will have to evaluate at some point anyway) but you might not see it in the type. I’m not sure which one is better to be honest. Being able to infer laziness/strictness from the type is nice, but it also hinders interoperability.
- jose_zap 4y agoAt this point there is not difference between the two of them. GHC is Haskell for all practical purposes