[Haskell-beginners] Syntax of Complex
Bob Ippolito
bob at redivi.com
Mon Jun 15 11:18:22 UTC 2015
On Monday, June 15, 2015, Shishir Srivastava <shishir.srivastava at gmail.com>
wrote:
> 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-whnf
https://hackhands.com/lazy-evaluation-works-haskell/
-bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150615/4b6e81c9/attachment.html>
More information about the Beginners
mailing list