
From: Data.Complex data (RealFloat a) => Complex a = !a :+ !a What's the purpose of the exclamation marks? Michael

michael rice
From: Data.Complex
data (RealFloat a) => Complex a = !a :+ !a
What's the purpose of the exclamation marks?
Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Thanks, Ivan.
I may be back later, after I read
http://en.wikibooks.org/wiki/Haskell/Laziness
Michael
--- On Sat, 7/31/10, Ivan Lazar Miljenovic
From: Data.Complex
data (RealFloat a) => Complex a = !a :+ !a
What's the purpose of the exclamation marks?
Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Sat, Jul 31, 2010 at 2:32 PM, Ivan Lazar Miljenovic
Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed:
http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html
Actually, this isn't a bang pattern: the 'a' here is not a pattern, it's a type variable. Strictness flags in data declarations are a haskell98 feature. See: http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2 the paragraph on Strictness Flags a little way down that page.

Ben Millwood
On Sat, Jul 31, 2010 at 2:32 PM, Ivan Lazar Miljenovic
wrote: Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed:
http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html
Actually, this isn't a bang pattern: the 'a' here is not a pattern, it's a type variable. Strictness flags in data declarations are a haskell98 feature.
See:
http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2
the paragraph on Strictness Flags a little way down that page.
Ugh, yeah; I should read what links I google for before putting them in emails :s -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

This Joni Mitchell lyric just popped into my head: "I've looked at clouds from both sides now
From up and down, and still somehow It's cloud illusions I recall I really don't know clouds at all"
A LOT of cool stuff here, but the learning curve is murder.
Michael
--- On Sat, 7/31/10, Ivan Lazar Miljenovic
From: Data.Complex
data (RealFloat a) => Complex a = !a :+ !a
What's the purpose of the exclamation marks?
Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Ok, got ! and WHNF.
Thanks,
Michael
--- On Sat, 7/31/10, Ivan Lazar Miljenovic
From: Data.Complex
data (RealFloat a) => Complex a = !a :+ !a
What's the purpose of the exclamation marks?
Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
participants (3)
-
Ben Millwood
-
Ivan Lazar Miljenovic
-
michael rice