
Hi, The Data.Complex package defines the new data type 'Complex' as ---------- data Complex a = !a :+ !a ------- Where ':+' is an infix operator. I don't however understand the usage of '!' in front of the type variable 'a'. What exactly is the purpose of '!' ? Any help would be appreciated. Thanks, Shishir Srivastava

On Monday, June 15, 2015, Shishir Srivastava
Hi,
The Data.Complex package defines the new data type 'Complex' as
----------
data Complex a = !a :+ !a
-------
Where ':+' is an infix operator. I don't however understand the usage of '!' in front of the type variable 'a'. What exactly is the purpose of '!' ?
'!' is a strictness annotation. This means that when the value is forced to weak-head normal form (by pattern matching, BangPatterns, or seq), then the fields with the ! will also be forced to weak-head normal form. See also: http://chimera.labs.oreilly.com/books/1230000000929/ch02.html#sec_par-eval-w... https://hackhands.com/lazy-evaluation-works-haskell/ -bob
participants (2)
-
Bob Ippolito
-
Shishir Srivastava