Re: [HOpenGL] Newbie: Difference between $= and <- operators?

the $= only works for OpenGL state variables, whereas <- won't work
for them. The difference is that $= is implemented by every member of
the SettableStateVar class differently, so that there may be extra
functionality going on under the hood. The <- operator on the other
hand always has the same meaning (relatively speaking -- it's possible
to override this), in that it is a substitude for
a <- someAction
is the same as
someAction >>= \a -> {- the rest of the do expression -}
-- Jeff
2009/3/20 Mark Spezzano
Hi,
What is the difference between the $= operator and the <- operator
Both seem to read “assign to” but surely there is a difference.
What should I use when?
I want to create an animation that reads some coordinate (state-ful) data.
Should I use $= or <- ?
Cheers,
Mark Spezzano
No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.20/2012 - Release Date: 19/03/2009 12:26 PM
_______________________________________________ HOpenGL mailing list HOpenGL@haskell.org http://www.haskell.org/mailman/listinfo/hopengl

Am Freitag, 20. März 2009 17:00:57 schrieb Jeff Heard:
the $= only works for OpenGL state variables, whereas <- won't work for them. [...]
This is partly correct: $= and friends work for e.g. IORefs, too. As Jeff already pointed out, the "do" notation is only handy way to combine monadic actions and bind values to names (this is what <- effectively does). OTOH, have a look at the signature of $= below: class HasSetter s where ($=) :: s a -> a -> IO () "foo $= bar" does not bind foo to bar, it executes some action, using foo and bar. In the case when foo is an IORef, it puts the value named by bar into foo. In the case when foo is some kind of OpenGL state variable, it changes the corresponding part of the OpenGL state machine (calling the driver, setting up HW, etc.). In other words (slightly simplified): You can think of $= as an actual "imperative" assignment, while <- is a binding construct, giving a value a name. Cheers, S.
participants (2)
-
Jeff Heard
-
Sven Panne