Syntax of Complex

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax of Complex

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 '!' ?

Any help would be appreciated.

Thanks,
Shishir Srivastava



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Syntax of Complex

Bob Ippolito
On Monday, June 15, 2015, Shishir Srivastava <[hidden email]> 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:

-bob

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners