Difference between revisions of "Strictness without ordering, or confusion"

From HaskellWiki
Jump to navigation Jump to search
(Created page with "Category:Proposals As the Haskell 2010 Report does not specify any order of evaluation with respect to its parameters, the name of the primitive <code>seq :: a -> b -> b...")
 
m (Replacement reference to "seq" page, other minor changes)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Proposals]]
 
[[Category:Proposals]]
   
 
<code>Prelude.seq :: a -> b -> b</code> is [[Seq|non]]-sequential: the Haskell 2010 Report does not specify any order of evaluation with respect to its parameters. Hence the use of the name "seq" is a misnomer.
 
As the Haskell 2010 Report does not specify any order of evaluation with respect to its parameters, the name of the primitive <code>seq :: a -> b -> b</code> is a misnomer.
 
   
 
Introduce the primitive <code>amid</code>, with the same (Haskell 2010 Report) requirements:
 
Introduce the primitive <code>amid</code>, with the same (Haskell 2010 Report) requirements:
Line 13: Line 12:
 
($!) :: (a -> b) -> a -> b
 
($!) :: (a -> b) -> a -> b
 
f $! x = x `amid` f x
 
f $! x = x `amid` f x
 
 
</haskell>
 
</haskell>
   
 
This frees the name "seq" for use with a new primitive definition, analogous to GHC's <code>Control.Parallel.pseq</code>, but not restricted to parallel programming.
 
This frees the name "seq" for use with a new primitive, analogous to the GHC primitive <code>pseq</code>, but not restricted to parallel programming.
 
   
 
If needed, "amidst" is one alternate basename for the ''deepseq'' library and its definitions.
 
If needed, "amidst" is one alternate basename for the ''deepseq'' library and its definitions.

Latest revision as of 02:08, 20 September 2024


Prelude.seq :: a -> b -> b is non-sequential: the Haskell 2010 Report does not specify any order of evaluation with respect to its parameters. Hence the use of the name "seq" is a misnomer.

Introduce the primitive amid, with the same (Haskell 2010 Report) requirements:

         infixr 0 `amid`
         primtive amid :: a -> b -> b

         infixr 0 $!
         ($!) :: (a -> b) -> a -> b
         f $! x =  x `amid` f x

This frees the name "seq" for use with a new primitive definition, analogous to GHC's Control.Parallel.pseq, but not restricted to parallel programming.

If needed, "amidst" is one alternate basename for the deepseq library and its definitions.

Atravers 01:17, 7 January 2019 (UTC)