[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts

wren ng thornton wren at freegeek.org
Tue Mar 8 02:11:07 CET 2011


On 3/7/11 6:58 PM, Alexander Solla wrote:
> The "magic" semantics of evaluating the first argument are done by the
> compiler/runtime, and are apparently not expressible in Haskell.

Of course this is true. The only ways of forcing evaluation in Haskell 
are (a) to perform pattern matches on a value, (b) use 'seq'--- either 
directly or in its disguised forms: strict data constructors and 
-XBangPatterns.

In order to use pattern matching you need to know what the constructors 
of the type are in order to force a choice between different 
constructors; therefore you can't use case analysis to define a function 
with the type and semantics of 'seq'.

But 'seq' is still defined in the Haskell report and therefore a part of 
Haskell. Many have lamented the problems introduced by a parametric 
polymorphic 'seq'; if it were just type-class polymorphic then it 
wouldn't be such a problem. But then a type-class polymorphic 'seq' 
could lead to maintenance issues similar to those faced by Java's 
checked exceptions, which is why it was rejected from Haskell.

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list