[Haskell-cafe] Infix operators naming conflicts (was: class Ref)
Dimitry Golubovsky
golubovsky at gmail.com
Tue Jun 7 09:21:35 EDT 2005
Gracjan Polak wrote:
> val = readIORef
> a=:b = writeIORef a b
Pretty shame := is already reserver :(. There is something alike
Graphics.Rendering.OpenGL.GL.StateVar. The use $= for assignment.
Generalizing "variables" (in respect to some monad) seems to be often
reinvented idea :)
Indeed, has anyone tried to summarize possible conflicts between infix
operators as they are defined in many places to serve different
purpose?
e. g.
(!) :: Ix i => Array i e -> i -> e
The value at the given index in an array. (Data.Array)
(!) :: a -> [HtmlAttr] -> a (Text.Html)
so if a module imports both modules mentioned above simultaneously,
will the compiler complain about (!) and ask to use a qualified name?
I had the following experience: when trying to create a convenient
syntax to access fields of foreign C structures using appropriate Ptr
and field label, I tried to define a combinator for that, and to name
it (.) (dot, same as dot-composition defined in Prelude, to look
similarly to Java notation) Type signature for my (.) was totally
different than Prelude's (.), and semantically it is not composition
of functions. However the compiler (GHC) asked to use qualified name.
Finally I ended up with the name (-->) which looks like C notation.
But who knows, whether someone wishes to use (-->) for other purposes?
--
Dimitry Golubovsky
Anywhere on the Web
More information about the Haskell-Cafe
mailing list